all repos — nixfiles @ d0dfc0b6ce1efc2183c8da14019f7a9f191e43fe

System and user configuration, managed by nix and home-manager

os update: use username to configure default elevation strategy

Alin
commit

d0dfc0b6ce1efc2183c8da14019f7a9f191e43fe

parent

8809fef69439784b64a2a389c23fde940c5a5249

1 file changed, 14 insertions(+), 3 deletions(-)

changed files
M scripts/os/update → scripts/os/update
@@ -14,18 +14,29 @@ echo "please specify target hostname" >&2
return 1 end -set --local targetPlainHostname (string split --fields 1 --max 1 . $target) +set --local user_regex '(?<user>[[:graph:]]+)' +set --local host_regex '(?<host>[[:alnum:]\-]*)' +set --local fqdn_regex "(?<fqdn>$host_regex(?:\.[[:alnum:]\-.]+)?)" +string match --quiet --regex --groups-only "(?:$user_regex@)?$fqdn_regex" $target + set --local actions $argv[2] switch set --local action $actions[1] set --local build_host $_flag_build_host $target -set --local elevation_strategy $_flag_elevation_strategy passwordless + +set --local elevation_strategy $_flag_elevation_strategy ( + if test $user = "root" + echo none + else + echo passwordless + end +) if set --query _flag_remote; or set --query _flag_build_host set --function build_host_arg --build-host $build_host[1] end nh os $action \ - --file . nixosConfigurations.{$targetPlainHostname} \ + --file . nixosConfigurations.{$host} \ $build_host_arg \ --use-substitutes \ --target-host {$target} \