diff options
| author | Franck Cuny <franck@fcuny.net> | 2022-11-01 08:51:36 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2022-11-01 18:46:27 -0700 |
| commit | 04a4d34e94c6333768a136ef8f40d367629f7e00 (patch) | |
| tree | f10292aae1188c4f13a4a2ba4fda0348af8b1b13 /src/x509-info/flake.nix | |
| parent | build: configure rust overlay to follow nixpkgs (diff) | |
| download | x-04a4d34e94c6333768a136ef8f40d367629f7e00.tar.gz | |
build: get rid of naersk
We can build a rust binary without naesrk,with the help of
`buildRustPackage`.
Simplify a bit the overall build by consuming information from
Cargo.toml and Cargo.lock.
Diffstat (limited to 'src/x509-info/flake.nix')
| -rw-r--r-- | src/x509-info/flake.nix | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/src/x509-info/flake.nix b/src/x509-info/flake.nix index 4861588..ca1762f 100644 --- a/src/x509-info/flake.nix +++ b/src/x509-info/flake.nix @@ -8,48 +8,53 @@ url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; - naersk.url = "github:nmattia/naersk"; }; outputs = { self , flake-utils , nixpkgs - , naersk , rust-overlay }: + let + # Borrow project metadata from the Rust config + meta = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package; + inherit (meta) name version; + overlays = [ + # Rust helpers + (import rust-overlay) + # Build Rust toolchain using helpers from rust-overlay + (self: super: { + # This supplies cargo, rustc, rustfmt, etc. + rustToolchain = super.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + }) + ]; + in flake-utils.lib.eachDefaultSystem (system: let - overlays = [ (import rust-overlay) ]; - pkgs = import nixpkgs { inherit system overlays; }; - rust-toolchain = - (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override { - extensions = [ "rust-src" ]; - }; - naersk-lib = naersk.lib."${system}".override { - rustc = rust-toolchain; - }; + pkgs = import nixpkgs { inherit overlays system; }; in - rec { - packages.x509-info = naersk-lib.buildPackage { - pname = "x509-info"; - root = ./.; - buildInputs = with pkgs; [ ]; + packages = rec { + default = x509-info; + x509-info = pkgs.rustPlatform.buildRustPackage { + pname = name; + inherit version; + src = ./.; + release = true; + cargoLock.lockFile = ./Cargo.lock; + }; }; - defaultPackage = packages.x509-info; - devShell = pkgs.mkShell { nativeBuildInputs = with pkgs; [ - rust-toolchain + rustToolchain cargo-audit cargo-deny - cargo-cross rust-analyzer - ] ++ pkgs.lib.optionals (pkgs.stdenv.isLinux) (with pkgs; [ cargo-watch ]); + ]; shellHook = '' cargo --version @@ -62,3 +67,4 @@ }; }; } + |
