refactor: simplify hosts files

This commit is contained in:
2026-01-17 19:37:05 +01:00
parent 35fd4e61e2
commit bb6a380599
6 changed files with 61 additions and 85 deletions

View File

@@ -1 +0,0 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzP1PjIDb1tN9nhPOK88HYDtTNk9SN9ZpEem2id49Fa h@astyanax

View File

@@ -6,41 +6,44 @@
pkgs, pkgs,
... ...
}: }:
let let
username = "h"; username = "h";
hostName = "andromache";
wolInterfaces = import ./wol-interfaces.nix; wolInterfaces = import ./wol-interfaces.nix;
in in
{ {
imports = [ imports = [
../../modules/common ../../modules/common
inputs.disko.nixosModules.disko
inputs.sops-nix.nixosModules.sops
inputs.home-manager.nixosModules.default
./hard.nix ./hard.nix
inputs.sops-nix.nixosModules.sops
../../modules/boot/bootloader.nix ../../modules/boot/bootloader.nix
(import ../../modules/disko/zfs-encrypted-root.nix { (import ../../modules/disko/zfs-encrypted-root.nix {
inherit lib config;
device = "/dev/nvme1n1"; device = "/dev/nvme1n1";
inherit lib;
inherit config;
}) })
../../modules/desktops/niri ../../modules/desktops/niri
../../modules/bluetooth ../../modules/bluetooth
../../modules/keyboard ../../modules/keyboard
(import ../../modules/networking { hostName = "andromache"; }) (import ../../modules/networking { hostName = hostName; })
../../modules/users ../../modules/users
../../modules/audio ../../modules/audio
../../modules/localization ../../modules/localization
../../modules/fonts ../../modules/fonts
../../modules/ssh/hardened-openssh.nix ../../modules/ssh/hardened-openssh.nix
(import ../../modules/secrets { (import ../../modules/secrets {
inherit lib; inherit lib inputs config;
inherit inputs;
inherit config;
}) })
../../modules/docker ../../modules/docker
]; ];
home-manager.users.${username} = import ../../home/hosts/andromache {
inherit inputs config pkgs lib;
};
networking.hostName = hostName;
ssh.username = username;
ssh.authorizedHosts = [ "astyanax" ];
secrets.username = username; secrets.username = username;
docker.user = username; docker.user = username;
@@ -79,22 +82,6 @@ in
environment.systemPackages = [ inputs.nvim.packages.x86_64-linux.nvim ]; environment.systemPackages = [ inputs.nvim.packages.x86_64-linux.nvim ];
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs outputs;
};
users.${username} = import ../../home/hosts/andromache {
inherit lib;
inherit inputs;
inherit config;
inherit pkgs;
};
};
ssh.authorizedHosts = [ "astyanax" ];
services.xserver = { services.xserver = {
videoDrivers = [ "nvidia" ]; videoDrivers = [ "nvidia" ];
}; };

View File

@@ -6,7 +6,6 @@
pkgs, pkgs,
... ...
}: }:
let let
username = "h"; username = "h";
hostName = "astyanax"; hostName = "astyanax";
@@ -15,15 +14,12 @@ in
{ {
imports = [ imports = [
../../modules/common ../../modules/common
# inputs.nixos-hardware.nixosModules.lenovo-thinkpad-e14-intel
inputs.disko.nixosModules.disko
inputs.sops-nix.nixosModules.sops
inputs.home-manager.nixosModules.default
./hard.nix ./hard.nix
# inputs.nixos-hardware.nixosModules.lenovo-thinkpad-e14-intel
inputs.sops-nix.nixosModules.sops
../../modules/boot/bootloader.nix ../../modules/boot/bootloader.nix
(import ../../modules/disko/zfs-encrypted-root.nix { (import ../../modules/disko/zfs-encrypted-root.nix {
inherit lib; inherit lib config;
inherit config;
device = "/dev/nvme0n1"; device = "/dev/nvme0n1";
}) })
../../modules/desktops/niri ../../modules/desktops/niri
@@ -36,13 +32,18 @@ in
../../modules/fonts ../../modules/fonts
../../modules/ssh/hardened-openssh.nix ../../modules/ssh/hardened-openssh.nix
(import ../../modules/secrets { (import ../../modules/secrets {
inherit lib; inherit lib inputs config username;
inherit inputs;
inherit config;
inherit username;
}) })
]; ];
home-manager.users.${username} = import ../../home/hosts/astyanax {
inherit inputs config pkgs lib;
};
networking.hostName = hostName;
ssh.username = username;
ssh.authorizedHosts = [ "andromache" ];
hardware = { hardware = {
cpu.intel.updateMicrocode = true; cpu.intel.updateMicrocode = true;
# https://wiki.nixos.org/wiki/Intel_Graphics # https://wiki.nixos.org/wiki/Intel_Graphics
@@ -73,26 +74,11 @@ in
}) })
]; ];
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs outputs;
};
users.${username} = import ../../home/hosts/astyanax {
inherit inputs;
inherit config;
inherit pkgs;
};
};
networking = { networking = {
# TODO: generate unique hostId on actual host with: head -c 8 /etc/machine-id # TODO: generate unique hostId on actual host with: head -c 8 /etc/machine-id
hostId = "80eef97e"; hostId = "80eef97e";
}; };
ssh.authorizedHosts = [ "andromache" ];
services = { services = {
fwupd.enable = true; fwupd.enable = true;
openssh = { openssh = {

View File

@@ -9,13 +9,21 @@
# Also see <https://wiki.nixos.org/wiki/Install_NixOS_on_Hetzner_Cloud> # Also see <https://wiki.nixos.org/wiki/Install_NixOS_on_Hetzner_Cloud>
let
username = "username";
hostName = "hecuba";
in
{ {
imports = [ imports = [
./hard.nix
../../modules/common ../../modules/common
./hard.nix
../../modules/ssh/hardened-openssh.nix ../../modules/ssh/hardened-openssh.nix
]; ];
networking.hostName = hostName;
ssh.username = username;
ssh.authorizedHosts = [ "andromache" ];
fileSystems."/" = { fileSystems."/" = {
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; fsType = "ext4";
@@ -41,16 +49,9 @@
}; };
}; };
ssh = {
username = "username";
authorizedHosts = [ "andromache" ];
};
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;
networking = { networking.firewall.enable = true;
firewall.enable = true;
};
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
vim vim
@@ -66,6 +67,4 @@
enable = true; enable = true;
harden = true; harden = true;
}; };
networking.hostName = "hecuba";
} }

View File

@@ -6,21 +6,19 @@
pkgs, pkgs,
... ...
}: }:
let let
username = "h"; username = "h";
hostName = "vm";
in in
{ {
imports = [ imports = [
../../modules/common ../../modules/common
inputs.disko.nixosModules.disko
inputs.sops-nix.nixosModules.sops
inputs.home-manager.nixosModules.default
./hard.nix ./hard.nix
inputs.sops-nix.nixosModules.sops
./disk.nix ./disk.nix
../../modules/boot/bootloader.nix ../../modules/boot/bootloader.nix
../../modules/keyboard ../../modules/keyboard
(import ../../modules/networking { hostName = "vm"; }) (import ../../modules/networking { hostName = hostName; })
../../modules/users ../../modules/users
../../modules/audio ../../modules/audio
../../modules/localization ../../modules/localization
@@ -28,12 +26,17 @@ in
../../modules/fonts ../../modules/fonts
../../modules/ssh/hardened-openssh.nix ../../modules/ssh/hardened-openssh.nix
(import ../../modules/secrets { (import ../../modules/secrets {
inherit lib; inherit lib inputs config;
inherit inputs;
inherit config;
}) })
]; ];
home-manager.users.${username} = import ../../home/hosts/vm {
inherit inputs config pkgs;
};
networking.hostName = hostName;
ssh.username = username;
secrets.username = username; secrets.username = username;
environment.systemPackages = [ inputs.nvim.packages.x86_64-linux.nvim ]; environment.systemPackages = [ inputs.nvim.packages.x86_64-linux.nvim ];
@@ -56,19 +59,6 @@ in
}; };
}; };
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs outputs;
};
users.${username} = import ../../home/hosts/vm {
inherit inputs;
inherit config;
inherit pkgs;
};
};
services.qemuGuest.enable = true; services.qemuGuest.enable = true;
services.spice-vdagentd.enable = true; services.spice-vdagentd.enable = true;

View File

@@ -1,4 +1,11 @@
{ inputs, outputs, ... }:
{ {
imports = [
inputs.disko.nixosModules.disko
inputs.home-manager.nixosModules.default
];
system.stateVersion = "25.05"; system.stateVersion = "25.05";
nix.settings.experimental-features = [ nix.settings.experimental-features = [
@@ -7,4 +14,12 @@
]; ];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs outputs;
};
};
} }