From bc92ad7f9f8f8f668ccc93ebeb2ee5a58adc2c94 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Fri, 24 May 2024 12:28:14 -0300 Subject: [PATCH 1/2] Use Cargo.toml version in Nix package --- flake.nix | 5 ++++- package.nix | 13 +++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 560d87c..b8b4cc1 100644 --- a/flake.nix +++ b/flake.nix @@ -21,6 +21,7 @@ outputs = { self, nixpkgs, nix, ... }@inputs: let + mncMeta = (builtins.fromTOML (builtins.readFile ./magic-nix-cache/Cargo.toml)).package; overlays = [ inputs.rust-overlay.overlays.default nix.overlays.default ]; supportedSystems = [ "aarch64-linux" @@ -40,7 +41,9 @@ in { 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; default = magic-nix-cache; }); diff --git a/package.nix b/package.nix index 6103341..f9617ad 100644 --- a/package.nix +++ b/package.nix @@ -1,4 +1,6 @@ -{ lib, stdenv, rustPlatform +{ lib +, stdenv +, rustPlatform , pkg-config , installShellFiles , nix @@ -7,14 +9,16 @@ , rust-analyzer , clippy , rustfmt +, version }: let ignoredPaths = [ ".github" "target" "book" ]; -in rustPlatform.buildRustPackage rec { +in +rustPlatform.buildRustPackage rec { pname = "magic-nix-cache"; - version = "0.1.0"; + inherit version; src = lib.cleanSourceWith { filter = name: type: !(type == "directory" && builtins.elem (baseNameOf name) ignoredPaths); @@ -30,7 +34,8 @@ in rustPlatform.buildRustPackage rec { ]; buildInputs = [ - nix boost + nix + boost ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ SystemConfiguration ]); From 824e740fe82cc35ef6685ce6e643572abf526d27 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Fri, 24 May 2024 12:59:43 -0300 Subject: [PATCH 2/2] Move version inference logic into package.nix --- flake.nix | 5 +---- package.nix | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index b8b4cc1..560d87c 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,6 @@ outputs = { self, nixpkgs, nix, ... }@inputs: let - mncMeta = (builtins.fromTOML (builtins.readFile ./magic-nix-cache/Cargo.toml)).package; overlays = [ inputs.rust-overlay.overlays.default nix.overlays.default ]; supportedSystems = [ "aarch64-linux" @@ -41,9 +40,7 @@ in { packages = forEachSupportedSystem ({ pkgs, cranePkgs, ... }: rec { - magic-nix-cache = pkgs.callPackage ./package.nix { - inherit (mncMeta) version; - }; + magic-nix-cache = pkgs.callPackage ./package.nix { }; #inherit (cranePkgs) magic-nix-cache; default = magic-nix-cache; }); diff --git a/package.nix b/package.nix index f9617ad..63dbc30 100644 --- a/package.nix +++ b/package.nix @@ -9,12 +9,11 @@ , rust-analyzer , clippy , rustfmt -, version }: let ignoredPaths = [ ".github" "target" "book" ]; - + version = (builtins.fromTOML (builtins.readFile ./magic-nix-cache/Cargo.toml)).package.version; in rustPlatform.buildRustPackage rec { pname = "magic-nix-cache";