Simplify flake

This commit is contained in:
Sam W 2021-11-17 22:55:49 +00:00
parent 02512d0377
commit d845e108b6
2 changed files with 30 additions and 66 deletions

View File

@ -39,7 +39,23 @@
"root": { "root": {
"inputs": { "inputs": {
"naersk": "naersk", "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"
} }
} }
}, },

View File

@ -3,76 +3,24 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nmattia/naersk"; naersk.url = "github:nmattia/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs"; naersk.inputs.nixpkgs.follows = "nixpkgs";
}; };
outputs = { self, nixpkgs, naersk }: outputs = { self, nixpkgs, utils, naersk }:
let let
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml)); 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 in
{ utils.lib.eachDefaultSystem (system: let
overlay = final: prev: { pkgs = nixpkgs.legacyPackages."${system}";
"${cargoToml.package.name}" = final.callPackage ./. { inherit naersk; }; naersk-lib = naersk.lib."${system}";
in rec {
packages."${cargoToml.package.name}" = naersk-lib.buildPackage {
pname = "${cargoToml.package.name}";
root = ./.;
buildInputs = [ pkgs.openssl ];
}; };
defaultPackage = packages."${cargoToml.package.name}";
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";
});
};
}