add nixos config script

nix-components
pegasust 2022-11-29 19:37:28 -07:00
parent cf4b4cf1e6
commit 9ec0aa5e84
3 changed files with 31 additions and 26 deletions

View File

@ -1,22 +0,0 @@
#!/usr/bin/env sh
set -xv
# Where is this script located
SCRIPT_DIR=$(realpath $(dirname $0))
echo "SCRIPT_DIR: ${SCRIPT_DIR}"
# Where should the symlink for this repo live in the system
CONFIG_DIR="~/.dotfiles"
# Create a symlink for this directory to ~/.dotfiles
# if it already exists, error out
if [ -L ${CONFIG_DIR} ] && [ $(readlink -f ${CONFIG_DIR}) != ${SCRIPT_DIR} ]; then
echo "ERR: ${SCRIPT_DIR}/apply-system.sh: ${CONFIG_DIR} exists and not symlink to ${SCRIPT_DIR}"
exit 1
fi
ln -s -T ${SCRIPT_DIR} ${CONFIG_DIR}
# $PWD to ~/.dotfiles
pushd ~/.dotfiles
sudo nixos-rebuild switch --flake .#nixos
popd

25
scripts/config-sysnix.sh Executable file
View File

@ -0,0 +1,25 @@
#!/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}"
SYSNIX_DIR="${SCRIPT_DIR}/../system-nix"
# Copy hardware-configuration of existing machine onto our version control
HARDWARE_CONF="${SYSNIX_DIR}/profiles/${HOSTNAME}/hardware-configuration.nix"
if [ ! -f ${HARDWARE_CONF} ];
sudo cp /etc/nixos/hardware-configuration.nix ${HARDWARE_CONF}
fi
echo "Apply nixos-rebuild"
sudo nixos-rebuild switch --flake "${SYSNIX_DIR}#${HOSTNAME}"

View File

@ -5,7 +5,8 @@
{ {
imports = imports =
[ (modulesPath + "/profiles/qemu-guest.nix") [
(modulesPath + "/profiles/qemu-guest.nix")
]; ];
boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ]; boot.initrd.availableKernelModules = [ "virtio_pci" "virtio_scsi" "ahci" "sd_mod" ];
@ -23,9 +24,11 @@
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems = { fileSystems = {
"/" = { device = "/dev/sda"; "/" = {
device = "/dev/sda";
fsType = "ext4"; fsType = "ext4";
}; };
# Assume Linode volume "gitea" exists, mount it to '/gitea"'
"/gitea" = { "/gitea" = {
device = "/dev/disk/by-id/scsi-0Linode_Volume_gitea"; device = "/dev/disk/by-id/scsi-0Linode_Volume_gitea";
fsType = "ext4"; fsType = "ext4";
@ -33,8 +36,7 @@
}; };
swapDevices = swapDevices =
[ { device = "/dev/sdb"; } [{ device = "/dev/sdb"; }];
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's