From f6f7f81f94fe00df0dd756b517848296a622867c Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 9 Sep 2024 13:15:25 +0100 Subject: build: use nix to build binaries using rustPlatform.buildRustPackage as used in nixpkgs --- flake.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index bdaa633..5015dba 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,7 @@ pkgs = import nixpkgs { inherit system overlays; }; + manifest = pkgs.lib.importTOML ./Cargo.toml; in with pkgs; { @@ -42,6 +43,22 @@ export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} ''; }; + # Create packages for each binary defined in Cargo.toml + packages = lib.listToAttrs (map (bin: { + inherit (bin) name; + value = pkgs.rustPlatform.buildRustPackage { + pname = bin.name; + version = manifest.package.version; + src = bin.path; + cargoLock = { + lockFile = ./Cargo.lock; + }; + buildInputs = [ + pkgs.pkg-config + pkgs.openssl + ]; + }; + }) manifest.bin); } ); -} +} \ No newline at end of file -- cgit v1.2.3