Skip to content

Commit

Permalink
Merge pull request #1285 from rohaquinlop/issue-1282
Browse files Browse the repository at this point in the history
feat(build): #1282 assure purity removing dir
  • Loading branch information
rohaquinlop authored Jan 31, 2024
2 parents 6eb19e6 + 8e570ae commit b2cca5f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Andres Cuberos <[email protected]> Andres Cuberos <[email protected]>
Andres Cuberos <[email protected]> Andres Cuberos <[email protected]>
Brandon Lotero <[email protected]> Brandon Lotero <[email protected]>
Briam Agudelo <[email protected]> Briam Agudelo <[email protected]>
Daniel Murcia <[email protected]> Daniel F. Murcia Rivera <[email protected]>
Daniel Murcia <[email protected]> Daniel Murcia <[email protected]>
Daniel Salazar <[email protected]> Daniel Salazar <[email protected]>
Expand Down
52 changes: 51 additions & 1 deletion src/args/make-python-environment/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,29 @@
};
in
import src {pkgs = __nixpkgs__;};
getPoetryPackages = let
tomlPath = "${pythonProjectDir}/poetry.lock";
tomlData = builtins.fromTOML (builtins.readFile tomlPath);
tomlPackages = tomlData.package;
packagesNames = builtins.map (pkg: pkg.name) tomlPackages;
extraPackagesLst = builtins.concatLists (builtins.map (
pkg:
if builtins.hasAttr "extras" pkg
then
builtins.concatLists (
builtins.attrValues pkg.extras
)
else []
)
tomlPackages);
extraPackagesNames =
builtins.map (
extra:
builtins.toString (builtins.head (builtins.split " " (__nixpkgs__.lib.toLower extra)))
)
extraPackagesLst;
in
packagesNames ++ extraPackagesNames;

is39 = pythonVersion == "3.9";
is310 = pythonVersion == "3.10";
Expand All @@ -32,8 +55,35 @@
}
.${pythonVersion};

overrideWithHome = pkg: super:
super.${pkg}.overridePythonAttrs (
old: {
preUnpack =
''
export HOME=$(mktemp -d)
rm -rf /homeless-shelter
''
+ (old.preUnpack or "");
}
);
tomlOverrides = self: super:
builtins.listToAttrs (
builtins.map (
pkg: {
name = pkg;
value = overrideWithHome pkg super;
}
)
getPoetryPackages
);
combinedOverrides = self: super: let
toml = tomlOverrides self super;
orig = overrides self super;
in
toml // orig;

env = poetry2nix.mkPoetryEnv {
overrides = poetry2nix.defaultPoetryOverrides.extend overrides;
overrides = poetry2nix.defaultPoetryOverrides.extend combinedOverrides;
inherit preferWheels;
projectDir = pythonProjectDir;
inherit python;
Expand Down

0 comments on commit b2cca5f

Please sign in to comment.