refactor so that my update scripts can apply to the nixpkgs bootstrap
This commit is contained in:
32
impure.nix
32
impure.nix
@@ -7,7 +7,7 @@
|
||||
{ }:
|
||||
let
|
||||
mkPkgs = branch: args: (
|
||||
import ./pkgs/by-name/nixpkgs/package.nix args
|
||||
import ./pkgs/by-name/nixpkgs-bootstrap/package.nix args
|
||||
)."${branch}".extend (import ./overlays/all.nix);
|
||||
pkgs = mkPkgs "master" {};
|
||||
inherit (pkgs) lib;
|
||||
@@ -78,25 +78,37 @@ let
|
||||
)
|
||||
attrs;
|
||||
|
||||
# update only packages maintained by me:
|
||||
# shouldUpdate = pkg: let
|
||||
# maintainers = ((pkg.meta or {}).maintainers or []);
|
||||
# in
|
||||
# pkg ? updateScript &&
|
||||
# (lib.elem lib.maintainers.colinsane maintainers || maintainers == [])
|
||||
# ;
|
||||
|
||||
# update any package possible, and just rely on good namespacing:
|
||||
shouldUpdate = pkg: pkg ? updateScript;
|
||||
|
||||
# given the path to a package, and that package, returns a list of all attr-paths (stringified)
|
||||
# which should be updated as part of that package (including the package in question).
|
||||
mkUpdateList = prefix: pkg: (lib.optionals (pkg ? updateScript) [ prefix ]) ++
|
||||
lib.foldl'
|
||||
(acc: nestedName: acc ++ mkUpdateListIfAuto "${prefix}.${nestedName}" pkg."${nestedName}")
|
||||
[]
|
||||
mkUpdateList = prefix: pkg: (lib.optionals (shouldUpdate pkg) [ prefix ]) ++
|
||||
lib.concatMap
|
||||
(nestedName: mkUpdateListIfAuto "${prefix}.${nestedName}" pkg."${nestedName}")
|
||||
(lib.optionals (pkg.recurseForDerivations or false) (subAttrNames pkg))
|
||||
;
|
||||
# a package can set `passthru.updateWithSuper = false;` if it doesn't want to be auto-updated.
|
||||
mkUpdateListIfAuto = prefix: pkg: lib.optionals (pkg.updateWithSuper or true) (mkUpdateList prefix pkg);
|
||||
|
||||
mkUpdateInfo = prefix: pkg: {
|
||||
"${prefix}" = rec {
|
||||
subPackages = mkUpdateList prefix pkg;
|
||||
mkUpdateInfo = prefix: pkg: let
|
||||
# the actual shell command which can update the package, after an environment has been configured for the updater:
|
||||
updateArgv = lib.optionals (pkg ? updateScript) (
|
||||
if builtins.isList pkg.updateScript then pkg.updateScript
|
||||
else if pkg.updateScript ? command then builtins.map builtins.toString pkg.updateScript.command
|
||||
else []
|
||||
);
|
||||
in {
|
||||
"${prefix}" = {
|
||||
subPackages = mkUpdateList prefix pkg;
|
||||
updateScript = let
|
||||
pname = pkg.pname or (pkg.name or "unknown");
|
||||
script = pkgs.writeShellScriptBin "update-${pname}" ''
|
||||
@@ -110,7 +122,7 @@ let
|
||||
${lib.escapeShellArgs updateArgv}
|
||||
popd
|
||||
'';
|
||||
in lib.optionalString (updateArgv != []) (lib.getExe script);
|
||||
in lib.optionalString (shouldUpdate pkg && updateArgv != []) (lib.getExe script);
|
||||
};
|
||||
} // builtins.foldl'
|
||||
(acc: subPkgName: acc // mkUpdateInfo "${prefix}.${subPkgName}" pkg."${subPkgName}")
|
||||
@@ -122,6 +134,8 @@ let
|
||||
in {
|
||||
inherit hosts;
|
||||
inherit updateInfo;
|
||||
# AttrSet mapping attrpath to a list of attrpaths representing all updatable packages beneath it
|
||||
updateTargets = builtins.mapAttrs (_: v: v.subPackages) (lib.filterAttrs (_: v: v.subPackages != []) updateInfo);
|
||||
# AttrSet mapping attrpath to the path of a shell script which can be used to update the package at that attrpath
|
||||
updateScripts = builtins.mapAttrs (_: v: v.updateScript) (lib.filterAttrs (_: v: v.updateScript != "") updateInfo);
|
||||
} // pkgs
|
||||
|
@@ -37,21 +37,19 @@ let
|
||||
staging-next.sha256 = "sha256-NFLhqDfWf49M4t6/YvK7XMqpLhTU1t1PcRUrGhODTM0=";
|
||||
};
|
||||
|
||||
mkVariant = variant: args: let
|
||||
mkVariant = variant: let
|
||||
lock' = lock."${variant}";
|
||||
in import ./common.nix ({
|
||||
in import ./common.nix {
|
||||
inherit doPatch localSystem nix-update-script system;
|
||||
inherit (lock') rev;
|
||||
src = fetchzip {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${lock'.rev}.tar.gz";
|
||||
inherit (lock') sha256;
|
||||
};
|
||||
} // args);
|
||||
|
||||
nixpkgs = mkVariant "master" {};
|
||||
in
|
||||
nixpkgs.lib.recurseIntoAttrs (mkVariant "master" {
|
||||
passthru.master = nixpkgs;
|
||||
passthru.staging = mkVariant "staging" {};
|
||||
passthru.staging-next = mkVariant "staging-next" {};
|
||||
})
|
||||
};
|
||||
in {
|
||||
recurseForDerivations = true;
|
||||
master = mkVariant "master";
|
||||
staging = mkVariant "staging";
|
||||
staging-next = mkVariant "staging-next";
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
# using the correct invocation is critical if any packages mentioned here are
|
||||
# additionally patched elsewhere
|
||||
#
|
||||
{ pkgs ? import ./additional/nixpkgs { }, final ? null }:
|
||||
{ pkgs ? (import ./by-name/nixpkgs-bootstrap { }).master, final ? null }:
|
||||
let
|
||||
lib = pkgs.lib;
|
||||
unpatched = pkgs;
|
||||
@@ -24,6 +24,9 @@ let
|
||||
# build like `nix-build -A linuxPackages.rk818-charger`
|
||||
# or `nix-build -A hosts.moby.config.boot.kernelPackages.rk818-charger`
|
||||
linuxKernel = unpatched.linuxKernel // {
|
||||
# don't update by default since most of these packages are from a different repo (i.e. nixpkgs).
|
||||
updateWithSuper = false;
|
||||
|
||||
packagesFor = kernel: (unpatched.linuxKernel.packagesFor kernel).extend (kFinal: kPrev: (
|
||||
lib.filesystem.packagesFromDirectoryRecursive {
|
||||
inherit (kFinal) callPackage;
|
||||
@@ -33,8 +36,9 @@ let
|
||||
};
|
||||
|
||||
### aliases
|
||||
nixpkgs-staging = nixpkgs.staging;
|
||||
nixpkgs-next = nixpkgs.staging-next;
|
||||
# nixpkgs = nixpkgs-bootstrap.master;
|
||||
# nixpkgs-staging = nixpkgs-bootstrap.staging;
|
||||
# nixpkgs-next = nixpkgs-bootstrap.staging-next;
|
||||
inherit (trivial-builders)
|
||||
copyIntoOwnPackage
|
||||
deepLinkIntoOwnPackage
|
||||
|
Reference in New Issue
Block a user