generated from tweag/project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Switch to a crane based build
- Loading branch information
Erin van der Veen
committed
Apr 2, 2024
1 parent
0550d05
commit f87f8b9
Showing
4 changed files
with
112 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,118 @@ | ||
{ | ||
inputs = { | ||
naersk.url = "github:nix-community/naersk/master"; | ||
crane = { | ||
url = "github:ipetkov/crane"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; | ||
|
||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
utils.url = "github:numtide/flake-utils"; | ||
nixtract.url = "github:tweag/nixtract"; | ||
}; | ||
|
||
outputs = | ||
{ self | ||
, crane | ||
, nixpkgs | ||
, utils | ||
, naersk | ||
, nixtract | ||
}: | ||
utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = import nixpkgs { inherit system; }; | ||
naersk-lib = pkgs.callPackage naersk { }; | ||
crane-lib = crane.lib.${system}; | ||
cyclonedx = pkgs.callPackage ./nix/cyclonedx.nix { }; | ||
nixtract-cli = nixtract.defaultPackage.${system}; | ||
|
||
# Here we start the crane stuff | ||
common-crane-args = { | ||
pname = "genealogos"; | ||
src = crane-lib.cleanCargoSource (crane-lib.path ./.); | ||
strictDeps = true; | ||
|
||
cargoArtifacts = cargo-artifacts; | ||
|
||
# Genealogos uses the reqwest crate to query for narinfo on the substituters. | ||
# reqwest depends on openssl. | ||
nativeBuildInputs = with pkgs; [ pkg-config ]; | ||
buildInputs = with pkgs; [ openssl ]; | ||
}; | ||
|
||
cargo-artifacts = crane-lib.buildDepsOnly common-crane-args; | ||
|
||
workspace = (common-crane-args // { | ||
cargoBuildCommand = "${pkgs.cargo-hack}/bin/cargo-hack hack build --profile release"; | ||
cargoTestCommand = "${pkgs.cargo-hack}/bin/cargo-hack hack test --profile release"; | ||
}); | ||
|
||
# Crane buildPackage arguments for every crate | ||
crates = { | ||
genealogos = (common-crane-args // { | ||
cargoExtraArgs = "-p genealogos"; | ||
}); | ||
genealogos-cli = (common-crane-args // { | ||
pname = "genealogos-cli"; | ||
cargoExtraArgs = "-p genealogos-cli"; | ||
}); | ||
genealogos-api = (common-crane-args // { | ||
pname = "genealogos-api"; | ||
cargoExtraArgs = "-p genealogos-api"; | ||
}); | ||
}; | ||
rust-packages = | ||
builtins.mapAttrs (_: crane-lib.buildPackage) crates; | ||
in | ||
rec { | ||
packages = import ./nix/packages.nix { inherit pkgs naersk-lib cyclonedx nixtract-cli; }; | ||
devShells = { | ||
default = | ||
pkgs.mkShell { | ||
buildInputs = with pkgs; [ | ||
cargo | ||
cargo-dist | ||
rust-analyzer | ||
rustPackages.clippy | ||
rustc | ||
rustfmt | ||
|
||
nixtract-cli | ||
|
||
pkg-config | ||
openssl | ||
|
||
# https://github.com/rust-lang/cargo/issues/4463 | ||
cargo-hack | ||
]; | ||
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; | ||
RUST_BACKTRACE = 1; | ||
checks = | ||
# Builds | ||
rust-packages | ||
# Clippy | ||
// builtins.mapAttrs | ||
(_: args: crane-lib.cargoClippy (args // { | ||
cargoClippyExtraArgs = "--all-targets -- --deny warnings"; | ||
})) | ||
crates | ||
# Doc | ||
// builtins.mapAttrs (_: crane-lib.cargoDoc) crates | ||
# fmt | ||
// builtins.mapAttrs (_: crane-lib.cargoFmt) crates; | ||
|
||
packages = | ||
rust-packages // { | ||
default = packages.genealogos; | ||
|
||
workspace = crane-lib.buildPackage workspace; | ||
|
||
update-fixture-output-files = pkgs.writeShellApplication { | ||
name = "update-fixture-output-files"; | ||
runtimeInputs = [ (packages.genealogos-cli.overrideAttrs (_: { doCheck = false; })) pkgs.jq ]; | ||
text = builtins.readFile ./scripts/update-fixture-output-files.sh; | ||
}; | ||
scripts = | ||
pkgs.mkShell { | ||
buildInputs = with packages; [ | ||
update-fixture-input-files | ||
update-fixture-output-files | ||
verify-fixture-files | ||
]; | ||
update-fixture-input-files = pkgs.writeShellApplication { | ||
name = "update-fixture-input-files"; | ||
runtimeInputs = [ nixtract-cli ]; | ||
text = builtins.readFile ./scripts/update-fixture-input-files.sh; | ||
}; | ||
verify-fixture-files = pkgs.writeShellApplication { | ||
name = "verify-fixture-files"; | ||
runtimeInputs = [ cyclonedx ]; | ||
text = builtins.readFile ./scripts/verify-fixture-files.sh; | ||
}; | ||
}; | ||
|
||
apps.default = utils.lib.mkApp { | ||
drv = packages.genealogos-cli; | ||
}; | ||
|
||
|
||
devShells.default = crane-lib.devShell { | ||
inherit checks; | ||
|
||
packages = with pkgs; [ | ||
rust-analyzer | ||
cargo-hack | ||
]; | ||
}; | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.