nix-files/pkgs/additional/nixpkgs/default.nix

96 lines
3.4 KiB
Nix

# XXX: this is in the bootstrap path;
# this means it has to be evaluatable using only builtins,
# though i'm free to include optional functionality (e.g. update scripts) so long as i gate it behind availability checks.
#
# branch workflow:
# - daily:
# - nixos-unstable cut from master after enough packages have been built in caches.
# - every 6 hours:
# - master auto-merged into staging and staging-next
# - staging-next auto-merged into staging.
# - manually, approximately once per month:
# - staging-next is cut from staging.
# - staging-next merged into master.
#
# which branch to source from?
# - nixos-unstable: for everyday development; it provides good caching
# - master: temporarily if i'm otherwise cherry-picking lots of already-applied patches
# - staging-next: if testing stuff that's been PR'd into staging, i.e. base library updates.
# - staging: maybe if no staging-next -> master PR has been cut yet?
{ variant ? "master"
, doPatch ? true
, localSystem ? builtins.currentSystem #< not available in pure mode
, system ? localSystem
#VVV these may or may not be available when called VVV
, fetchzip ? builtins.fetchTarball
, nix-update-script ? null
}:
let
lock = {
master.rev = "716a7056386dcc67eb3b813289499d6329d4befc";
master.sha256 = "sha256:1skv9nbnspi3pphk4jzvcj147796m4wqdx8iwdbnl9h4nd3kw6n2";
staging.rev = "da9d22446697971278edcd4af92f63221f7d21f6";
staging.sha256 = "sha256:0yccyg071zn77i1pfb49dz07difwx5k3w1g0l1vdzlc3xiv9dgmk";
staging-next.rev = "5aa86ae5585cd46299ee46682fda8a9b76baf2ae";
staging-next.sha256 = "sha256:1dqws7fmdv4l9mk45i88ivzlxzm2b4lbdg9rg4am0z1alsz36dzz";
};
lock' = lock."${variant}";
unpatchedSrc = fetchzip {
url = "https://github.com/NixOS/nixpkgs/archive/${lock'.rev}.tar.gz";
inherit (lock') sha256;
};
unpatchedNixpkgs = import unpatchedSrc { inherit localSystem; };
patchesFor = unpatchedNixpkgs.callPackage ./list.nix { };
patchedSrc = unpatchedNixpkgs.applyPatches {
name = "nixpkgs-patched-uninsane";
# version = ...
src = unpatchedSrc;
patches = patchesFor {
inherit variant;
date = unpatchedSrc.lastModifiedDate;
};
# skip applied patches
prePatch = ''
realpatch=$(command -v patch)
patch() {
OUT=$($realpatch "$@") || echo "$OUT" | grep "Skipping patch" -q
}
'';
};
src = if doPatch then patchedSrc else { outPath = unpatchedSrc; };
args = {
inherit localSystem;
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-06-xx";
passthru = (base.passthru or {}) // nixpkgs // {
src = unpatchedSrc // {
inherit (lock') rev;
};
updateScript = nix-update-script {
extraArgs = [ "--version" "branch" ];
};
};
})
else
nixpkgs