nixos/scripts/option.sh
Malte Tammena 73ffca6989 [flake] Extract devShell scripts
Also start using writeShellApplication.
2022-04-18 18:12:36 +02:00

35 lines
544 B
Bash

function print_help() {
printf "Usage:"
printf " %s [ --home ] HOST OPTION [ USER ]\n" "$0"
exit 1
}
if [ -z "${2+x}" ]; then
print_help
fi
if [ "$1" = "--home" ]; then
useHome=1
host=$2
if [ -z "${3+x}" ]; then
print_help
fi
option=$3
if [ -n "${4+x}" ]; then
user=$4
else
user=$USER
fi
else
useHome=0
host=$1
option=$2
fi
if [ $useHome -eq 1 ]; then
nix eval ".#nixosConfigurations.$host.config.home-manager.users.$user.$option"
else
nix eval ".#nixosConfigurations.$host.config.$option"
fi