-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to a crane based build #42
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although it seems to work in practice, the cyclic dependency between |
||
|
||
# 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I'm often that guy but.... not a very high entropy comment 😛