Add package to flake outputs

This commit is contained in:
Marcin Kulik
2024-04-20 14:02:53 +02:00
parent 2ca178a86f
commit c3a5233afe
2 changed files with 116 additions and 16 deletions

71
flake.lock generated
View File

@@ -18,6 +18,24 @@
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1707877513,
@@ -34,10 +52,46 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1706487304,
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1713579131,
"narHash": "sha256-j/lrqFNzm7SdlBlKX43kA2Wp0OaGVOUjQGnER9//4Ao=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "67e961704b80454f1ba6595b02e26afc9af4cdce",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
@@ -54,6 +108,21 @@
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",

View File

@@ -3,22 +3,53 @@
inputs = {
nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable;
rust-overlay.url = github:oxalica/rust-overlay;
flake-utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let pkgs = nixpkgs.legacyPackages.${system}; in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
rustup
] ++ (lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Foundation
]);
};
}
);
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
msrv = cargoToml.package.rust-version;
buildDeps = rust: with pkgs; [
rust
] ++ (lib.optionals stdenv.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Foundation
]) ++ testDeps;
testDeps = with pkgs; [
python3
procps # provides `w` binary
];
mkDevShell = rust: pkgs.mkShell {
nativeBuildInputs = buildDeps (rust.override {
extensions = [ "rust-src" ];
});
RUST_BACKTRACE = 1;
};
mkPackage = rust: (pkgs.makeRustPlatform {
cargo = rust;
rustc = rust;
}).buildRustPackage {
inherit (cargoToml.package) name version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = buildDeps rust;
dontUseCargoParallelTests = true;
};
in
{
devShells.default = mkDevShell pkgs.rust-bin.stable.latest.default;
devShells.msrv = mkDevShell pkgs.rust-bin.stable.${msrv}.default;
packages.default = mkPackage pkgs.rust-bin.stable.latest.minimal;
}
);
}