Simplify flake
This commit is contained in:
parent
02512d0377
commit
d845e108b6
18
flake.lock
18
flake.lock
|
@ -39,7 +39,23 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1637014545,
|
||||
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "bba5dcc8e0b20ab664967ad83d24d64cb64ec4f4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
78
flake.nix
78
flake.nix
|
@ -3,76 +3,24 @@
|
|||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
naersk.url = "github:nmattia/naersk";
|
||||
naersk.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, naersk }:
|
||||
outputs = { self, nixpkgs, utils, naersk }:
|
||||
let
|
||||
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
|
||||
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
||||
in
|
||||
{
|
||||
overlay = final: prev: {
|
||||
"${cargoToml.package.name}" = final.callPackage ./. { inherit naersk; };
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
naersk-lib = naersk.lib."${system}";
|
||||
in rec {
|
||||
packages."${cargoToml.package.name}" = naersk-lib.buildPackage {
|
||||
pname = "${cargoToml.package.name}";
|
||||
root = ./.;
|
||||
buildInputs = [ pkgs.openssl ];
|
||||
};
|
||||
|
||||
packages = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
self.overlay
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
|
||||
});
|
||||
|
||||
|
||||
defaultPackage = forAllSystems (system: (import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
})."${cargoToml.package.name}");
|
||||
|
||||
checks = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
self.overlay
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
format = pkgs.runCommand "check-format"
|
||||
{
|
||||
buildInputs = with pkgs; [ rustfmt cargo ];
|
||||
} ''
|
||||
${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check
|
||||
${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
|
||||
touch $out # it worked!
|
||||
'';
|
||||
"${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
|
||||
});
|
||||
devShell = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ self.overlay ];
|
||||
};
|
||||
in
|
||||
pkgs.mkShell {
|
||||
inputsFrom = with pkgs; [
|
||||
pkgs."${cargoToml.package.name}"
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
rustfmt
|
||||
nixpkgs-fmt
|
||||
];
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
});
|
||||
};
|
||||
}
|
||||
defaultPackage = packages."${cargoToml.package.name}";
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue