This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.update-pkgs: evaluate all packages in one flake snapshot

+51 -42
+1 -42
tools/update-pkgs/flake-module.nix
··· 22 22 root=$(git rev-parse --show-toplevel) 23 23 cd "$root" 24 24 host=$(nix eval --raw --impure --expr builtins.currentSystem) 25 - # Only update scripts written for this flake: nix-update with --flake, 26 - # or a script inside this flake. Packages wrapping nixpkgs or 27 - # flake-input packages otherwise inherit an updateScript meant for 28 - # that checkout; those follow flake.lock instead. 29 - src=$(nix flake metadata --json . | jq -r .path) 30 - 31 - # attr -> {cmd, pname, version, name}. Per package tryEval: one 32 - # package refusing to evaluate on this system must not hide the rest. 33 - scripts() { 34 - nix eval --json ".#packages.$1" --apply " 35 - ps: builtins.mapAttrs (n: p: 36 - let 37 - r = builtins.tryEval ( 38 - let 39 - u = p.passthru.updateScript or null; 40 - isOurs = s: s == \"--flake\" 41 - || builtins.substring 0 (builtins.stringLength \"$src/\") s == \"$src/\"; 42 - c = 43 - if builtins.isList u then u 44 - else if builtins.isAttrs u && u ? command then 45 - (if builtins.isList u.command then u.command else [ u.command ]) 46 - else [ u ]; 47 - v = { 48 - cmd = map toString c; 49 - pname = p.pname or n; 50 - version = p.version or \"\"; 51 - name = p.name or n; 52 - }; 53 - in 54 - if u == null || !(builtins.any isOurs v.cmd) then null else builtins.deepSeq v v 55 - ); 56 - in 57 - if r.success then r.value else null) ps" 58 - } 59 - host_scripts=$(scripts "$host") 60 - linux_scripts='{}' 61 - if [ "$host" != x86_64-linux ]; then 62 - linux_scripts=$(scripts x86_64-linux) 63 - fi 64 - # host entries win over linux ones 65 - all=$(jq -s '.[1] + .[0] | with_entries(select(.value != null))' \ 66 - <<<"$host_scripts $linux_scripts") 25 + all=$(nix eval --json --impure --expr "import ${./scripts.nix} { flake = \"$root\"; host = \"$host\"; }") 67 26 68 27 if [ "''${1:-}" = --list ]; then 69 28 jq -r 'to_entries[] | "\(.key)\t\(.value.cmd | join(" "))"' <<<"$all"
+50
tools/update-pkgs/scripts.nix
··· 1 + # attr -> { cmd, pname, version, name } for every flake package with an 2 + # updateScript written for this flake. One getFlake call, so the source path 3 + # and both package sets come from the same snapshot of the (possibly dirty) 4 + # tree. Host entries win; x86_64-linux fills in linux-only packages. 5 + { flake, host }: 6 + let 7 + f = builtins.getFlake flake; 8 + src = toString f.outPath + "/"; 9 + 10 + # Only scripts written for this flake: nix-update with --flake, or a script 11 + # inside this flake. Packages wrapping nixpkgs or flake-input packages 12 + # otherwise inherit an updateScript meant for that checkout; those follow 13 + # flake.lock instead. 14 + isOurs = s: s == "--flake" || builtins.substring 0 (builtins.stringLength src) s == src; 15 + 16 + entry = 17 + n: p: 18 + let 19 + u = p.passthru.updateScript or null; 20 + c = 21 + if builtins.isList u then 22 + u 23 + else if builtins.isAttrs u && u ? command then 24 + (if builtins.isList u.command then u.command else [ u.command ]) 25 + else 26 + [ u ]; 27 + v = { 28 + cmd = map toString c; 29 + pname = p.pname or n; 30 + version = p.version or ""; 31 + name = p.name or n; 32 + }; 33 + in 34 + if u == null || !(builtins.any isOurs v.cmd) then null else builtins.deepSeq v v; 35 + 36 + # Per package tryEval: one package refusing to evaluate on this system must 37 + # not hide the rest. 38 + scripts = 39 + system: 40 + builtins.mapAttrs ( 41 + n: p: 42 + let 43 + r = builtins.tryEval (entry n p); 44 + in 45 + if r.success then r.value else null 46 + ) (f.packages.${system} or { }); 47 + 48 + merged = (if host == "x86_64-linux" then { } else scripts "x86_64-linux") // scripts host; 49 + in 50 + builtins.removeAttrs merged (builtins.filter (n: merged.${n} == null) (builtins.attrNames merged))