shell#flk: consistent quoting

This commit is contained in:
Timothy DeHerrera 2021-02-01 20:10:26 -07:00
parent 4ae99af29d
commit 46a7e7d4ce
No known key found for this signature in database
GPG Key ID: 8985725DB5B0C122

View File

@ -11,27 +11,27 @@ let
}).config.system.build; }).config.system.build;
flk = pkgs.writeShellScriptBin "flk" '' flk = pkgs.writeShellScriptBin "flk" ''
system=$(nix eval --impure --expr "builtins.currentSystem") system="$(nix eval --impure --expr builtins.currentSystem)"
system=${"\${system//\\\"/"}} system="${"\${system//\\\"/"}}"
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo "Usage: $(basename "$0") [ up | iso {host} | install {host} | {host} [switch|boot|test] | home {host} {user} [switch] ]" echo "Usage: $(basename $0) [ up | iso {host} | install {host} | {host} [switch|boot|test] | home {host} {user} [switch] ]"
elif [[ "$1" == "up" ]]; then elif [[ "$1" == "up" ]]; then
mkdir -p $DEVSHELL_ROOT/up mkdir -p "$DEVSHELL_ROOT/up"
hostname=$(hostname) hostname="$(hostname)"
nixos-generate-config --dir $DEVSHELL_ROOT/up/$hostname nixos-generate-config --dir "$DEVSHELL_ROOT/up/$hostname"
echo \ echo \
"{ "{
imports = [ ../up/$hostname/configuration.nix ]; imports = [ ../up/$hostname/configuration.nix ];
}" > $DEVSHELL_ROOT/hosts/up-$hostname.nix }" > "$DEVSHELL_ROOT/hosts/up-$hostname.nix"
git add -f $DEVSHELL_ROOT/up/$hostname git add -f "$DEVSHELL_ROOT/up/$hostname"
git add -f $DEVSHELL_ROOT/hosts/up-$hostname.nix git add -f "$DEVSHELL_ROOT/hosts/up-$hostname.nix"
elif [[ "$1" == "iso" ]]; then elif [[ "$1" == "iso" ]]; then
nix build $DEVSHELL_ROOT#nixosConfigurations.$2.${build}.iso "${"\${@:3}"}" nix build "$DEVSHELL_ROOT#nixosConfigurations.$2.${build}.iso" "${"\${@:3}"}"
elif [[ "$1" == "install" ]]; then elif [[ "$1" == "install" ]]; then
sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${"\${@:3}"}" sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${"\${@:3}"}"
elif [[ "$1" == "home" ]]; then elif [[ "$1" == "home" ]]; then
nix build ./#hmActivationPackages."$system".$2.$3 "${"\${@:4}"}" nix build "./#hmActivationPackages.$system.$2.$3" "${"\${@:4}"}"
if [[ "$4" == "switch" ]]; then if [[ "$4" == "switch" ]]; then
./result/activate && unlink result ./result/activate && unlink result
fi fi