From fee44db81ce4418c85849a83b0573a6c6a06c824 Mon Sep 17 00:00:00 2001 From: pph Date: Tue, 10 Mar 2026 12:59:16 +0100 Subject: [PATCH] let nixy take arguments Signed-off-by: pph --- home/programs/nixy/default.nix | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/home/programs/nixy/default.nix b/home/programs/nixy/default.nix index 51f1c13..d619c87 100644 --- a/home/programs/nixy/default.nix +++ b/home/programs/nixy/default.nix @@ -5,13 +5,19 @@ #- - `nixy` - UI wizard to manage the system. #- - `nixy rebuild` - Rebuild the system. #- - `nixy ...` - ... see the script for more commands. -{ pkgs, config, ... }: -let +{ + pkgs, + config, + ... +}: let configDirectory = config.var.configDirectory; - nixy = pkgs.writeShellScriptBin "nixy" + nixy = + pkgs.writeShellScriptBin "nixy" # bash '' + EXTRA_ARGS="''${@:2}" + function exec() { $@ } @@ -49,11 +55,11 @@ let [[ $1 == "" ]] && ui 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 - cd ${configDirectory} && git add . && sudo nixos-rebuild test --flake + cd ${configDirectory} && git add . && sudo nixos-rebuild test --flake . $EXTRA_ARGS elif [[ $1 == "update" ]];then - cd ${configDirectory} && nix flake update + cd ${configDirectory} && nix flake update $EXTRA_ARGS elif [[ $1 == "gc" ]];then echo "Starting Nix garbage collection..." cd ${configDirectory} && \ @@ -74,4 +80,4 @@ let echo "Unknown argument" fi ''; -in { home.packages = [ nixy ]; } +in {home.packages = [nixy];}