From 71829db15f2739d62efecf782de32765cdbc82b8 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Mon, 30 Dec 2024 14:36:23 -0800 Subject: [PATCH] feat: nh doas wrapper only runs under root for commands that need root --- hm/modules/linux/default.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hm/modules/linux/default.nix b/hm/modules/linux/default.nix index cd2c618..df67904 100755 --- a/hm/modules/linux/default.nix +++ b/hm/modules/linux/default.nix @@ -26,11 +26,12 @@ # wrapper for nh as it doesn't work with `doas` body = '' if count $argv > /dev/null - if contains -- os $argv or contains -- clean $argv - doas ${pkgs.nh}/bin/nh $argv -R - else - ${pkgs.nh}/bin/nh $argv - end + set subcommand (string join " " $argv) + if contains -- $subcommand "os switch" "os test" "os boot" "clean all" + doas ${pkgs.nh}/bin/nh $argv -R + else + ${pkgs.nh}/bin/nh $argv + end else ${pkgs.nh}/bin/nh end