From e8bf83274fe70de7dc10aae5b87e547f9d452ceb Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 24 Sep 2023 12:35:39 +0000 Subject: [PATCH] flake: have update.pkgs not update the feeds by default --- flake.nix | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index c520983a9..9f4a92910 100644 --- a/flake.nix +++ b/flake.nix @@ -273,37 +273,40 @@ ${command} ''); }; - mkUpdatersNoAliases = basePath: pkgs.lib.concatMapAttrs + mkUpdatersNoAliases = opts: basePath: pkgs.lib.concatMapAttrs (name: pkg: if pkg.recurseForDerivations or false then { - "${name}" = mkUpdaters (basePath ++ [ name ]); + "${name}" = mkUpdaters opts (basePath ++ [ name ]); } else if pkg.updateScript or null != null then { "${name}" = mkUpdater (basePath ++ [ name ]); } else {} ) (pkgs.lib.getAttrFromPath basePath sanePkgs); - mkUpdaters = basePath: + mkUpdaters = { ignore ? [] }@opts: basePath: let - updaters = mkUpdatersNoAliases basePath; + updaters = mkUpdatersNoAliases opts basePath; invokeUpdater = name: pkg: let + fullPath = basePath ++ [ name ]; + doUpdateByDefault = !builtins.elem fullPath ignore; + # 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); - in pkgs.lib.escapeShellArgs [ - "nix" "run" ".#${updatePath}" - ]; - in { - #all = { - type = "app"; - program = builtins.toString (pkgs.writeShellScript - (builtins.concatStringsSep "-" (["update"] ++ basePath)) - (builtins.concatStringsSep - "\n" - (pkgs.lib.mapAttrsToList invokeUpdater updaters) - ) + in pkgs.lib.optionalString doUpdateByDefault ( + pkgs.lib.escapeShellArgs [ + "nix" "run" ".#${updatePath}" + ] ); - #}; + in { + type = "app"; + program = builtins.toString (pkgs.writeShellScript + (builtins.concatStringsSep "-" (["update"] ++ basePath)) + (builtins.concatStringsSep + "\n" + (pkgs.lib.mapAttrsToList invokeUpdater updaters) + ) + ); } // updaters; in { help = { @@ -315,7 +318,7 @@ - show this message - `nix run '.#update.pkgs'` - updates every package - - `nix run '.#update.pkgs.feeds'` + - `nix run '.#update.feeds'` - updates metadata for all feeds - `nix run '.#init-feed' ` - `nix run '.#deploy-{lappy,moby,moby-test,servo}' [nixos-rebuild args ...]` @@ -325,7 +328,8 @@ cat ${helpMsg} ''); }; - update.pkgs = mkUpdaters []; + update.pkgs = mkUpdaters { ignore = [ ["feeds"] ]; } []; + update.feeds = mkUpdaters {} [ "feeds" ]; init-feed = { type = "app";