flake: add host outputs for nixpkgs-staging and nixpkgs-staging-next

This commit is contained in:
Colin 2023-12-11 22:12:42 +00:00
parent e7edb4739f
commit e7826e0648
4 changed files with 67 additions and 13 deletions

View File

@ -51,6 +51,38 @@
"type": "github"
}
},
"nixpkgs-staging-next-unpatched": {
"locked": {
"lastModified": 1702317658,
"narHash": "sha256-jYzBIMW18oQG+uQ9TVZwiYFHVafYIqllW+zFLROtwcE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "f81605387c494a302c16901ac6459e877c45f913",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "staging-next",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-staging-unpatched": {
"locked": {
"lastModified": 1702311933,
"narHash": "sha256-bARcUNREf0wVSYzWhcK+mKCUgzeHbiKKDbpHBH92Mdk=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "14b1b887952e70c12c6b8fc4ee9c1e22ec32faa6",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "staging",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-unpatched": {
"locked": {
"lastModified": 1702272962,
@ -70,6 +102,8 @@
"root": {
"inputs": {
"mobile-nixos": "mobile-nixos",
"nixpkgs-staging-next-unpatched": "nixpkgs-staging-next-unpatched",
"nixpkgs-staging-unpatched": "nixpkgs-staging-unpatched",
"nixpkgs-unpatched": "nixpkgs-unpatched",
"sops-nix": "sops-nix",
"uninsane-dot-org": "uninsane-dot-org"

View File

@ -44,8 +44,8 @@
# <https://github.com/nixos/nixpkgs/tree/nixos-unstable>
# nixpkgs-unpatched.url = "github:nixos/nixpkgs?ref=nixos-unstable";
nixpkgs-unpatched.url = "github:nixos/nixpkgs?ref=master";
# nixpkgs-unpatched.url = "github:nixos/nixpkgs?ref=staging-next";
# nixpkgs-unpatched.url = "github:nixos/nixpkgs?ref=staging";
nixpkgs-staging-next-unpatched.url = "github:nixos/nixpkgs?ref=staging-next";
nixpkgs-staging-unpatched.url = "github:nixos/nixpkgs?ref=staging";
mobile-nixos = {
# <https://github.com/nixos/mobile-nixos>
@ -74,6 +74,8 @@
outputs = {
self,
nixpkgs-unpatched,
nixpkgs-staging-unpatched ? null,
nixpkgs-staging-next-unpatched ? null,
mobile-nixos,
sops-nix,
uninsane-dot-org,
@ -83,6 +85,8 @@
inherit (builtins) attrNames elem listToAttrs map mapAttrs;
# redefine some nixpkgs `lib` functions to avoid the infinite recursion
# of if we tried to use patched `nixpkgs.lib` as part of the patching process.
mapAttrs' = f: set:
listToAttrs (map (attr: f attr set.${attr}) (attrNames set));
optionalAttrs = cond: attrs: if cond then attrs else {};
# mapAttrs but without the `name` argument
mapAttrValues = f: mapAttrs (_: f);
@ -90,9 +94,9 @@
# rather than apply our nixpkgs patches as a flake input, do that here instead.
# this (temporarily?) resolves the bad UX wherein a subflake residing in the same git
# repo as the main flake causes the main flake to have an unstable hash.
nixpkgs = (import ./nixpatches/flake.nix).outputs {
self = nixpkgs;
nixpkgs = nixpkgs-unpatched;
patchNixpkgs = variant: nixpkgs: (import ./nixpatches/flake.nix).outputs {
inherit variant nixpkgs;
self = patchNixpkgs variant nixpkgs;
} // {
# provide values that nixpkgs ordinarily sources from the flake.lock file,
# inaccessible to it here because of the import-from-derivation.
@ -108,9 +112,10 @@
inherit (self) shortRev;
};
nixpkgs = patchNixpkgs "master" nixpkgs-unpatched;
nixpkgsCompiledBy = system: nixpkgs.legacyPackages."${system}";
evalHost = { name, local, target, light ? false }: nixpkgs.lib.nixosSystem {
evalHost = { name, local, target, light ? false, nixpkgs ? nixpkgs }: nixpkgs.lib.nixosSystem {
system = target;
modules = [
{
@ -148,7 +153,19 @@
moby-light = { name = "moby"; local = "x86_64-linux"; target = "aarch64-linux"; light = true; };
rescue = { name = "rescue"; local = "x86_64-linux"; target = "x86_64-linux"; };
};
in mapAttrValues evalHost hosts;
stagingHosts = mapAttrs' (h: v: {
name = "${h}-staging";
value = v // { nixpkgs = patchNixpkgs "staging" nixpkgs-staging-unpatched; };
}) hosts;
stagingNextHosts = mapAttrs' (h: v: {
name = "${h}-staging-next";
value = v // { nixpkgs = patchNixpkgs "staging-next" nixpkgs-staging-next-unpatched; };
}) hosts;
in mapAttrValues evalHost (
hosts //
(optionalAttrs (nixpkgs-staging-unpatched != null) stagingHosts) //
(optionalAttrs (nixpkgs-staging-next-unpatched != null) stagingNextHosts)
);
# unofficial output
# this produces a EFI-bootable .img file (GPT with a /boot partition and a system (/ or /nix) partition).

View File

@ -3,15 +3,16 @@
# user is expected to define this from their flake via `inputs.nixpkgs.follows = ...`
nixpkgs = {};
};
outputs = { self, nixpkgs }@inputs:
outputs = { self, nixpkgs, variant ? "master" }@inputs:
let
patchedPkgsFor = system: nixpkgs.legacyPackages.${system}.applyPatches {
name = "nixpkgs-patched-uninsane";
version = self.lastModifiedDate;
src = nixpkgs;
patches = import ./list.nix {
patches = builtins.filter (p: p != null) (import ./list.nix {
inherit (nixpkgs.legacyPackages.${system}) fetchpatch2 fetchurl;
};
inherit variant;
});
};
patchedFlakeFor = system: import "${patchedPkgsFor system}/flake.nix";
patchedFlakeOutputsFor = system:

View File

@ -1,4 +1,4 @@
{ fetchpatch2, fetchurl }:
{ fetchpatch2, fetchurl, variant }:
let
fetchpatch' = {
saneCommit ? null,
@ -7,6 +7,7 @@ let
hash ? null,
title ? null,
revert ? false,
applies ? [ "unstable" "master" "staging" "staging-next" ],
}:
let
url = if prUrl != null then
@ -17,11 +18,11 @@ let
else
"https://github.com/NixOS/nixpkgs/commit/${nixpkgsCommit}.patch"
;
in fetchpatch2 (
in if (builtins.elem variant applies) then fetchpatch2 (
{ inherit revert url; }
// (if hash != null then { inherit hash; } else {})
// (if title != null then { name = title; } else {})
);
) else null;
in [
(fetchpatch' {
title = "ripgrep: fix shell completions when cross compiling";
@ -32,6 +33,7 @@ in [
title = "python3Packages.numpy: fix cross compilation";
prUrl = "https://github.com/NixOS/nixpkgs/pull/268587";
hash = "sha256-GRRLXwUw2JXEV6Ov0QiVTFwoi/ACManG2Qk7D3fzS8E=";
applies = [ "unstable" "master" ];
})
# (fetchpatch' {
# title = "nixos/slskd: allow omitting username from yaml config";