flake: fix "update" for my newer overlay schema

This commit is contained in:
Colin 2023-11-26 02:16:25 +00:00
parent 9491190ce4
commit 9bd0537854

View File

@ -278,6 +278,7 @@
# pkg updating. # pkg updating.
# a cleaner alternative lives here: <https://discourse.nixos.org/t/how-can-i-run-the-updatescript-of-personal-packages/25274/2> # a cleaner alternative lives here: <https://discourse.nixos.org/t/how-can-i-run-the-updatescript-of-personal-packages/25274/2>
# mkUpdater :: [ String ] -> { type = "app"; program = path; }
mkUpdater = attrPath: { mkUpdater = attrPath: {
type = "app"; type = "app";
program = let program = let
@ -302,7 +303,7 @@
} else {} } else {}
) )
(pkgs.lib.getAttrFromPath basePath sanePkgs); (pkgs.lib.getAttrFromPath basePath sanePkgs);
mkUpdaters = { ignore ? [] }@opts: basePath: mkUpdaters = { ignore ? [], flakePrefix ? [] }@opts: basePath:
let let
updaters = mkUpdatersNoAliases opts basePath; updaters = mkUpdatersNoAliases opts basePath;
invokeUpdater = name: pkg: invokeUpdater = name: pkg:
@ -312,7 +313,7 @@
# in case `name` has a `.` in it, we have to quote it # in case `name` has a `.` in it, we have to quote it
escapedPath = builtins.map (p: ''"${p}"'') fullPath; escapedPath = builtins.map (p: ''"${p}"'') fullPath;
updatePath = builtins.concatStringsSep "." ([ "update" "pkgs" ] ++ escapedPath); updatePath = builtins.concatStringsSep "." (flakePrefix ++ escapedPath);
in pkgs.lib.optionalString doUpdateByDefault ( in pkgs.lib.optionalString doUpdateByDefault (
pkgs.lib.escapeShellArgs [ pkgs.lib.escapeShellArgs [
"nix" "run" ".#${updatePath}" "nix" "run" ".#${updatePath}"
@ -320,8 +321,9 @@
); );
in { in {
type = "app"; type = "app";
# top-level app just invokes the updater of everything one layer below it
program = builtins.toString (pkgs.writeShellScript program = builtins.toString (pkgs.writeShellScript
(builtins.concatStringsSep "-" (["update"] ++ basePath)) (builtins.concatStringsSep "-" (flakePrefix ++ basePath))
(builtins.concatStringsSep (builtins.concatStringsSep
"\n" "\n"
(pkgs.lib.mapAttrsToList invokeUpdater updaters) (pkgs.lib.mapAttrsToList invokeUpdater updaters)
@ -355,8 +357,14 @@
nix flake show --option allow-import-from-derivation true nix flake show --option allow-import-from-derivation true
''); '');
}; };
update.pkgs = mkUpdaters { ignore = [ ["feeds"] ]; } []; # wrangle some names to get package updaters which refer back into the flake, but also conditionally ignore certain paths (e.g. sane.feeds).
update.feeds = mkUpdaters {} [ "feeds" ]; # TODO: better design
update = rec {
_impl.pkgs.sane = mkUpdaters { flakePrefix = [ "update" "_impl" "pkgs" ]; ignore = [ [ "sane" "feeds" ] ]; } [ "sane" ];
pkgs = _impl.pkgs.sane;
_impl.feeds.sane.feeds = mkUpdaters { flakePrefix = [ "update" "_impl" "feeds" ]; } [ "sane" "feeds" ];
feeds = _impl.feeds.sane.feeds;
};
init-feed = { init-feed = {
type = "app"; type = "app";