diff --git a/flake.nix b/flake.nix index a45523e..f5b36db 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,7 @@ }; outputs = - inputs@{ flake-parts, pyproject-nix, ... }: + inputs@{ self, flake-parts, pyproject-nix, ... }: flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" @@ -33,7 +33,10 @@ python = pkgs.python3.override { packageOverrides = import ./nix/mkPackageOverrides.nix { inherit pkgs; }; }; - packageAttrs = import ./nix/mkPackageAttrs.nix { inherit pkgs project python; }; + packageAttrs = import ./nix/mkPackageAttrs.nix { + inherit pkgs project python; + rev = self.rev or null; + }; in { packages = { diff --git a/nix/mkPackageAttrs.nix b/nix/mkPackageAttrs.nix index 66942b8..8f4c389 100644 --- a/nix/mkPackageAttrs.nix +++ b/nix/mkPackageAttrs.nix @@ -1,16 +1,30 @@ -{ pkgs, project, python }: -(project.renderers.buildPythonPackage { inherit python; }) // { - src = ./..; - postPatch = '' - substituteInPlace pyproject.toml \ - --replace-fail "cryptg-anyos" "cryptg" - ''; - pythonRelaxDeps = [ - "cryptg" - ]; - meta = { - license = pkgs.lib.licenses.mit; - homepage = "https://tgpy.tmat.me/"; - pythonImportsCheck = [ "tgpy" ]; +{ + pkgs, + project, + python, + rev, +}: +let + postPatch = + '' + substituteInPlace pyproject.toml \ + --replace-fail "cryptg-anyos" "cryptg" + '' + + pkgs.lib.optionalString (rev != null) '' + substituteInPlace tgpy/version.py \ + --replace-fail "COMMIT_HASH = None" "COMMIT_HASH = \"${rev}\"" + ''; + newAttrs = { + src = ./..; + inherit postPatch; + pythonRelaxDeps = [ + "cryptg" + ]; + meta = { + license = pkgs.lib.licenses.mit; + homepage = "https://tgpy.tmat.me/"; + pythonImportsCheck = [ "tgpy" ]; + }; }; -} +in +(project.renderers.buildPythonPackage { inherit python; }) // newAttrs