From 1ce83d0f37240ed4856af33a571e3c72f583ce38 Mon Sep 17 00:00:00 2001 From: Random936 Date: Thu, 31 Oct 2024 13:23:46 -0700 Subject: [PATCH] Updated networking for sampledb and media --- config/media.nix | 17 ++++------------- config/networking.nix | 23 +++++++++++++++++++++++ config/sampledb.nix | 16 ++++------------ hardware/sampledb.nix | 21 +++++++++++---------- install-homemanager.sh | 13 +++++++++++-- 5 files changed, 53 insertions(+), 37 deletions(-) create mode 100644 config/networking.nix diff --git a/config/media.nix b/config/media.nix index ee71011..72ddde8 100644 --- a/config/media.nix +++ b/config/media.nix @@ -3,22 +3,13 @@ imports = [ ../hardware/media.nix ./headless.nix + (import ./networking.nix { + hostname = "sampledb-dev"; + ip_address = "192.168.100.40"; + }) ]; users.users.media = import ./user.nix; - networking.hostName = "r330-media"; - - # Conigure a static IP address. - networking.defaultGateway = "192.168.100.1"; - networking.nameservers = [ "192.168.100.1" ]; - networking.firewall.allowedTCPPorts = [ 80 443 32400 ]; - networking.interfaces.enp6s18.ipv4.addresses = [ - { - address = "192.168.100.40"; - prefixLength = 24; - } - ]; - # Setup drivers for NVIDIA GPU services.xserver = { diff --git a/config/networking.nix b/config/networking.nix new file mode 100644 index 0000000..efe9f9e --- /dev/null +++ b/config/networking.nix @@ -0,0 +1,23 @@ +{ ip_address, hostname }: +{ + # Configure hostname. + networking.hostName = hostname; + + # Conigure a static IP address. + networking.useDHCP = false; + networking.useNetworkd= true; + + networking.defaultGateway = { + address = ip_address; + interface = "enp6s18"; + }; + + networking.nameservers = [ "192.168.100.1" ]; + networking.firewall.allowedTCPPorts = [ 80 443 ]; + networking.interfaces.enp6s18.ipv4.addresses = [ + { + address = ip_address; + prefixLength = 24; + } + ]; +} diff --git a/config/sampledb.nix b/config/sampledb.nix index e295db8..6adf5bd 100644 --- a/config/sampledb.nix +++ b/config/sampledb.nix @@ -3,19 +3,11 @@ imports = [ ../hardware/sampledb.nix ./headless.nix + (import ./networking.nix { + hostname = "sampledb-dev"; + ip_address = "192.168.100.42"; + }) ]; users.users.sampledb = import ./user.nix; - networking.hostName = "sampledb-dev"; - - # Conigure a static IP address. - networking.defaultGateway = "192.168.100.1"; - networking.nameservers = [ "192.168.100.1" ]; - networking.firewall.allowedTCPPorts = [ 80 443 32400 ]; - networking.interfaces.ens18.ipv4.addresses = [ - { - address = "192.168.100.42"; - prefixLength = 24; - } - ]; } diff --git a/hardware/sampledb.nix b/hardware/sampledb.nix index 8c0b765..c0058af 100644 --- a/hardware/sampledb.nix +++ b/hardware/sampledb.nix @@ -8,20 +8,21 @@ [ (modulesPath + "/profiles/qemu-guest.nix") ]; - boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.availableKernelModules = [ "uhci_hcd" "ehci_pci" "ahci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ ]; boot.extraModulePackages = [ ]; - fileSystems."/" = { - device = "/dev/disk/by-uuid/bc530c66-1e41-4c32-9ea0-e9e644677300"; - fsType = "ext4"; - }; + fileSystems."/" = + { device = "/dev/disk/by-uuid/8d1d0298-307f-4d9a-84f8-0434fafa0c55"; + fsType = "ext4"; + }; - fileSystems."/mnt/sampledb" = { - device = "/dev/disk/by-uuid/9d0bc50c-7382-4085-a3ea-5bc0fb52c1f8"; - fsType = "ext4"; - }; + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/4821-12F7"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; swapDevices = [ ]; @@ -30,7 +31,7 @@ # still possible to use this option, but it's recommended to use it in conjunction # with explicit per-interface declarations with `networking.interfaces..useDHCP`. networking.useDHCP = lib.mkDefault true; - # networking.interfaces.ens18.useDHCP = lib.mkDefault true; + # networking.interfaces.enp6s18.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; } diff --git a/install-homemanager.sh b/install-homemanager.sh index 6280112..5065b9c 100755 --- a/install-homemanager.sh +++ b/install-homemanager.sh @@ -1,14 +1,23 @@ #!/usr/bin/env bash -STATE_VERSION="24.05" +STATE_VERSION="$1" if [ $(id -u) != 0 ]; then echo "This script must be run as root." exit fi +if [[ $1 == "" ]]; then + echo "Usage: $0 " + exit +fi + echo "Adding home-manager:${STATE_VERSION} to nix channels..." -nix-channel --add "https://github.com/nix-community/home-manager/archive/release-${STATE_VERSION}.tar.gz" home-manager +if [[ $STATE_VERSION == "unstable" ]]; then + nix-channel --add "https://github.com/nix-community/home-manager/archive/master.tar.gz" home-manager +else + nix-channel --add "https://github.com/nix-community/home-manager/archive/release-${STATE_VERSION}.tar.gz" home-manager +fi echo "Updating nix channels..." nix-channel --update