feat: nh doas wrapper only runs under root for commands that need root

This commit is contained in:
Youwen Wu 2024-12-30 14:36:23 -08:00
parent f3bc3dcf65
commit 71829db15f
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3

View file

@ -26,11 +26,12 @@
# wrapper for nh as it doesn't work with `doas` # wrapper for nh as it doesn't work with `doas`
body = '' body = ''
if count $argv > /dev/null if count $argv > /dev/null
if contains -- os $argv or contains -- clean $argv set subcommand (string join " " $argv)
doas ${pkgs.nh}/bin/nh $argv -R if contains -- $subcommand "os switch" "os test" "os boot" "clean all"
else doas ${pkgs.nh}/bin/nh $argv -R
${pkgs.nh}/bin/nh $argv else
end ${pkgs.nh}/bin/nh $argv
end
else else
${pkgs.nh}/bin/nh ${pkgs.nh}/bin/nh
end end