From da4319add11548d4e2f92f0082bfc21ae1a8875e Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sun, 22 Sep 2024 19:21:27 +0200 Subject: [PATCH] flake: set hostname in mkSystem --- hosts/default.nix | 4 ++++ modules/system/os/networking/module.nix | 3 +-- parts/lib/builders.nix | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hosts/default.nix b/hosts/default.nix index 1724c7d..d2dd2e5 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -28,12 +28,16 @@ in { temperance = mkSystem { inherit withSystem; system = "x86_64-linux"; + + hostname = "temperance"; modules = mkModulesFor "temperance"; }; hermit = mkSystem { inherit withSystem; system = "x86_64-linux"; + + hostname = "hermit"; modules = mkModulesFor "hermit"; }; }; diff --git a/modules/system/os/networking/module.nix b/modules/system/os/networking/module.nix index 0723321..fd4ca78 100644 --- a/modules/system/os/networking/module.nix +++ b/modules/system/os/networking/module.nix @@ -1,11 +1,10 @@ {config, ...}: let - inherit (config.modules.other.system) hostname username; + inherit (config.modules.other.system) username; in { imports = [ ./networkmanager.nix ]; networking = { - hostName = hostname; enableIPv6 = true; nameservers = [ # quad9 DNS diff --git a/parts/lib/builders.nix b/parts/lib/builders.nix index b422084..7cdb9eb 100644 --- a/parts/lib/builders.nix +++ b/parts/lib/builders.nix @@ -10,6 +10,7 @@ mkSystem = { withSystem, system, + hostname, ... } @ args: withSystem system ( @@ -30,9 +31,9 @@ (args.specialArgs or {}); modules = concatLists [ # This is used to pre-emptively set the hostPlatform for nixpkgs. - # We need a singleton here since we concatenate lists, and a singleton - # generates a list with a single element. + # Also, we set the system hostname here. (singleton { + networking.hostName = args.hostname; nixpkgs.hostPlatform = mkDefault args.system; })