Skip to content

Commit

Permalink
Merge pull request #26 from ento/with-packages-fix
Browse files Browse the repository at this point in the history
Make it possible to use .withPackages and .pkgs
  • Loading branch information
domenkozar authored Jan 11, 2024
2 parents 8c1b05a + cc028a6 commit cd1f364
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
64 changes: 35 additions & 29 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
extra-trusted-public-keys = "nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU=";
};

outputs = { self, nixpkgs, flake-utils, ... }:
let
outputs = { self, nixpkgs, flake-utils, ... }:
let
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
lib = nixpkgs.lib;
Expand All @@ -31,7 +31,7 @@
, version
, hash
, url
, callPackage
, packages
}:
let
versionList = builtins.splitVersion version;
Expand Down Expand Up @@ -90,7 +90,7 @@
url = "https://bugs.python.org/file48016/python-3.x-distutils-C++.patch";
sha256 = "1h18lnpx539h5lfxyk379dxwr8m2raigcjixkf133l4xy3f4bzi2";
});
}
}
{ condition = version: versionInBetween version "3.7.4" "3.7.3";
override = replacePatch "python-3.x-distutils-C++.patch" ./patches/python-3.7.3-distutils-C++.patch;
}
Expand Down Expand Up @@ -130,7 +130,7 @@
# no existing patch available
noldconfigPatch = null;
# otherwise it segfaults
stdenv =
stdenv =
if pkgs.stdenv.isLinux
then pkgs.overrideCC pkgs.stdenv pkgs.gcc8
else pkgs.stdenv;
Expand All @@ -139,44 +139,50 @@
# fill in the missing pc file
{ condition = version: versionInBetween version "3.5.2" "3.0" && pkgs.stdenv.isLinux;
override = pkg: pkg.overrideAttrs (old: {
postInstall = ''
postInstall = ''
ln -s "$out/lib/pkgconfig/python-${pkg.passthru.sourceVersion.major}.${pkg.passthru.sourceVersion.minor}.pc" "$out/lib/pkgconfig/python3.pc"
''+ old.postInstall;
});
}
];
in (self.lib.applyOverrides overrides (pkgs.callPackage "${pkgs.path}/pkgs/development/interpreters/python/cpython/${infix}default.nix" ({
inherit sourceVersion;
inherit (pkgs.darwin) configd;
hash = null;
self = callPackage ./self.nix { inherit version; };
passthruFun = pkgs.callPackage "${pkgs.path}/pkgs/development/interpreters/python/passthrufun.nix" { };
} // lib.optionalAttrs (sourceVersion.major == "3") {
noldconfigPatch = ./patches + "/${sourceVersion.major}.${sourceVersion.minor}-no-ldconfig.patch";
}))).overrideAttrs (old: {
src = pkgs.fetchurl {
inherit url;
sha256 = hash;
};
meta = old.meta // {
knownVulnerabilities = [];
callPackage = pkgs.newScope {
inherit python;
pkgsBuildHost = pkgs.pkgsBuildHost // {
"python${sourceVersion.major}${sourceVersion.minor}" = python;
};
};
});
python = (self.lib.applyOverrides overrides (callPackage "${pkgs.path}/pkgs/development/interpreters/python/cpython/${infix}default.nix" ({
inherit sourceVersion;
inherit (pkgs.darwin) configd;
hash = null;
self = packages.${version};
passthruFun = callPackage "${pkgs.path}/pkgs/development/interpreters/python/passthrufun.nix" { };
} // lib.optionalAttrs (sourceVersion.major == "3") {
noldconfigPatch = ./patches + "/${sourceVersion.major}.${sourceVersion.minor}-no-ldconfig.patch";
}))).overrideAttrs (old: {
src = pkgs.fetchurl {
inherit url;
sha256 = hash;
};
meta = old.meta // {
knownVulnerabilities = [];
};
});
in python;

lib.versions = builtins.fromJSON (builtins.readFile ./versions.json);

checks = forAllSystems (system:
let
callPackage = lib.callPackageWith (pkgs // { nixpkgs-python = packages; });
pkgs = nixpkgs.legacyPackages.${system};
getRelease = callPackage: version: source: self.lib.mkPython {
inherit pkgs version callPackage;
getRelease = version: source: self.lib.mkPython {
inherit pkgs version packages;
inherit (source) hash url;
};
getLatest = callPackage: version: latest:
getRelease callPackage latest self.lib.versions.releases.${latest};
packages = pkgs.lib.mapAttrs (getRelease callPackage) self.lib.versions.releases
// pkgs.lib.mapAttrs (getLatest callPackage) self.lib.versions.latest;
getLatest = version: latest:
getRelease latest self.lib.versions.releases.${latest};
packages = pkgs.lib.mapAttrs getRelease self.lib.versions.releases
// pkgs.lib.mapAttrs getLatest self.lib.versions.latest;
in packages
);

Expand Down
3 changes: 0 additions & 3 deletions self.nix

This file was deleted.

0 comments on commit cd1f364

Please sign in to comment.