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,7 +26,8 @@
# 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)
if contains -- $subcommand "os switch" "os test" "os boot" "clean all"
doas ${pkgs.nh}/bin/nh $argv -R doas ${pkgs.nh}/bin/nh $argv -R
else else
${pkgs.nh}/bin/nh $argv ${pkgs.nh}/bin/nh $argv