diff --git a/impure.nix b/impure.nix index e598bbaea..2d39bf1ae 100644 --- a/impure.nix +++ b/impure.nix @@ -8,8 +8,9 @@ localSystem ? builtins.currentSystem, }: let + mkNixpkgs = import ./pkgs/by-name/nixpkgs-bootstrap/mkNixpkgs.nix {}; mkPkgs = branch: args: ( - import ./pkgs/by-name/nixpkgs-bootstrap/${branch}.nix args + mkNixpkgs (args // { inherit branch; }) ).extend (import ./overlays/all.nix); pkgs = mkPkgs "master" { inherit localSystem; }; inherit (pkgs) lib; diff --git a/pkgs/by-name/nixpkgs-bootstrap/master.nix b/pkgs/by-name/nixpkgs-bootstrap/master.nix index c90b84914..1f5a3fe6e 100644 --- a/pkgs/by-name/nixpkgs-bootstrap/master.nix +++ b/pkgs/by-name/nixpkgs-bootstrap/master.nix @@ -6,11 +6,10 @@ # - paste the output as the new `sha256` { mkNixpkgs ? import ./mkNixpkgs.nix {}, - ... -}@args: -mkNixpkgs ({ +}: +mkNixpkgs { rev = "5db39d669a21ca7f0e76c295e7664b9d938b7042"; sha256 = "sha256-SUZZMAn19X3Ym6lVb18LoXhCS2yicrRr83si5VyJDS0="; version = "0-unstable-2025-02-28"; branch = "master"; -} // args) +} diff --git a/pkgs/by-name/nixpkgs-bootstrap/mkNixpkgs.nix b/pkgs/by-name/nixpkgs-bootstrap/mkNixpkgs.nix index c68e512b2..63333790a 100644 --- a/pkgs/by-name/nixpkgs-bootstrap/mkNixpkgs.nix +++ b/pkgs/by-name/nixpkgs-bootstrap/mkNixpkgs.nix @@ -28,10 +28,10 @@ let fetchzip' = if inBootstrap then builtins.fetchTarball else fetchzip; optionalAttrs = cond: attrs: if cond then attrs else {}; mkNixpkgs = { - rev, - sha256, branch, - version, + rev ? null, + sha256 ? null, + version ? null, #VVV config localSystem ? if stdenv != null then stdenv.buildPlatform.system else builtins.currentSystem, #< not available in pure mode system ? if stdenv != null then stdenv.hostPlatform.system else localSystem, @@ -84,41 +84,48 @@ let } else {}); nixpkgs = import "${patchedSrc}" nixpkgsArgs; in - # N.B.: this is crafted to allow `nixpkgs.FOO` from other nix code - # AND `nix-build -A nixpkgs` - patchedSrc.overrideAttrs (base: { - # attributes needed for update scripts - inherit version; - pname = "nixpkgs"; - passthru = (base.passthru or {}) // nixpkgs // { - # override is used to configure hostPlatform higher up. - override = overrideArgs: mkNixpkgs (args // overrideArgs); + if rev == null && sha256 == null && version == null then + import ./${branch}.nix { + mkNixpkgs = args': mkNixpkgs ({ + inherit localSystem system; + } // args'); + } + else + # N.B.: this is crafted to allow `nixpkgs.FOO` from other nix code + # AND `nix-build -A nixpkgs` + patchedSrc.overrideAttrs (base: { + # attributes needed for update scripts + inherit version; + pname = "nixpkgs"; + passthru = (base.passthru or {}) // nixpkgs // { + # override is used to configure hostPlatform higher up. + override = overrideArgs: mkNixpkgs (args // overrideArgs); - # N.B.: src has to be specified in passthru, not the outer scope, so as to take precedence over the nixpkgs `src` package - src = { - # required by unstableGitUpdater - gitRepoUrl = "https://github.com/NixOS/nixpkgs.git"; - inherit rev; - } // src'; + # N.B.: src has to be specified in passthru, not the outer scope, so as to take precedence over the nixpkgs `src` package + src = { + # required by unstableGitUpdater + gitRepoUrl = "https://github.com/NixOS/nixpkgs.git"; + inherit rev; + } // src'; - # required so that unstableGitUpdater can know in which file the `rev` variable can be updated in. - meta.position = let - position = builtins.unsafeGetAttrPos "rev" args; - in - "${position.file}:${toString position.line}"; + # required so that unstableGitUpdater can know in which file the `rev` variable can be updated in. + meta.position = let + position = builtins.unsafeGetAttrPos "rev" args; + in + "${position.file}:${toString position.line}"; - # while we could *technically* use `nixpkgs.<...>` updateScript - # that can force maaany rebuilds on staging/staging-next. - # updateScript = nix-update-script { - # extraArgs = [ "--version=branch=${branch}" ]; - # }; - updateScript = unstableGitUpdater { - # else the update script tries to walk 10000's of commits to find a tag - hardcodeZeroVersion = true; - inherit branch; + # while we could *technically* use `nixpkgs.<...>` updateScript + # that can force maaany rebuilds on staging/staging-next. + # updateScript = nix-update-script { + # extraArgs = [ "--version=branch=${branch}" ]; + # }; + updateScript = unstableGitUpdater { + # else the update script tries to walk 10000's of commits to find a tag + hardcodeZeroVersion = true; + inherit branch; + }; }; - }; - }) + }) ; in mkNixpkgs diff --git a/pkgs/by-name/nixpkgs-bootstrap/staging-next.nix b/pkgs/by-name/nixpkgs-bootstrap/staging-next.nix index f1e1963f8..56a548caa 100644 --- a/pkgs/by-name/nixpkgs-bootstrap/staging-next.nix +++ b/pkgs/by-name/nixpkgs-bootstrap/staging-next.nix @@ -1,10 +1,9 @@ { mkNixpkgs ? import ./mkNixpkgs.nix {}, - ... -}@args: -mkNixpkgs ({ +}: +mkNixpkgs { rev = "749375426d72ead4bdac625818e7be62a6bbbaf4"; sha256 = "sha256-IDxPfbSdIy7XAP1hneGOfr2jsj+hFUsvFhpRksYqols="; version = "0-unstable-2025-02-28"; branch = "staging-next"; -} // args) +} diff --git a/pkgs/by-name/nixpkgs-bootstrap/staging.nix b/pkgs/by-name/nixpkgs-bootstrap/staging.nix index 28b0300aa..96b169303 100644 --- a/pkgs/by-name/nixpkgs-bootstrap/staging.nix +++ b/pkgs/by-name/nixpkgs-bootstrap/staging.nix @@ -1,10 +1,9 @@ { mkNixpkgs ? import ./mkNixpkgs.nix {}, - ... -}@args: -mkNixpkgs ({ +}: +mkNixpkgs { rev = "29dcbf482396b9e5bdf1ec92973a8451e0aaa1d5"; sha256 = "sha256-ps1xz98RAUqrT+V7GFpzf/uHaoh9o5ZoOpE7SnSB6sY="; version = "0-unstable-2025-02-28"; branch = "staging"; -} // args) +}