#! /usr/bin/env dash # shellcheck disable=SC2086 # shellcheck source=/dev/null . %SHELL_LIBRARY_PATH export LIB_TEMP_DIR_FOR_SCRIPT="$(mktemp -d)" msg "Select a host-config:" hosts=$(mktmp); host=""; awk -F "." '/inputs.nixpkgs.lib.nixosSystem/{print $1}' "$(tmp 'curl https://git.sils.li/ene/nixos-config/raw/branch/prime/flake/nixosConfigurations/default.nix 2> /dev/null')" | awk '{print $1}' > $hosts; while ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; do i=1; while read -r ho ; do printf "%4s) %s \n" "$i" "$ho"; i=$((i+1)); done < "$hosts" printf "%4s) Exit\n" "q" readp "Enter a option: " host [ "$host" = "q" ] && exit 1 host=$(awk -v i="$host" '{if (NR==i) {print $0}}' "$hosts"); if ! grep "$host" "$hosts" > /dev/null || [ "$(printf "%s" "$host" | wc -c)" -eq 0 ]; then warning "No host selected. Select a host to continue.\n" fi done nixos-install --flake git+https://git.sils.li/ene/nixos-config#${host} --no-root-passwd # clone the git config git clone https://git.sils.li/ene/nixos-config /mnt/etc/nixos # setup persistent home dir mkdir -p /srv/home chmod 777 /srv/home if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi