From 8584eef0ecfb4cad3a1e123291c45cc86dd87b5a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 19 Sep 2024 23:45:19 +0200 Subject: [PATCH] Allow configuring the hostname --- lib/modules/valhalla.nix | 6 ++++++ profiles/machines/manuel/DerGeret/config.nix | 6 +++++- profiles/machines/manuel/ManuSurface/config.nix | 5 ++++- scripts/Arch/OS/setup.fish | 2 +- scripts/Windows/OS/Setup.ps1 | 3 +-- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/modules/valhalla.nix b/lib/modules/valhalla.nix index 66b52c14..316d94d0 100644 --- a/lib/modules/valhalla.nix +++ b/lib/modules/valhalla.nix @@ -35,6 +35,12 @@ }; }; + hostname = mkOption { + type = types.str; + description = "The hostname of the system."; + default = "valhalla"; + }; + setupUser = { name = mkOption { type = types.str; diff --git a/profiles/machines/manuel/DerGeret/config.nix b/profiles/machines/manuel/DerGeret/config.nix index 087c65ad..3f67fcb6 100644 --- a/profiles/machines/manuel/DerGeret/config.nix +++ b/profiles/machines/manuel/DerGeret/config.nix @@ -1,16 +1,20 @@ -{ ... }: { +{ lib, ... }: { imports = [ ../defaults.nix ]; config = { valhalla = { + hostname = lib.mkDefault "der-geret"; + windows = { dualboot = { enable = true; linuxPercentage = 70; # better safe than sorry }; + hostname = "DerGeret"; + users.manuel = { microsoftAccount = true; groups = ["Administrators"]; diff --git a/profiles/machines/manuel/ManuSurface/config.nix b/profiles/machines/manuel/ManuSurface/config.nix index 937f3076..abce2810 100644 --- a/profiles/machines/manuel/ManuSurface/config.nix +++ b/profiles/machines/manuel/ManuSurface/config.nix @@ -4,6 +4,9 @@ ]; config = { - valhalla.partition.os.deviceName = "nvme0n1"; + valhalla = { + hostname = "manu-surface"; + partition.os.deviceName = "nvme0n1"; + }; }; } diff --git a/scripts/Arch/OS/setup.fish b/scripts/Arch/OS/setup.fish index 628cd47c..8b3cc5f9 100755 --- a/scripts/Arch/OS/setup.fish +++ b/scripts/Arch/OS/setup.fish @@ -78,7 +78,7 @@ begin echo "KEYMAP=$keyMap" | arch-chroot "$mountDir" tee /etc/vconsole.conf > /dev/null end - and echo "$ARCH_HOSTNAME" | arch-chroot "$mountDir" tee /etc/hostname > /dev/null + and echo (getConfig valhalla.hostname) | arch-chroot "$mountDir" tee /etc/hostname > /dev/null and arch-chroot "$mountDir" mkinitcpio -P and runHook installDrivers "Installing drivers..." || true diff --git a/scripts/Windows/OS/Setup.ps1 b/scripts/Windows/OS/Setup.ps1 index 69b653c9..ff0ec8a8 100644 --- a/scripts/Windows/OS/Setup.ps1 +++ b/scripts/Windows/OS/Setup.ps1 @@ -8,7 +8,6 @@ function Start-Setup { $Global:InformationPreference = "Continue"; $Global:ErrorActionPreference = "Inquire"; $env:CONFIG_NAME ??= $ConfigurationName; - $null = $env:WIN_COMPUTER_NAME; $null = $env:SETUP_SCRIPT_NAME ??= "$PSScriptRoot/Install.ps1"; $env:WSLENV = "CONFIG_NAME"; @@ -218,7 +217,7 @@ function Start-Setup { # Adjust unattended settings $computerName = (Get-Component (Get-PassSettings "specialize") "Microsoft-Windows-Shell-Setup").SelectSingleNode("./ua:ComputerName", $namespace); - $computerName.InnerText = "$env:WIN_COMPUTER_NAME"; + $computerName.InnerText = $valhallaConfig.hostname; # Execute corresponding installer script after startup $oobeSettings = (Get-Component (Get-PassSettings "oobeSystem") "Microsoft-Windows-Shell-Setup");