diff --git a/home/hosts/andromache/default.nix b/home/hosts/andromache/default.nix index 9b31b4d..6cb75f8 100644 --- a/home/hosts/andromache/default.nix +++ b/home/hosts/andromache/default.nix @@ -5,9 +5,6 @@ ... }: -let - username = "h"; -in { imports = [ ../../modules @@ -35,8 +32,8 @@ in home = { stateVersion = "25.05"; - inherit username; - homeDirectory = "/home/${username}"; + username = config.host.username; + homeDirectory = "/home/${config.host.username}"; }; xdg.userDirs.createDirectories = false; diff --git a/home/hosts/astyanax/default.nix b/home/hosts/astyanax/default.nix index 6ce75c2..681e54a 100644 --- a/home/hosts/astyanax/default.nix +++ b/home/hosts/astyanax/default.nix @@ -4,9 +4,6 @@ ... }: -let - username = "h"; -in { imports = [ ../../modules @@ -33,8 +30,8 @@ in home = { stateVersion = "25.05"; - inherit username; - homeDirectory = "/home/${username}"; + username = config.host.username; + homeDirectory = "/home/${config.host.username}"; }; xdg.userDirs.createDirectories = false; diff --git a/hosts/andromache/default.nix b/hosts/andromache/default.nix index 973413c..d03f499 100644 --- a/hosts/andromache/default.nix +++ b/hosts/andromache/default.nix @@ -7,8 +7,6 @@ }: let - username = "h"; - hostName = "andromache"; wolInterfaces = import ./wol-interfaces.nix; in { @@ -30,7 +28,7 @@ in ../../modules/bluetooth ../../modules/gaming ../../modules/keyboard - (import ../../modules/networking { inherit hostName; }) + (import ../../modules/networking { hostName = config.host.name; }) ../../modules/users ../../modules/audio ../../modules/localization @@ -45,7 +43,12 @@ in ../../modules/yubikey ]; - home-manager.users.${username} = import ../../home/hosts/andromache { + host = { + username = "h"; + name = "andromache"; + }; + + home-manager.users.${config.host.username} = import ../../home/hosts/andromache { inherit inputs config @@ -54,13 +57,11 @@ in ; }; - networking.hostName = hostName; - - ssh.username = username; + ssh.username = config.host.username; ssh.authorizedHosts = [ "astyanax" ]; - secrets.username = username; - docker.user = username; + secrets.username = config.host.username; + docker.user = config.host.username; nix.settings.secret-key-files = [ config.sops.secrets.nix_signing_key_andromache.path ]; @@ -94,7 +95,7 @@ in my.yubikey = { enable = false; - inherit username; + username = config.host.username; keys = [ { handle = ""; diff --git a/hosts/astyanax/default.nix b/hosts/astyanax/default.nix index 12113bd..9ad1767 100644 --- a/hosts/astyanax/default.nix +++ b/hosts/astyanax/default.nix @@ -6,8 +6,6 @@ ... }: let - username = "h"; - hostName = "astyanax"; wolInterfaces = import ../andromache/wol-interfaces.nix; in { @@ -30,7 +28,7 @@ in ../../modules/backups ../../modules/bluetooth ../../modules/keyboard - (import ../../modules/networking { inherit hostName; }) + (import ../../modules/networking { hostName = config.host.name; }) ../../modules/users ../../modules/localization ../../modules/fonts @@ -42,7 +40,12 @@ in ../../modules/nfc ]; - home-manager.users.${username} = import ../../home/hosts/astyanax { + host = { + username = "h"; + name = "astyanax"; + }; + + home-manager.users.${config.host.username} = import ../../home/hosts/astyanax { inherit inputs config @@ -51,14 +54,12 @@ in ; }; - networking.hostName = hostName; - - ssh.username = username; + ssh.username = config.host.username; ssh.authorizedHosts = [ "andromache" ]; - secrets.username = username; - docker.user = username; - nfc.user = username; + secrets.username = config.host.username; + docker.user = config.host.username; + nfc.user = config.host.username; desktop.ly.enable = true; nix.settings.secret-key-files = [ config.sops.secrets.nix_signing_key_astyanax.path ]; diff --git a/hosts/eetion-02/default.nix b/hosts/eetion-02/default.nix index e359824..bf1ff85 100644 --- a/hosts/eetion-02/default.nix +++ b/hosts/eetion-02/default.nix @@ -1,21 +1,23 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: # Raspberry Pi 3 # See -let - username = "h"; - hostName = "eetion-02"; -in { imports = [ ./hard.nix ../../modules/ssh + ../../modules/common ]; + host = { + username = "h"; + name = "eetion-02"; + }; + ssh = { - inherit username; - publicHostname = "eetion-02"; + username = config.host.username; + publicHostname = config.host.name; authorizedHosts = [ "andromache" "astyanax" @@ -38,7 +40,7 @@ in hardware.enableRedistributableFirmware = true; networking = { - inherit hostName; + hostName = config.host.name; networkmanager.enable = true; firewall = { enable = true; @@ -51,7 +53,7 @@ in users.users = { root.hashedPassword = "!"; - ${username} = { + ${config.host.username} = { isNormalUser = true; extraGroups = [ "wheel" ]; }; diff --git a/hosts/eetion/default.nix b/hosts/eetion/default.nix index 3091498..6ebaad0 100644 --- a/hosts/eetion/default.nix +++ b/hosts/eetion/default.nix @@ -1,22 +1,24 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: # Orange Pi Zero2 H616 # See -let - username = "h"; - hostName = "eetion"; -in { imports = [ ./hard.nix ../../modules/ssh + ../../modules/common # ../../modules/uptime-kuma ]; + host = { + username = "h"; + name = "eetion"; + }; + ssh = { - inherit username; - publicHostname = "eetion"; + username = config.host.username; + publicHostname = config.host.name; authorizedHosts = [ "andromache" "astyanax" @@ -29,7 +31,7 @@ in }; networking = { - inherit hostName; + hostName = config.host.name; networkmanager.enable = true; firewall = { enable = true; @@ -44,7 +46,7 @@ in users.users = { root.hashedPassword = "!"; - ${username} = { + ${config.host.username} = { isNormalUser = true; extraGroups = [ "wheel" ]; }; @@ -57,19 +59,19 @@ in enable = true; passwordFile = "/etc/paperless-admin-pass"; settings = { - PAPERLESS_URL = "http://paperless.eetion"; + PAPERLESS_URL = "http://paperless.${config.host.name}"; }; }; # added (OPNSense) domain override to make this work on LAN # - # host: eetion + # host: # domain: - # ip address: + # ip address: # # host: paperless - # domain: eetion - # ip address: + # domain: + # ip address: nginx = { enable = true; recommendedGzipSettings = true; @@ -78,13 +80,13 @@ in recommendedTlsSettings = true; virtualHosts = { - "eetion" = { + "${config.host.name}" = { default = true; locations."/" = { proxyPass = "http://127.0.0.1:5006"; }; }; - "paperless.eetion" = { + "paperless.${config.host.name}" = { locations."/" = { proxyPass = "http://127.0.0.1:28981"; }; diff --git a/hosts/hecuba/default.nix b/hosts/hecuba/default.nix index 08b9fdb..f0f8e6d 100644 --- a/hosts/hecuba/default.nix +++ b/hosts/hecuba/default.nix @@ -1,15 +1,12 @@ { inputs, pkgs, + config, ... }: # Also see -let - username = "username"; - hostName = "hecuba"; -in { imports = [ inputs.disko.nixosModules.disko @@ -19,9 +16,14 @@ in ../../modules/docker ]; - networking.hostName = hostName; + host = { + username = "username"; + name = "hecuba"; + }; + + networking.hostName = config.host.name; ssh = { - inherit username; + username = config.host.username; publicHostname = "server.hektormisplon.xyz"; authorizedHosts = [ "andromache" @@ -29,7 +31,7 @@ in ]; }; - docker.user = username; + docker.user = config.host.username; fileSystems."/" = { device = "/dev/disk/by-label/nixos"; @@ -50,7 +52,7 @@ in users.users = { root.hashedPassword = "!"; - username = { + ${config.host.username} = { isNormalUser = true; extraGroups = [ "wheel" ]; }; diff --git a/hosts/vm/default.nix b/hosts/vm/default.nix index f23db79..41449df 100644 --- a/hosts/vm/default.nix +++ b/hosts/vm/default.nix @@ -5,10 +5,6 @@ pkgs, ... }: -let - username = "h"; - hostName = "vm"; -in { imports = [ inputs.disko.nixosModules.disko @@ -18,7 +14,7 @@ in ./disk.nix ../../modules/boot/bootloader.nix ../../modules/keyboard - (import ../../modules/networking { inherit hostName; }) + (import ../../modules/networking { hostName = config.host.name; }) ../../modules/users ../../modules/audio ../../modules/localization @@ -31,14 +27,19 @@ in }) ]; - home-manager.users.${username} = import ../../home/hosts/vm { + host = { + username = "h"; + name = "vm"; + }; + + home-manager.users.${config.host.username} = import ../../home/hosts/vm { inherit inputs config pkgs; }; - networking.hostName = hostName; - ssh.username = username; + networking.hostName = config.host.name; + ssh.username = config.host.username; - secrets.username = username; + secrets.username = config.host.username; disko = { devices.disk.main = { diff --git a/modules/common/default.nix b/modules/common/default.nix index dd9c368..eb4c98e 100644 --- a/modules/common/default.nix +++ b/modules/common/default.nix @@ -12,6 +12,7 @@ in { imports = [ inputs.home-manager.nixosModules.default + ./host.nix ]; options.nixpkgs.allowedUnfree = lib.mkOption { diff --git a/modules/common/host.nix b/modules/common/host.nix new file mode 100644 index 0000000..515319c --- /dev/null +++ b/modules/common/host.nix @@ -0,0 +1,13 @@ +{ lib, ... }: + +{ + options.host = { + username = lib.mkOption { + type = lib.types.str; + }; + + name = lib.mkOption { + type = lib.types.str; + }; + }; +}