From a14faa869d12d6280ac5ebf94c585ef200bb4c9c Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 02:38:07 +0200 Subject: [PATCH 01/11] flake.nix: Use a Nixpkgs scope for components --- flake.nix | 97 +++++----------------------------------- packaging/components.nix | 86 +++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 87 deletions(-) create mode 100644 packaging/components.nix diff --git a/flake.nix b/flake.nix index dfae6ce2dde..30a8e435486 100644 --- a/flake.nix +++ b/flake.nix @@ -172,93 +172,16 @@ }; }); - # TODO: define everything here instead of top level? - nix-components = { - inherit (final) - nix-util - nix-util-test-support - nix-util-test - nix-util-c - nix-store - nix-fetchers - nix-perl-bindings - ; - }; - - nix-util = final.callPackage ./src/libutil/package.nix { - inherit - fileset - stdenv - officialRelease - versionSuffix - ; - }; - - nix-util-test-support = final.callPackage ./tests/unit/libutil-support/package.nix { - inherit - fileset - stdenv - versionSuffix - ; - }; - - nix-util-test = final.callPackage ./tests/unit/libutil/package.nix { - inherit - fileset - stdenv - versionSuffix - ; - }; - - nix-util-c = final.callPackage ./src/libutil-c/package.nix { - inherit - fileset - stdenv - versionSuffix - ; - }; - - nix-store = final.callPackage ./src/libstore/package.nix { - inherit - fileset - stdenv - officialRelease - versionSuffix - ; - libseccomp = final.libseccomp-nix; - busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell; - }; - - nix-fetchers = final.callPackage ./src/libfetchers/package.nix { - inherit - fileset - stdenv - officialRelease - versionSuffix - ; - }; - - nix = - final.callPackage ./package.nix { - inherit - fileset - stdenv - officialRelease - versionSuffix - ; - boehmgc = final.boehmgc-nix; - libgit2 = final.libgit2-nix; - libseccomp = final.libseccomp-nix; - busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell; - }; + # A new scope, so that we can use `callPackage` to inject our own interdependencies + # without "polluting" the top level "`pkgs`" attrset. + # This also has the benefit of providing us with a distinct set of packages + # we can iterate over. + nixComponents = lib.makeScope final.newScope (import ./packaging/components.nix { + pkgs = final; + inherit stdenv versionSuffix officialRelease; + }); - nix-perl-bindings = final.callPackage ./src/perl/package.nix { - inherit - fileset - stdenv - versionSuffix - ; - }; + nix = final.nixComponents.nix; nix-internal-api-docs = final.callPackage ./src/internal-api-docs/package.nix { inherit @@ -340,7 +263,7 @@ "static-" = nixpkgsFor.${system}.static; }) (nixpkgsPrefix: nixpkgs: - flatMapAttrs nixpkgs.nix-components + flatMapAttrs nixpkgs.nixComponents (pkgName: pkg: flatMapAttrs pkg.tests or {} (testName: test: { diff --git a/packaging/components.nix b/packaging/components.nix new file mode 100644 index 00000000000..af26e05ce18 --- /dev/null +++ b/packaging/components.nix @@ -0,0 +1,86 @@ +{pkgs, stdenv, officialRelease, versionSuffix}: scope: +let + inherit (scope) callPackage; + + # TODO: push fileset parameter into package.nix files as `lib` parameter + inherit (callPackage (args@{ lib }: args) {}) lib; + inherit (lib) fileset; +in + +# This becomes the pkgs.nixComponents attribute set +{ + # TODO: build the nix CLI with meson + nix = pkgs.callPackage ../package.nix { + inherit + fileset + stdenv + officialRelease + versionSuffix + ; + boehmgc = pkgs.boehmgc-nix; + libgit2 = pkgs.libgit2-nix; + libseccomp = pkgs.libseccomp-nix; + busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell; + }; + + nix-util = callPackage ../src/libutil/package.nix { + inherit + fileset + stdenv + officialRelease + versionSuffix + ; + }; + + nix-util-test-support = callPackage ../tests/unit/libutil-support/package.nix { + inherit + fileset + stdenv + versionSuffix + ; + }; + + nix-util-test = callPackage ../tests/unit/libutil/package.nix { + inherit + fileset + stdenv + versionSuffix + ; + }; + + nix-util-c = callPackage ../src/libutil-c/package.nix { + inherit + fileset + stdenv + versionSuffix + ; + }; + + nix-store = callPackage ../src/libstore/package.nix { + inherit + fileset + stdenv + officialRelease + versionSuffix + ; + libseccomp = pkgs.libseccomp-nix; + busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell; + }; + + nix-fetchers = callPackage ../src/libfetchers/package.nix { + inherit + fileset + stdenv + officialRelease + versionSuffix + ; + }; + + nix-perl-bindings = callPackage ../src/perl/package.nix { + inherit + fileset + stdenv + versionSuffix + ; + }; +} From d40c59ed194b715bffdcd40f4b654ebc60cf5be3 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 02:44:21 +0200 Subject: [PATCH 02/11] flake.nix: Use the nixComponents scope instead of bare pkgs packages ... which aren't around anymore. --- flake.nix | 24 ++++++++++++------------ maintainers/hydra.nix | 11 +++++++---- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index 30a8e435486..a66603cc8f9 100644 --- a/flake.nix +++ b/flake.nix @@ -296,16 +296,16 @@ } (pkgName: {}: { # These attributes go right into `packages.`. - "${pkgName}" = nixpkgsFor.${system}.native.${pkgName}; - "${pkgName}-static" = nixpkgsFor.${system}.static.${pkgName}; + "${pkgName}" = nixpkgsFor.${system}.native.nixComponents.${pkgName}; + "${pkgName}-static" = nixpkgsFor.${system}.static.nixComponents.${pkgName}; } // flatMapAttrs (lib.genAttrs crossSystems (_: { })) (crossSystem: {}: { # These attributes go right into `packages.`. - "${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.${pkgName}; + "${pkgName}-${crossSystem}" = nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName}; }) // flatMapAttrs (lib.genAttrs stdenvs (_: { })) (stdenvName: {}: { # These attributes go right into `packages.`. - "${pkgName}-${stdenvName}" = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".${pkgName}; + "${pkgName}-${stdenvName}" = nixpkgsFor.${system}.stdenvs."${stdenvName}Packages".nixComponents.${pkgName}; }) ) // lib.optionalAttrs (builtins.elem system linux64BitSystems) { @@ -367,17 +367,17 @@ }; mesonFlags = - map (transformFlag "libutil") pkgs.nix-util.mesonFlags - ++ map (transformFlag "libstore") pkgs.nix-store.mesonFlags - ++ map (transformFlag "libfetchers") pkgs.nix-fetchers.mesonFlags - ++ lib.optionals havePerl (map (transformFlag "perl") pkgs.nix-perl-bindings.mesonFlags) + map (transformFlag "libutil") pkgs.nixComponents.nix-util.mesonFlags + ++ map (transformFlag "libstore") pkgs.nixComponents.nix-store.mesonFlags + ++ map (transformFlag "libfetchers") pkgs.nixComponents.nix-fetchers.mesonFlags + ++ lib.optionals havePerl (map (transformFlag "perl") pkgs.nixComponents.nix-perl-bindings.mesonFlags) ; nativeBuildInputs = attrs.nativeBuildInputs or [] - ++ pkgs.nix-util.nativeBuildInputs - ++ pkgs.nix-store.nativeBuildInputs - ++ pkgs.nix-fetchers.nativeBuildInputs - ++ lib.optionals havePerl pkgs.nix-perl-bindings.nativeBuildInputs + ++ pkgs.nixComponents.nix-util.nativeBuildInputs + ++ pkgs.nixComponents.nix-store.nativeBuildInputs + ++ pkgs.nixComponents.nix-fetchers.nativeBuildInputs + ++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.nativeBuildInputs ++ pkgs.nix-internal-api-docs.nativeBuildInputs ++ pkgs.nix-external-api-docs.nativeBuildInputs ++ [ diff --git a/maintainers/hydra.nix b/maintainers/hydra.nix index 9e6f2c4686b..b03cbdfa0e5 100644 --- a/maintainers/hydra.nix +++ b/maintainers/hydra.nix @@ -33,6 +33,9 @@ let doBuild = false; }; + # Technically we could just return `pkgs.nixComponents`, but for Hydra it's + # convention to transpose it, and to transpose it efficiently, we need to + # enumerate them manually, so that we don't evaluate unnecessary package sets. forAllPackages = lib.genAttrs [ "nix" "nix-util" @@ -46,16 +49,16 @@ in { # Binary package for various platforms. build = forAllPackages (pkgName: - forAllSystems (system: nixpkgsFor.${system}.native.${pkgName})); + forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.${pkgName})); shellInputs = forAllSystems (system: self.devShells.${system}.default.inputDerivation); buildStatic = forAllPackages (pkgName: - lib.genAttrs linux64BitSystems (system: nixpkgsFor.${system}.static.${pkgName})); + lib.genAttrs linux64BitSystems (system: nixpkgsFor.${system}.static.nixComponents.${pkgName})); buildCross = forAllPackages (pkgName: forAllCrossSystems (crossSystem: - lib.genAttrs [ "x86_64-linux" ] (system: nixpkgsFor.${system}.cross.${crossSystem}.${pkgName}))); + lib.genAttrs [ "x86_64-linux" ] (system: nixpkgsFor.${system}.cross.${crossSystem}.nixComponents.${pkgName}))); buildNoGc = forAllSystems (system: self.packages.${system}.nix.override { enableGC = false; } @@ -73,7 +76,7 @@ in ); # Perl bindings for various platforms. - perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nix-perl-bindings); + perlBindings = forAllSystems (system: nixpkgsFor.${system}.native.nixComponents.nix-perl-bindings); # Binary tarball for various platforms, containing a Nix store # with the closure of 'nix' package, and the second half of From 85de5a60c77c256d5e57943becb683f50f9d7537 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 03:18:01 +0200 Subject: [PATCH 03/11] Use lib instead of explicit fileset passing --- flake.nix | 2 -- maintainers/hydra.nix | 3 --- package.nix | 6 ++---- packaging/components.nix | 16 ---------------- src/external-api-docs/package.nix | 6 ++++-- src/internal-api-docs/package.nix | 6 ++++-- src/libfetchers/package.nix | 6 ++---- src/libstore/package.nix | 5 ++--- src/libutil-c/package.nix | 3 ++- src/libutil/package.nix | 4 ++-- src/perl/package.nix | 5 ++++- tests/unit/libutil-support/package.nix | 3 ++- tests/unit/libutil/package.nix | 3 ++- 13 files changed, 26 insertions(+), 42 deletions(-) diff --git a/flake.nix b/flake.nix index a66603cc8f9..7fc491035cb 100644 --- a/flake.nix +++ b/flake.nix @@ -185,7 +185,6 @@ nix-internal-api-docs = final.callPackage ./src/internal-api-docs/package.nix { inherit - fileset stdenv versionSuffix ; @@ -193,7 +192,6 @@ nix-external-api-docs = final.callPackage ./src/external-api-docs/package.nix { inherit - fileset stdenv versionSuffix ; diff --git a/maintainers/hydra.nix b/maintainers/hydra.nix index b03cbdfa0e5..98d8b39619d 100644 --- a/maintainers/hydra.nix +++ b/maintainers/hydra.nix @@ -9,7 +9,6 @@ }: let inherit (inputs) nixpkgs nixpkgs-regression; - inherit (lib) fileset; installScriptFor = tarballs: nixpkgsFor.x86_64-linux.native.callPackage ../scripts/installer.nix { @@ -25,8 +24,6 @@ let lib.versionAtLeast client.version "2.4pre20211005") "-${client.version}-against-${daemon.version}"; - inherit fileset; - test-client = client; test-daemon = daemon; diff --git a/package.nix b/package.nix index f414b9a7351..9a6fc272a49 100644 --- a/package.nix +++ b/package.nix @@ -1,12 +1,10 @@ { lib -, fetchurl , stdenv , releaseTools , autoconf-archive , autoreconfHook , aws-sdk-cpp , boehmgc -, buildPackages , nlohmann_json , bison , boost @@ -15,7 +13,6 @@ , curl , editline , readline -, fileset , flex , git , gtest @@ -50,7 +47,6 @@ , pname ? "nix" , versionSuffix ? "" -, officialRelease ? false # Whether to build Nix. Useful to skip for tasks like testing existing pre-built versions of Nix , doBuild ? true @@ -113,6 +109,8 @@ }: let + inherit (lib) fileset; + version = lib.fileContents ./.version + versionSuffix; # selected attributes with defaults, will be used to define some diff --git a/packaging/components.nix b/packaging/components.nix index af26e05ce18..d3809ff38f5 100644 --- a/packaging/components.nix +++ b/packaging/components.nix @@ -1,10 +1,6 @@ {pkgs, stdenv, officialRelease, versionSuffix}: scope: let inherit (scope) callPackage; - - # TODO: push fileset parameter into package.nix files as `lib` parameter - inherit (callPackage (args@{ lib }: args) {}) lib; - inherit (lib) fileset; in # This becomes the pkgs.nixComponents attribute set @@ -12,9 +8,7 @@ in # TODO: build the nix CLI with meson nix = pkgs.callPackage ../package.nix { inherit - fileset stdenv - officialRelease versionSuffix ; boehmgc = pkgs.boehmgc-nix; @@ -25,16 +19,13 @@ in nix-util = callPackage ../src/libutil/package.nix { inherit - fileset stdenv - officialRelease versionSuffix ; }; nix-util-test-support = callPackage ../tests/unit/libutil-support/package.nix { inherit - fileset stdenv versionSuffix ; @@ -42,7 +33,6 @@ in nix-util-test = callPackage ../tests/unit/libutil/package.nix { inherit - fileset stdenv versionSuffix ; @@ -50,7 +40,6 @@ in nix-util-c = callPackage ../src/libutil-c/package.nix { inherit - fileset stdenv versionSuffix ; @@ -58,9 +47,7 @@ in nix-store = callPackage ../src/libstore/package.nix { inherit - fileset stdenv - officialRelease versionSuffix ; libseccomp = pkgs.libseccomp-nix; @@ -69,16 +56,13 @@ in nix-fetchers = callPackage ../src/libfetchers/package.nix { inherit - fileset stdenv - officialRelease versionSuffix ; }; nix-perl-bindings = callPackage ../src/perl/package.nix { inherit - fileset stdenv versionSuffix ; diff --git a/src/external-api-docs/package.nix b/src/external-api-docs/package.nix index aa5cd49ebaf..352698360c5 100644 --- a/src/external-api-docs/package.nix +++ b/src/external-api-docs/package.nix @@ -1,7 +1,5 @@ { lib , stdenv -, releaseTools -, fileset , meson , ninja @@ -12,6 +10,10 @@ , versionSuffix ? "" }: +let + inherit (lib) fileset; +in + stdenv.mkDerivation (finalAttrs: { pname = "nix-external-api-docs"; version = lib.fileContents ./.version + versionSuffix; diff --git a/src/internal-api-docs/package.nix b/src/internal-api-docs/package.nix index b5f1b0da1cf..fa54d55f3a7 100644 --- a/src/internal-api-docs/package.nix +++ b/src/internal-api-docs/package.nix @@ -1,7 +1,5 @@ { lib , stdenv -, releaseTools -, fileset , meson , ninja @@ -12,6 +10,10 @@ , versionSuffix ? "" }: +let + inherit (lib) fileset; +in + stdenv.mkDerivation (finalAttrs: { pname = "nix-internal-api-docs"; version = lib.fileContents ./.version + versionSuffix; diff --git a/src/libfetchers/package.nix b/src/libfetchers/package.nix index 80025603082..a5583d14cd2 100644 --- a/src/libfetchers/package.nix +++ b/src/libfetchers/package.nix @@ -1,7 +1,6 @@ { lib , stdenv , releaseTools -, fileset , meson , ninja @@ -16,17 +15,16 @@ # Configuration Options , versionSuffix ? "" -, officialRelease ? false # Check test coverage of Nix. Probably want to use with with at least # one of `doCheck` or `doInstallCheck` enabled. , withCoverageChecks ? false -# Avoid setting things that would interfere with a functioning devShell -, forDevShell ? false }: let + inherit (lib) fileset; + version = lib.fileContents ./.version + versionSuffix; mkDerivation = diff --git a/src/libstore/package.nix b/src/libstore/package.nix index e54dfe597e0..e118f3cd21f 100644 --- a/src/libstore/package.nix +++ b/src/libstore/package.nix @@ -1,7 +1,6 @@ { lib , stdenv , releaseTools -, fileset , meson , ninja @@ -13,7 +12,6 @@ , aws-sdk-cpp , libseccomp , nlohmann_json -, man , sqlite , busybox-sandbox-shell ? null @@ -21,7 +19,6 @@ # Configuration Options , versionSuffix ? "" -, officialRelease ? false # Check test coverage of Nix. Probably want to use with at least # one of `doCheck` or `doInstallCheck` enabled. @@ -32,6 +29,8 @@ }: let + inherit (lib) fileset; + version = lib.fileContents ./.version + versionSuffix; mkDerivation = diff --git a/src/libutil-c/package.nix b/src/libutil-c/package.nix index a45b36d4c9d..05a26c17e6c 100644 --- a/src/libutil-c/package.nix +++ b/src/libutil-c/package.nix @@ -1,7 +1,6 @@ { lib , stdenv , releaseTools -, fileset , meson , ninja @@ -19,6 +18,8 @@ }: let + inherit (lib) fileset; + version = lib.fileContents ./.version + versionSuffix; mkDerivation = diff --git a/src/libutil/package.nix b/src/libutil/package.nix index b36e3879c21..892951cdf4e 100644 --- a/src/libutil/package.nix +++ b/src/libutil/package.nix @@ -1,7 +1,6 @@ { lib , stdenv , releaseTools -, fileset , meson , ninja @@ -18,7 +17,6 @@ # Configuration Options , versionSuffix ? "" -, officialRelease ? false # Check test coverage of Nix. Probably want to use with at least # one of `doCheck` or `doInstallCheck` enabled. @@ -26,6 +24,8 @@ }: let + inherit (lib) fileset; + version = lib.fileContents ./.version + versionSuffix; mkDerivation = diff --git a/src/perl/package.nix b/src/perl/package.nix index a31b1b66cf5..85f1547b7cf 100644 --- a/src/perl/package.nix +++ b/src/perl/package.nix @@ -1,5 +1,4 @@ { lib -, fileset , stdenv , perl , perlPackages @@ -16,6 +15,10 @@ , versionSuffix ? "" }: +let + inherit (lib) fileset; +in + perl.pkgs.toPerlModule (stdenv.mkDerivation (finalAttrs: { pname = "nix-perl"; version = lib.fileContents ./.version + versionSuffix; diff --git a/tests/unit/libutil-support/package.nix b/tests/unit/libutil-support/package.nix index caa37b74871..0be0a9945be 100644 --- a/tests/unit/libutil-support/package.nix +++ b/tests/unit/libutil-support/package.nix @@ -1,7 +1,6 @@ { lib , stdenv , releaseTools -, fileset , meson , ninja @@ -21,6 +20,8 @@ }: let + inherit (lib) fileset; + version = lib.fileContents ./.version + versionSuffix; mkDerivation = diff --git a/tests/unit/libutil/package.nix b/tests/unit/libutil/package.nix index 7a09e4aa5a7..391f8d85326 100644 --- a/tests/unit/libutil/package.nix +++ b/tests/unit/libutil/package.nix @@ -1,7 +1,6 @@ { lib , stdenv , releaseTools -, fileset , meson , ninja @@ -25,6 +24,8 @@ }: let + inherit (lib) fileset; + version = lib.fileContents ./.version + versionSuffix; mkDerivation = From 74b9b77c9f05099c2bb207890d0728455a85efa7 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 03:33:30 +0200 Subject: [PATCH 04/11] components.nix: Simplify with scope --- flake.nix | 2 +- packaging/components.nix | 71 +++++++++------------------------------- 2 files changed, 16 insertions(+), 57 deletions(-) diff --git a/flake.nix b/flake.nix index 7fc491035cb..ed330b669a8 100644 --- a/flake.nix +++ b/flake.nix @@ -178,7 +178,7 @@ # we can iterate over. nixComponents = lib.makeScope final.newScope (import ./packaging/components.nix { pkgs = final; - inherit stdenv versionSuffix officialRelease; + inherit stdenv versionSuffix; }); nix = final.nixComponents.nix; diff --git a/packaging/components.nix b/packaging/components.nix index d3809ff38f5..7cef0e356c7 100644 --- a/packaging/components.nix +++ b/packaging/components.nix @@ -1,70 +1,29 @@ -{pkgs, stdenv, officialRelease, versionSuffix}: scope: +{pkgs, stdenv, versionSuffix}: scope: let inherit (scope) callPackage; in # This becomes the pkgs.nixComponents attribute set { - # TODO: build the nix CLI with meson - nix = pkgs.callPackage ../package.nix { - inherit - stdenv - versionSuffix - ; - boehmgc = pkgs.boehmgc-nix; - libgit2 = pkgs.libgit2-nix; - libseccomp = pkgs.libseccomp-nix; - busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell; - }; + inherit stdenv versionSuffix; + libseccomp = pkgs.libseccomp-nix; + boehmgc = pkgs.boehmgc-nix; + libgit2 = pkgs.libgit2-nix; + busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell; - nix-util = callPackage ../src/libutil/package.nix { - inherit - stdenv - versionSuffix - ; - }; + nix = callPackage ../package.nix { }; - nix-util-test-support = callPackage ../tests/unit/libutil-support/package.nix { - inherit - stdenv - versionSuffix - ; - }; + nix-util = callPackage ../src/libutil/package.nix { }; - nix-util-test = callPackage ../tests/unit/libutil/package.nix { - inherit - stdenv - versionSuffix - ; - }; + nix-util-test-support = callPackage ../tests/unit/libutil-support/package.nix { }; - nix-util-c = callPackage ../src/libutil-c/package.nix { - inherit - stdenv - versionSuffix - ; - }; + nix-util-test = callPackage ../tests/unit/libutil/package.nix { }; - nix-store = callPackage ../src/libstore/package.nix { - inherit - stdenv - versionSuffix - ; - libseccomp = pkgs.libseccomp-nix; - busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell; - }; + nix-util-c = callPackage ../src/libutil-c/package.nix { }; - nix-fetchers = callPackage ../src/libfetchers/package.nix { - inherit - stdenv - versionSuffix - ; - }; + nix-store = callPackage ../src/libstore/package.nix { }; - nix-perl-bindings = callPackage ../src/perl/package.nix { - inherit - stdenv - versionSuffix - ; - }; + nix-fetchers = callPackage ../src/libfetchers/package.nix { }; + + nix-perl-bindings = callPackage ../src/perl/package.nix { }; } From ebf77c79ae1cd1516117311c6315bd8c56b8b837 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 03:36:03 +0200 Subject: [PATCH 05/11] flake.nix: Use Nixpkgs convention for package variants --- flake.nix | 6 +++--- packaging/components.nix | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index ed330b669a8..d49bccda877 100644 --- a/flake.nix +++ b/flake.nix @@ -153,18 +153,18 @@ ''; }; - libgit2-nix = final.libgit2.overrideAttrs (attrs: { + libgit2_nix = final.libgit2.overrideAttrs (attrs: { src = libgit2; version = libgit2.lastModifiedDate; cmakeFlags = attrs.cmakeFlags or [] ++ [ "-DUSE_SSH=exec" ]; }); - boehmgc-nix = final.boehmgc.override { + boehmgc_nix = final.boehmgc.override { enableLargeConfig = true; }; - libseccomp-nix = final.libseccomp.overrideAttrs (_: rec { + libseccomp_nix = final.libseccomp.overrideAttrs (_: rec { version = "2.5.5"; src = final.fetchurl { url = "https://github.com/seccomp/libseccomp/releases/download/v${version}/libseccomp-${version}.tar.gz"; diff --git a/packaging/components.nix b/packaging/components.nix index 7cef0e356c7..2d06cfec4ab 100644 --- a/packaging/components.nix +++ b/packaging/components.nix @@ -6,9 +6,9 @@ in # This becomes the pkgs.nixComponents attribute set { inherit stdenv versionSuffix; - libseccomp = pkgs.libseccomp-nix; - boehmgc = pkgs.boehmgc-nix; - libgit2 = pkgs.libgit2-nix; + libseccomp = pkgs.libseccomp_nix; + boehmgc = pkgs.boehmgc_nix; + libgit2 = pkgs.libgit2_nix; busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell; nix = callPackage ../package.nix { }; From 25dc12aab139b4bd3438c764a1d479ae8517a81a Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 03:58:47 +0200 Subject: [PATCH 06/11] components.nix: Extract dependency scope This avoids polluting nixComponents with things that aren't our components. Fixes the extraction of passthru tests, which failed for boehmgc which had many irrelevant ones anyway. --- flake.nix | 12 +++++++++++- packaging/components.nix | 6 ------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index d49bccda877..870b8295022 100644 --- a/flake.nix +++ b/flake.nix @@ -176,11 +176,21 @@ # without "polluting" the top level "`pkgs`" attrset. # This also has the benefit of providing us with a distinct set of packages # we can iterate over. - nixComponents = lib.makeScope final.newScope (import ./packaging/components.nix { + nixComponents = lib.makeScope final.nixDependencies.newScope (import ./packaging/components.nix { pkgs = final; inherit stdenv versionSuffix; }); + # The dependencies are in their own scope, so that they don't have to be + # in Nixpkgs top level `pkgs` or `nixComponents`. + nixDependencies = lib.makeScope final.newScope (scope: { + inherit stdenv versionSuffix; + libseccomp = final.libseccomp_nix; + boehmgc = final.boehmgc_nix; + libgit2 = final.libgit2_nix; + busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell; + }); + nix = final.nixComponents.nix; nix-internal-api-docs = final.callPackage ./src/internal-api-docs/package.nix { diff --git a/packaging/components.nix b/packaging/components.nix index 2d06cfec4ab..e1e73d4c0d9 100644 --- a/packaging/components.nix +++ b/packaging/components.nix @@ -5,12 +5,6 @@ in # This becomes the pkgs.nixComponents attribute set { - inherit stdenv versionSuffix; - libseccomp = pkgs.libseccomp_nix; - boehmgc = pkgs.boehmgc_nix; - libgit2 = pkgs.libgit2_nix; - busybox-sandbox-shell = pkgs.busybox-sandbox-shell or pkgs.default-busybox-sandbox-shell; - nix = callPackage ../package.nix { }; nix-util = callPackage ../src/libutil/package.nix { }; From c24dbf14571cd59ef4e7b2a3470c61760a6a6aa4 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 04:17:30 +0200 Subject: [PATCH 07/11] components.nix: Simplify --- flake.nix | 5 +---- packaging/components.nix | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 870b8295022..90a48a38212 100644 --- a/flake.nix +++ b/flake.nix @@ -176,10 +176,7 @@ # without "polluting" the top level "`pkgs`" attrset. # This also has the benefit of providing us with a distinct set of packages # we can iterate over. - nixComponents = lib.makeScope final.nixDependencies.newScope (import ./packaging/components.nix { - pkgs = final; - inherit stdenv versionSuffix; - }); + nixComponents = lib.makeScope final.nixDependencies.newScope (import ./packaging/components.nix); # The dependencies are in their own scope, so that they don't have to be # in Nixpkgs top level `pkgs` or `nixComponents`. diff --git a/packaging/components.nix b/packaging/components.nix index e1e73d4c0d9..f96ac6b5187 100644 --- a/packaging/components.nix +++ b/packaging/components.nix @@ -1,4 +1,4 @@ -{pkgs, stdenv, versionSuffix}: scope: +scope: let inherit (scope) callPackage; in From 65802da98db906e61a810e686e140536d3ab4e54 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 04:24:50 +0200 Subject: [PATCH 08/11] Move maintainers/hydra.nix -> packaging/hydra.nix --- flake.nix | 2 +- {maintainers => packaging}/hydra.nix | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename {maintainers => packaging}/hydra.nix (100%) diff --git a/flake.nix b/flake.nix index 90a48a38212..510df73f169 100644 --- a/flake.nix +++ b/flake.nix @@ -224,7 +224,7 @@ # 'nix-perl-bindings' packages. overlays.default = overlayFor (p: p.stdenv); - hydraJobs = import ./maintainers/hydra.nix { + hydraJobs = import ./packaging/hydra.nix { inherit inputs binaryTarball diff --git a/maintainers/hydra.nix b/packaging/hydra.nix similarity index 100% rename from maintainers/hydra.nix rename to packaging/hydra.nix From 409eded5415f00c2cc7ef6e124a51c1bb0290df1 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 10:41:56 +0200 Subject: [PATCH 09/11] flake.nix: Move dependencies scope to packaging/dependencies.nix --- flake.nix | 52 ++-------------------------------- packaging/dependencies.nix | 58 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 49 deletions(-) create mode 100644 packaging/dependencies.nix diff --git a/flake.nix b/flake.nix index 510df73f169..8b4deb78a58 100644 --- a/flake.nix +++ b/flake.nix @@ -129,49 +129,6 @@ { nixStable = prev.nix; - default-busybox-sandbox-shell = final.busybox.override { - useMusl = true; - enableStatic = true; - enableMinimal = true; - extraConfig = '' - CONFIG_FEATURE_FANCY_ECHO y - CONFIG_FEATURE_SH_MATH y - CONFIG_FEATURE_SH_MATH_64 y - - CONFIG_ASH y - CONFIG_ASH_OPTIMIZE_FOR_SIZE y - - CONFIG_ASH_ALIAS y - CONFIG_ASH_BASH_COMPAT y - CONFIG_ASH_CMDCMD y - CONFIG_ASH_ECHO y - CONFIG_ASH_GETOPTS y - CONFIG_ASH_INTERNAL_GLOB y - CONFIG_ASH_JOB_CONTROL y - CONFIG_ASH_PRINTF y - CONFIG_ASH_TEST y - ''; - }; - - libgit2_nix = final.libgit2.overrideAttrs (attrs: { - src = libgit2; - version = libgit2.lastModifiedDate; - cmakeFlags = attrs.cmakeFlags or [] - ++ [ "-DUSE_SSH=exec" ]; - }); - - boehmgc_nix = final.boehmgc.override { - enableLargeConfig = true; - }; - - libseccomp_nix = final.libseccomp.overrideAttrs (_: rec { - version = "2.5.5"; - src = final.fetchurl { - url = "https://github.com/seccomp/libseccomp/releases/download/v${version}/libseccomp-${version}.tar.gz"; - hash = "sha256-JIosik2bmFiqa69ScSw0r+/PnJ6Ut23OAsHJqiX7M3U="; - }; - }); - # A new scope, so that we can use `callPackage` to inject our own interdependencies # without "polluting" the top level "`pkgs`" attrset. # This also has the benefit of providing us with a distinct set of packages @@ -180,12 +137,9 @@ # The dependencies are in their own scope, so that they don't have to be # in Nixpkgs top level `pkgs` or `nixComponents`. - nixDependencies = lib.makeScope final.newScope (scope: { - inherit stdenv versionSuffix; - libseccomp = final.libseccomp_nix; - boehmgc = final.boehmgc_nix; - libgit2 = final.libgit2_nix; - busybox-sandbox-shell = final.busybox-sandbox-shell or final.default-busybox-sandbox-shell; + nixDependencies = lib.makeScope final.newScope (import ./packaging/dependencies.nix { + inherit inputs stdenv versionSuffix; + pkgs = final; }); nix = final.nixComponents.nix; diff --git a/packaging/dependencies.nix b/packaging/dependencies.nix new file mode 100644 index 00000000000..88273df2210 --- /dev/null +++ b/packaging/dependencies.nix @@ -0,0 +1,58 @@ +# These overrides are applied to the dependencies of the Nix components. + +{ + # Flake inputs; used for sources + inputs, + + # The raw Nixpkgs, not affected by this scope + pkgs, + + stdenv, + versionSuffix, +}: +scope: { + inherit stdenv versionSuffix; + + libseccomp = pkgs.libseccomp.overrideAttrs (_: rec { + version = "2.5.5"; + src = pkgs.fetchurl { + url = "https://github.com/seccomp/libseccomp/releases/download/v${version}/libseccomp-${version}.tar.gz"; + hash = "sha256-JIosik2bmFiqa69ScSw0r+/PnJ6Ut23OAsHJqiX7M3U="; + }; + }); + + boehmgc = pkgs.boehmgc.override { + enableLargeConfig = true; + }; + + libgit2 = pkgs.libgit2.overrideAttrs (attrs: { + src = inputs.libgit2; + version = inputs.libgit2.lastModifiedDate; + cmakeFlags = attrs.cmakeFlags or [] + ++ [ "-DUSE_SSH=exec" ]; + }); + + busybox-sandbox-shell = pkgs.busybox-sandbox-shell or (pkgs.busybox.override { + useMusl = true; + enableStatic = true; + enableMinimal = true; + extraConfig = '' + CONFIG_FEATURE_FANCY_ECHO y + CONFIG_FEATURE_SH_MATH y + CONFIG_FEATURE_SH_MATH_64 y + + CONFIG_ASH y + CONFIG_ASH_OPTIMIZE_FOR_SIZE y + + CONFIG_ASH_ALIAS y + CONFIG_ASH_BASH_COMPAT y + CONFIG_ASH_CMDCMD y + CONFIG_ASH_ECHO y + CONFIG_ASH_GETOPTS y + CONFIG_ASH_INTERNAL_GLOB y + CONFIG_ASH_JOB_CONTROL y + CONFIG_ASH_PRINTF y + CONFIG_ASH_TEST y + ''; + }); +} From 985c211061be71317eb2a9fc7a4d35278f5d8e41 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 10:47:13 +0200 Subject: [PATCH 10/11] flake.nix: Move {in,ex}ternal-api-docs into nixComponents scope --- flake.nix | 22 ++++------------------ packaging/components.nix | 5 +++++ packaging/hydra.nix | 4 ++-- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index 8b4deb78a58..582a946c42e 100644 --- a/flake.nix +++ b/flake.nix @@ -144,20 +144,6 @@ nix = final.nixComponents.nix; - nix-internal-api-docs = final.callPackage ./src/internal-api-docs/package.nix { - inherit - stdenv - versionSuffix - ; - }; - - nix-external-api-docs = final.callPackage ./src/external-api-docs/package.nix { - inherit - stdenv - versionSuffix - ; - }; - nix_noTests = final.nix.override { doCheck = false; doInstallCheck = false; @@ -239,8 +225,8 @@ inherit (nixpkgsFor.${system}.native) changelog-d; default = self.packages.${system}.nix; - nix-internal-api-docs = nixpkgsFor.${system}.native.nix-internal-api-docs; - nix-external-api-docs = nixpkgsFor.${system}.native.nix-external-api-docs; + nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-internal-api-docs; + nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs; } # We need to flatten recursive attribute sets of derivations to pass `flake check`. // flatMapAttrs @@ -337,8 +323,8 @@ ++ pkgs.nixComponents.nix-store.nativeBuildInputs ++ pkgs.nixComponents.nix-fetchers.nativeBuildInputs ++ lib.optionals havePerl pkgs.nixComponents.nix-perl-bindings.nativeBuildInputs - ++ pkgs.nix-internal-api-docs.nativeBuildInputs - ++ pkgs.nix-external-api-docs.nativeBuildInputs + ++ pkgs.nixComponents.nix-internal-api-docs.nativeBuildInputs + ++ pkgs.nixComponents.nix-external-api-docs.nativeBuildInputs ++ [ modular.pre-commit.settings.package (pkgs.writeScriptBin "pre-commit-hooks-install" diff --git a/packaging/components.nix b/packaging/components.nix index f96ac6b5187..b5e47969e05 100644 --- a/packaging/components.nix +++ b/packaging/components.nix @@ -20,4 +20,9 @@ in nix-fetchers = callPackage ../src/libfetchers/package.nix { }; nix-perl-bindings = callPackage ../src/perl/package.nix { }; + + nix-internal-api-docs = callPackage ../src/internal-api-docs/package.nix { }; + + nix-external-api-docs = callPackage ../src/external-api-docs/package.nix { }; + } diff --git a/packaging/hydra.nix b/packaging/hydra.nix index 98d8b39619d..5715abd8eaa 100644 --- a/packaging/hydra.nix +++ b/packaging/hydra.nix @@ -122,10 +122,10 @@ in }; # API docs for Nix's unstable internal C++ interfaces. - internal-api-docs = nixpkgsFor.x86_64-linux.native.nix-internal-api-docs; + internal-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents.nix-internal-api-docs; # API docs for Nix's C bindings. - external-api-docs = nixpkgsFor.x86_64-linux.native.nix-external-api-docs; + external-api-docs = nixpkgsFor.x86_64-linux.native.nixComponents.nix-external-api-docs; # System tests. tests = import ../tests/nixos { inherit lib nixpkgs nixpkgsFor self; } // { From e6442891611b2f2ceee7ab1c573eec918a5fe5d7 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 26 Jun 2024 10:54:17 +0200 Subject: [PATCH 11/11] Remove unused boehmgc patch --- dep-patches/boehmgc-traceable_allocator-public.diff | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 dep-patches/boehmgc-traceable_allocator-public.diff diff --git a/dep-patches/boehmgc-traceable_allocator-public.diff b/dep-patches/boehmgc-traceable_allocator-public.diff deleted file mode 100644 index 903c707a698..00000000000 --- a/dep-patches/boehmgc-traceable_allocator-public.diff +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/include/gc_allocator.h b/include/gc_allocator.h -index 597c7f13..587286be 100644 ---- a/include/gc_allocator.h -+++ b/include/gc_allocator.h -@@ -312,6 +312,7 @@ public: - - template<> - class traceable_allocator { -+public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer;