fix impure.nix to be compatible with updateScripts

This commit is contained in:
2025-03-04 07:30:57 +00:00
parent 8160840bf2
commit dd9daa06a8
5 changed files with 52 additions and 47 deletions

View File

@@ -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;

View File

@@ -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)
}

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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)
}