From f6094a9583180dfc10fd0c078f156bb2254cdca7 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 45a57cea..2bf2bea3 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 4c454c68..386668bf 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 9a81b0bb..c4714dec 100755 --- a/scripts/Arch/OS/setup.fish +++ b/scripts/Arch/OS/setup.fish @@ -86,7 +86,7 @@ begin true 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 d2eaa84b..c1dc56ed 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");