let nixy take arguments

Signed-off-by: pph <pph@pph.pph>
This commit is contained in:
pph
2026-03-10 12:59:16 +01:00
parent 214095c02a
commit fee44db81c

View File

@@ -5,13 +5,19 @@
#- - `nixy` - UI wizard to manage the system. #- - `nixy` - UI wizard to manage the system.
#- - `nixy rebuild` - Rebuild the system. #- - `nixy rebuild` - Rebuild the system.
#- - `nixy ...` - ... see the script for more commands. #- - `nixy ...` - ... see the script for more commands.
{ pkgs, config, ... }: {
let pkgs,
config,
...
}: let
configDirectory = config.var.configDirectory; configDirectory = config.var.configDirectory;
nixy = pkgs.writeShellScriptBin "nixy" nixy =
pkgs.writeShellScriptBin "nixy"
# bash # bash
'' ''
EXTRA_ARGS="''${@:2}"
function exec() { function exec() {
$@ $@
} }
@@ -49,11 +55,11 @@ let
[[ $1 == "" ]] && ui [[ $1 == "" ]] && ui
if [[ $1 == "rebuild" ]];then if [[ $1 == "rebuild" ]];then
cd ${configDirectory} && git add . && sudo nixos-rebuild switch --flake cd ${configDirectory} && git add . && sudo nixos-rebuild switch --flake . $EXTRA_ARGS
elif [[ $1 == "test" ]];then elif [[ $1 == "test" ]];then
cd ${configDirectory} && git add . && sudo nixos-rebuild test --flake cd ${configDirectory} && git add . && sudo nixos-rebuild test --flake . $EXTRA_ARGS
elif [[ $1 == "update" ]];then elif [[ $1 == "update" ]];then
cd ${configDirectory} && nix flake update cd ${configDirectory} && nix flake update $EXTRA_ARGS
elif [[ $1 == "gc" ]];then elif [[ $1 == "gc" ]];then
echo "Starting Nix garbage collection..." echo "Starting Nix garbage collection..."
cd ${configDirectory} && \ cd ${configDirectory} && \
@@ -74,4 +80,4 @@ let
echo "Unknown argument" echo "Unknown argument"
fi fi
''; '';
in { home.packages = [ nixy ]; } in {home.packages = [nixy];}