From e6362fb2277ed8fa8c44d7efc93c9b44453c4cd6 Mon Sep 17 00:00:00 2001 From: ento Date: Wed, 29 Nov 2023 18:34:36 -0800 Subject: [PATCH 1/2] :art: whitespace --- flake.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 76a6490..d5be866 100644 --- a/flake.nix +++ b/flake.nix @@ -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; @@ -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; } @@ -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; @@ -139,7 +139,7 @@ # 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; }); From cc028a645f7afa88b09bfd14b812cb514b140cb7 Mon Sep 17 00:00:00 2001 From: ento Date: Wed, 29 Nov 2023 18:39:29 -0800 Subject: [PATCH 2/2] Use newScope to pass down our python derivation through all references This may not cover *all* references, and overwriting pkgsBuildHost like this feels wrong --- flake.nix | 54 ++++++++++++++++++++++++++++++------------------------ self.nix | 3 --- 2 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 self.nix diff --git a/flake.nix b/flake.nix index d5be866..fb92537 100644 --- a/flake.nix +++ b/flake.nix @@ -31,7 +31,7 @@ , version , hash , url - , callPackage + , packages }: let versionList = builtins.splitVersion version; @@ -145,38 +145,44 @@ }); } ]; - 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; + callPackage = pkgs.newScope { + inherit python; + pkgsBuildHost = pkgs.pkgsBuildHost // { + "python${sourceVersion.major}${sourceVersion.minor}" = python; + }; }; - meta = old.meta // { - knownVulnerabilities = []; - }; - }); + 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 ); diff --git a/self.nix b/self.nix deleted file mode 100644 index d41b372..0000000 --- a/self.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ nixpkgs-python, version }: - -nixpkgs-python.${version}