flake: have update.pkgs not update the feeds by default

This commit is contained in:
2023-09-24 12:35:39 +00:00
parent 083bdad88f
commit e8bf83274f

View File

@@ -273,28 +273,32 @@
${command} ${command}
''); '');
}; };
mkUpdatersNoAliases = basePath: pkgs.lib.concatMapAttrs mkUpdatersNoAliases = opts: basePath: pkgs.lib.concatMapAttrs
(name: pkg: (name: pkg:
if pkg.recurseForDerivations or false then { if pkg.recurseForDerivations or false then {
"${name}" = mkUpdaters (basePath ++ [ name ]); "${name}" = mkUpdaters opts (basePath ++ [ name ]);
} else if pkg.updateScript or null != null then { } else if pkg.updateScript or null != null then {
"${name}" = mkUpdater (basePath ++ [ name ]); "${name}" = mkUpdater (basePath ++ [ name ]);
} else {} } else {}
) )
(pkgs.lib.getAttrFromPath basePath sanePkgs); (pkgs.lib.getAttrFromPath basePath sanePkgs);
mkUpdaters = basePath: mkUpdaters = { ignore ? [] }@opts: basePath:
let let
updaters = mkUpdatersNoAliases basePath; updaters = mkUpdatersNoAliases opts basePath;
invokeUpdater = name: pkg: invokeUpdater = name: pkg:
let let
fullPath = basePath ++ [ name ];
doUpdateByDefault = !builtins.elem fullPath ignore;
# 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}"'') (basePath ++ [ name ]); escapedPath = builtins.map (p: ''"${p}"'') fullPath;
updatePath = builtins.concatStringsSep "." ([ "update" "pkgs" ] ++ escapedPath); updatePath = builtins.concatStringsSep "." ([ "update" "pkgs" ] ++ escapedPath);
in pkgs.lib.escapeShellArgs [ in pkgs.lib.optionalString doUpdateByDefault (
pkgs.lib.escapeShellArgs [
"nix" "run" ".#${updatePath}" "nix" "run" ".#${updatePath}"
]; ]
);
in { in {
#all = {
type = "app"; type = "app";
program = builtins.toString (pkgs.writeShellScript program = builtins.toString (pkgs.writeShellScript
(builtins.concatStringsSep "-" (["update"] ++ basePath)) (builtins.concatStringsSep "-" (["update"] ++ basePath))
@@ -303,7 +307,6 @@
(pkgs.lib.mapAttrsToList invokeUpdater updaters) (pkgs.lib.mapAttrsToList invokeUpdater updaters)
) )
); );
#};
} // updaters; } // updaters;
in { in {
help = { help = {
@@ -315,7 +318,7 @@
- show this message - show this message
- `nix run '.#update.pkgs'` - `nix run '.#update.pkgs'`
- updates every package - updates every package
- `nix run '.#update.pkgs.feeds'` - `nix run '.#update.feeds'`
- updates metadata for all feeds - updates metadata for all feeds
- `nix run '.#init-feed' <url>` - `nix run '.#init-feed' <url>`
- `nix run '.#deploy-{lappy,moby,moby-test,servo}' [nixos-rebuild args ...]` - `nix run '.#deploy-{lappy,moby,moby-test,servo}' [nixos-rebuild args ...]`
@@ -325,7 +328,8 @@
cat ${helpMsg} cat ${helpMsg}
''); '');
}; };
update.pkgs = mkUpdaters []; update.pkgs = mkUpdaters { ignore = [ ["feeds"] ]; } [];
update.feeds = mkUpdaters {} [ "feeds" ];
init-feed = { init-feed = {
type = "app"; type = "app";