Use Cargo.toml version in Nix package

This commit is contained in:
Luc Perkins 2024-05-24 12:28:14 -03:00
parent 18f457e56e
commit bc92ad7f9f
No known key found for this signature in database
GPG key ID: 16DB1108FB591835
2 changed files with 13 additions and 5 deletions

View file

@ -21,6 +21,7 @@
outputs = { self, nixpkgs, nix, ... }@inputs: outputs = { self, nixpkgs, nix, ... }@inputs:
let let
mncMeta = (builtins.fromTOML (builtins.readFile ./magic-nix-cache/Cargo.toml)).package;
overlays = [ inputs.rust-overlay.overlays.default nix.overlays.default ]; overlays = [ inputs.rust-overlay.overlays.default nix.overlays.default ];
supportedSystems = [ supportedSystems = [
"aarch64-linux" "aarch64-linux"
@ -40,7 +41,9 @@
in in
{ {
packages = forEachSupportedSystem ({ pkgs, cranePkgs, ... }: rec { packages = forEachSupportedSystem ({ pkgs, cranePkgs, ... }: rec {
magic-nix-cache = pkgs.callPackage ./package.nix { }; magic-nix-cache = pkgs.callPackage ./package.nix {
inherit (mncMeta) version;
};
#inherit (cranePkgs) magic-nix-cache; #inherit (cranePkgs) magic-nix-cache;
default = magic-nix-cache; default = magic-nix-cache;
}); });

View file

@ -1,4 +1,6 @@
{ lib, stdenv, rustPlatform { lib
, stdenv
, rustPlatform
, pkg-config , pkg-config
, installShellFiles , installShellFiles
, nix , nix
@ -7,14 +9,16 @@
, rust-analyzer , rust-analyzer
, clippy , clippy
, rustfmt , rustfmt
, version
}: }:
let let
ignoredPaths = [ ".github" "target" "book" ]; ignoredPaths = [ ".github" "target" "book" ];
in rustPlatform.buildRustPackage rec { in
rustPlatform.buildRustPackage rec {
pname = "magic-nix-cache"; pname = "magic-nix-cache";
version = "0.1.0"; inherit version;
src = lib.cleanSourceWith { src = lib.cleanSourceWith {
filter = name: type: !(type == "directory" && builtins.elem (baseNameOf name) ignoredPaths); filter = name: type: !(type == "directory" && builtins.elem (baseNameOf name) ignoredPaths);
@ -30,7 +34,8 @@ in rustPlatform.buildRustPackage rec {
]; ];
buildInputs = [ buildInputs = [
nix boost nix
boost
] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
SystemConfiguration SystemConfiguration
]); ]);