Skip to content

Commit

Permalink
Add argument to enable filtering of packages from lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
icetan committed Oct 24, 2022
1 parent d6c6a2b commit 06a79b9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ lib.makeScope pkgs.newScope (self: {
, pyProject ? readTOML pyproject
, groups ? [ ]
, checkGroups ? [ "dev" ]
}:
, filterLock ? (_: true)
}@attrs:
let
/* The default list of poetry2nix override overlays */
mkEvalPep508 = import ./pep508.nix {
Expand All @@ -158,9 +159,12 @@ lib.makeScope pkgs.newScope (self: {
editablePackageSources = editablePackageSources';
};

poetryLock = readTOML poetrylock;

# Lock file version 1.1 files
poetryLock = let
lock = readTOML poetrylock;
in
lock // { package = builtins.filter filterLock lock.package; };

lockFiles =
let
lockfiles = lib.getAttrFromPath [ "metadata" "files" ] poetryLock;
Expand Down Expand Up @@ -300,6 +304,7 @@ lib.makeScope pkgs.newScope (self: {
, editablePackageSources ? { }
, extraPackages ? ps: [ ]
, groups ? [ "dev" ]
, filterLock ? (_: true)
}:
let
inherit (lib) hasAttr;
Expand Down Expand Up @@ -332,7 +337,7 @@ lib.makeScope pkgs.newScope (self: {
excludedEditablePackageNames;

poetryPython = self.mkPoetryPackages {
inherit pyproject poetrylock overrides python pwd preferWheels pyProject groups;
inherit pyproject poetrylock overrides python pwd preferWheels pyProject groups filterLock;
editablePackageSources = editablePackageSources';
};

Expand Down Expand Up @@ -367,11 +372,12 @@ lib.makeScope pkgs.newScope (self: {
, preferWheels ? false
, groups ? [ ]
, checkGroups ? [ "dev" ]
, filterLock ? (_: true)
, ...
}@attrs:
let
poetryPython = self.mkPoetryPackages {
inherit pyproject poetrylock overrides python pwd preferWheels groups checkGroups;
inherit pyproject poetrylock overrides python pwd preferWheels groups checkGroups filterLock;
};
py = poetryPython.python;

Expand All @@ -383,6 +389,7 @@ lib.makeScope pkgs.newScope (self: {
"pwd"
"pyproject"
"preferWheels"
"filterLock"
];
passedAttrs = builtins.removeAttrs attrs specialAttrs;

Expand Down

0 comments on commit 06a79b9

Please sign in to comment.