nix: switch to naersk rust infrastructure

This commit is contained in:
Youwen Wu 2024-09-12 01:13:32 -07:00
parent c0b47b1fbc
commit 435d7a0407
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
2 changed files with 56 additions and 14 deletions

View file

@ -18,7 +18,37 @@
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1721727458,
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
"owner": "nix-community",
"repo": "naersk",
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 0,
"narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=",
"path": "/nix/store/5w3dp0m37794iffsbm9vd9f1xmmhda6i-source",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1725634671,
"narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=",
@ -34,7 +64,7 @@
"type": "github"
}
},
"nixpkgs_2": {
"nixpkgs_3": {
"locked": {
"lastModified": 1718428119,
"narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",
@ -53,13 +83,14 @@
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": "nixpkgs_2"
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1726021481,

View file

@ -5,6 +5,7 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "github:nix-community/naersk";
};
outputs =
@ -12,6 +13,7 @@
nixpkgs,
flake-utils,
rust-overlay,
naersk,
...
}:
flake-utils.lib.eachDefaultSystem (
@ -19,6 +21,18 @@
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
naersk' = pkgs.callPackage naersk { };
defaultBuildOpts = {
cargo = pkgs.rust-bin.stable.latest.default;
rustc = pkgs.rust-bin.stable.latest.default;
src = ./.;
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
mode = "build";
};
in
{
devShells.default = pkgs.mkShell {
@ -30,17 +44,14 @@
rust-bin.stable.latest.rustfmt
];
};
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "cartographer";
version = "0.1.0";
src = ./.;
cargoHash = "sha256-6nqR5x34o8zCpNVp8NUC7+7j48rOkbHKJF9AU3bBs+c=";
# cargoHash = pkgs.lib.fakeHash;
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
packages = {
default = naersk'.buildPackage defaultBuildOpts;
test = naersk'.buildPackage (
defaultBuildOpts
// {
mode = "test";
}
);
};
}
);