From f18e17b02a9284513a2f5170c84e2258c3c3ade3 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 3 Dec 2023 00:19:36 +0200 Subject: [PATCH] Less repetitiveness in Nix files --- flake.nix | 5 ++--- package.nix | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index a6a30b8..293a4ea 100644 --- a/flake.nix +++ b/flake.nix @@ -27,14 +27,13 @@ }; }; packages = { - # Besides the `src` and `version` arguments, this package.nix could + # Besides the `src` and `cargoTomlPkg` arguments, this package.nix could # be copied as is to Nixpkgs' # pkgs/development/python-modules/pysequoia/default.nix, and should be # maintained in parallel to this local version of it. pysequoia = pkgs.python3.pkgs.callPackage ./package.nix { src = self; - # Get the version defined in pyproject.toml - version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version; + cargoTomlPkg = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package; }; }; } diff --git a/package.nix b/package.nix index ff6522e..37a876e 100644 --- a/package.nix +++ b/package.nix @@ -1,7 +1,7 @@ { lib , buildPythonPackage , src -, version +, cargoTomlPkg , pkg-config , rustPlatform , cargo @@ -17,7 +17,8 @@ buildPythonPackage rec { pname = "pysequoia"; - inherit src version; + inherit src; + inherit (cargoTomlPkg) version; pyproject = true; # This attribute is defined differently in Nixpkgs - using @@ -50,11 +51,13 @@ buildPythonPackage rec { pythonImportsCheck = [ "pysequoia" ]; - meta = with lib; { - description = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.description; - downloadPage = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.repository; - homepage = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.homepage; - license = licenses.asl20; - maintainers = with maintainers; [ doronbehar ]; + meta = { + inherit (cargoTomlPkg) + description + homepage + ; + downloadPage = cargoTomlPkg.repository; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ doronbehar ]; }; }