pkgs/nixpkgs: move to by-name

This commit is contained in:
2024-10-03 09:30:34 +00:00
parent 141ce4be3d
commit 474e37d1e4
3 changed files with 78 additions and 57 deletions

View File

@@ -0,0 +1,63 @@
{
nix-update-script,
localSystem,
system,
src,
rev,
doPatch,
passthru ? {},
}: let
commonNixpkgsArgs = {
inherit localSystem;
# reset impurities
config = {};
overlays = [];
};
unpatchedNixpkgs = import src commonNixpkgsArgs;
patchedSrc = unpatchedNixpkgs.applyPatches {
inherit src;
name = "nixpkgs-patched-uninsane";
# version = ...
patches = unpatchedNixpkgs.callPackage ./list.nix { };
# skip applied patches
prePatch = ''
realpatch=$(command -v patch)
patch() {
OUT=$($realpatch "$@") || echo "$OUT" | grep "Skipping patch" -q
}
'';
};
src' = if doPatch then patchedSrc else { outPath = src; };
args = commonNixpkgsArgs // {
config = {
allowUnfree = true; # NIXPKGS_ALLOW_UNFREE=1
allowBroken = true; # NIXPKGS_ALLOW_BROKEN=1
};
} // (if (system != localSystem) then {
# XXX(2023/12/11): cache.nixos.org uses `system = ...` instead of `hostPlatform.system`, and that choice impacts the closure of every package.
# so avoid specifying hostPlatform.system on non-cross builds, so i can use upstream caches.
crossSystem = system;
} else {});
nixpkgs = import "${src'}" args;
in
# N.B.: this is crafted to allow `nixpkgs.FOO` from other nix code
# AND `nix-build -A nixpkgs`
if src' ? overrideAttrs then
src'.overrideAttrs (base: {
# attributes needed for update scripts
pname = "nixpkgs";
version = "24.05-unstable-2024-10-02";
passthru = (base.passthru or {}) // nixpkgs // {
src = src // {
inherit rev;
};
updateScript = nix-update-script {
extraArgs = [ "--version" "branch" ];
};
} // passthru;
})
else
nixpkgs

View File

@@ -37,62 +37,20 @@ let
staging-next.rev = "dd89098d752fcd8af9c4e59a66b97af8e8fd185b"; staging-next.rev = "dd89098d752fcd8af9c4e59a66b97af8e8fd185b";
staging-next.sha256 = "sha256-L/g6FGwBe9yd7IXE4271e9ptU0Cb22ycA2I1Ymn+HTk="; staging-next.sha256 = "sha256-L/g6FGwBe9yd7IXE4271e9ptU0Cb22ycA2I1Ymn+HTk=";
}; };
lock' = lock."${variant}";
unpatchedSrc = fetchzip {
url = "https://github.com/NixOS/nixpkgs/archive/${lock'.rev}.tar.gz";
inherit (lock') sha256;
};
commonNixpkgsArgs = {
inherit localSystem;
# reset impurities
config = {};
overlays = [];
};
unpatchedNixpkgs = import unpatchedSrc commonNixpkgsArgs;
patchedSrc = unpatchedNixpkgs.applyPatches { mkVariant = variant: args: let
name = "nixpkgs-patched-uninsane"; lock' = lock."${variant}";
# version = ... in import ./common.nix ({
src = unpatchedSrc; inherit doPatch localSystem nix-update-script system;
patches = unpatchedNixpkgs.callPackage ./list.nix { }; inherit (lock') rev;
# skip applied patches src = fetchzip {
prePatch = '' url = "https://github.com/NixOS/nixpkgs/archive/${lock'.rev}.tar.gz";
realpatch=$(command -v patch) inherit (lock') sha256;
patch() {
OUT=$($realpatch "$@") || echo "$OUT" | grep "Skipping patch" -q
}
'';
};
src = if doPatch then patchedSrc else { outPath = unpatchedSrc; };
args = commonNixpkgsArgs // {
config = {
allowUnfree = true; # NIXPKGS_ALLOW_UNFREE=1
allowBroken = true; # NIXPKGS_ALLOW_BROKEN=1
}; };
} // (if (system != localSystem) then { } // args);
# XXX(2023/12/11): cache.nixos.org uses `system = ...` instead of `hostPlatform.system`, and that choice impacts the closure of every package.
# so avoid specifying hostPlatform.system on non-cross builds, so i can use upstream caches.
crossSystem = system;
} else {});
nixpkgs = import "${src}" args;
in in
# N.B.: this is crafted to allow `nixpkgs.FOO` from other nix code mkVariant "master" {
# AND `nix-build -A nixpkgs` passthru.staging = mkVariant "staging" {};
if src ? overrideAttrs then passthru.staging-next = mkVariant "staging-next" {};
src.overrideAttrs (base: { }
# attributes needed for update scripts
pname = "nixpkgs";
version = "24.05-unstable-2024-10-02";
passthru = (base.passthru or {}) // nixpkgs // {
src = unpatchedSrc // {
inherit (lock') rev;
};
updateScript = nix-update-script {
extraArgs = [ "--version" "branch" ];
};
};
})
else
nixpkgs

View File

@@ -32,8 +32,8 @@ let
gpodder-adaptive-configured = gpodder-configured.override { gpodder-adaptive-configured = gpodder-configured.override {
gpodder = gpodder-adaptive; gpodder = gpodder-adaptive;
}; };
nixpkgs-staging = nixpkgs.override { variant = "staging"; }; nixpkgs-staging = nixpkgs.staging;
nixpkgs-next = nixpkgs.override { variant = "staging-next"; }; nixpkgs-next = nixpkgs.staging-next;
inherit (trivial-builders) inherit (trivial-builders)
copyIntoOwnPackage copyIntoOwnPackage
deepLinkIntoOwnPackage deepLinkIntoOwnPackage