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" "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": { "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": { "locked": {
"lastModified": 1725634671, "lastModified": 1725634671,
"narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=",
@ -34,7 +64,7 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1718428119, "lastModified": 1718428119,
"narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",
@ -53,13 +83,14 @@
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1726021481, "lastModified": 1726021481,

View file

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