2022-11-30 02:37:28 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
set -xv
|
|
|
|
|
|
|
|
HOSTNAME=${1}
|
|
|
|
|
|
|
|
if [ -z $HOSTNAME ]; then
|
|
|
|
echo "Missing hostname as first param" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Where is this script located
|
|
|
|
SCRIPT_DIR=$(realpath $(dirname $0))
|
|
|
|
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
|
|
|
|
|
2022-12-03 00:01:48 +00:00
|
|
|
SYSNIX_DIR="${SCRIPT_DIR}/../nix-conf/system"
|
2022-11-30 02:37:28 +00:00
|
|
|
|
|
|
|
# Copy hardware-configuration of existing machine onto our version control
|
2022-11-30 02:58:57 +00:00
|
|
|
SYSNIX_PROF="${SYSNIX_DIR}/profiles/${HOSTNAME}"
|
|
|
|
HARDWARE_CONF="${SYSNIX_PROF}/hardware-configuration.nix"
|
|
|
|
if [ ! -f "${HARDWARE_CONF}" ]; then;
|
|
|
|
mkdir "$SYSNIX_PROF"
|
2022-11-30 02:37:28 +00:00
|
|
|
sudo cp /etc/nixos/hardware-configuration.nix ${HARDWARE_CONF}
|
|
|
|
fi
|
2022-11-30 02:58:57 +00:00
|
|
|
git add "${HARDWARE_CONF}"
|
2022-11-30 02:37:28 +00:00
|
|
|
|
|
|
|
echo "Apply nixos-rebuild"
|
|
|
|
sudo nixos-rebuild switch --flake "${SYSNIX_DIR}#${HOSTNAME}"
|
|
|
|
|