dotfiles.nix/install.sh

23 lines
519 B
Bash
Raw Normal View History

2021-01-11 03:59:20 +00:00
#!/usr/bin/env bash
2020-01-01 21:12:08 +00:00
2021-05-05 21:55:45 +00:00
dest=$1
machine=$HOSTNAME
if [[ -z "$dest" ]]; then
dest="/etc/nixos/configuration.nix"
fi
2020-01-01 21:12:08 +00:00
2021-01-11 03:59:20 +00:00
if [[ -z "$machine" ]]; then
2021-05-05 21:55:45 +00:00
machine=default-name
2021-01-11 03:59:20 +00:00
fi
2021-05-05 21:55:45 +00:00
if [[ ! -d "machines/$machine" || ! -f "machines/$machine/configuration.nix" ]]; then
2021-01-11 03:59:20 +00:00
echo "$machine is not a known machine"
2021-05-05 21:55:45 +00:00
echo "Run as \`env HOSTNAME=<MACHINE> ./install.sh\` to override."
2021-01-11 03:59:20 +00:00
exit
else
2021-05-05 21:55:45 +00:00
echo "Linking ./machines/$machine/configuration.nix to $dest"
2021-01-11 03:59:20 +00:00
fi
2021-05-05 21:55:45 +00:00
sudo ln -sf $PWD/machines/$machine/configuration.nix $dest