refactor: add config.host option for host variables
This commit is contained in:
@@ -5,9 +5,6 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
|
||||||
username = "h";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../modules
|
../../modules
|
||||||
@@ -35,8 +32,8 @@ in
|
|||||||
|
|
||||||
home = {
|
home = {
|
||||||
stateVersion = "25.05";
|
stateVersion = "25.05";
|
||||||
inherit username;
|
username = config.host.username;
|
||||||
homeDirectory = "/home/${username}";
|
homeDirectory = "/home/${config.host.username}";
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg.userDirs.createDirectories = false;
|
xdg.userDirs.createDirectories = false;
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
|
||||||
username = "h";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../modules
|
../../modules
|
||||||
@@ -33,8 +30,8 @@ in
|
|||||||
|
|
||||||
home = {
|
home = {
|
||||||
stateVersion = "25.05";
|
stateVersion = "25.05";
|
||||||
inherit username;
|
username = config.host.username;
|
||||||
homeDirectory = "/home/${username}";
|
homeDirectory = "/home/${config.host.username}";
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg.userDirs.createDirectories = false;
|
xdg.userDirs.createDirectories = false;
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
username = "h";
|
|
||||||
hostName = "andromache";
|
|
||||||
wolInterfaces = import ./wol-interfaces.nix;
|
wolInterfaces = import ./wol-interfaces.nix;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -30,7 +28,7 @@ in
|
|||||||
../../modules/bluetooth
|
../../modules/bluetooth
|
||||||
../../modules/gaming
|
../../modules/gaming
|
||||||
../../modules/keyboard
|
../../modules/keyboard
|
||||||
(import ../../modules/networking { inherit hostName; })
|
(import ../../modules/networking { hostName = config.host.name; })
|
||||||
../../modules/users
|
../../modules/users
|
||||||
../../modules/audio
|
../../modules/audio
|
||||||
../../modules/localization
|
../../modules/localization
|
||||||
@@ -45,7 +43,12 @@ in
|
|||||||
../../modules/yubikey
|
../../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
|
inherit
|
||||||
inputs
|
inputs
|
||||||
config
|
config
|
||||||
@@ -54,13 +57,11 @@ in
|
|||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.hostName = hostName;
|
ssh.username = config.host.username;
|
||||||
|
|
||||||
ssh.username = username;
|
|
||||||
ssh.authorizedHosts = [ "astyanax" ];
|
ssh.authorizedHosts = [ "astyanax" ];
|
||||||
|
|
||||||
secrets.username = username;
|
secrets.username = config.host.username;
|
||||||
docker.user = username;
|
docker.user = config.host.username;
|
||||||
|
|
||||||
nix.settings.secret-key-files = [ config.sops.secrets.nix_signing_key_andromache.path ];
|
nix.settings.secret-key-files = [ config.sops.secrets.nix_signing_key_andromache.path ];
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ in
|
|||||||
|
|
||||||
my.yubikey = {
|
my.yubikey = {
|
||||||
enable = false;
|
enable = false;
|
||||||
inherit username;
|
username = config.host.username;
|
||||||
keys = [
|
keys = [
|
||||||
{
|
{
|
||||||
handle = "<KeyHandle1>";
|
handle = "<KeyHandle1>";
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
username = "h";
|
|
||||||
hostName = "astyanax";
|
|
||||||
wolInterfaces = import ../andromache/wol-interfaces.nix;
|
wolInterfaces = import ../andromache/wol-interfaces.nix;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -30,7 +28,7 @@ in
|
|||||||
../../modules/backups
|
../../modules/backups
|
||||||
../../modules/bluetooth
|
../../modules/bluetooth
|
||||||
../../modules/keyboard
|
../../modules/keyboard
|
||||||
(import ../../modules/networking { inherit hostName; })
|
(import ../../modules/networking { hostName = config.host.name; })
|
||||||
../../modules/users
|
../../modules/users
|
||||||
../../modules/localization
|
../../modules/localization
|
||||||
../../modules/fonts
|
../../modules/fonts
|
||||||
@@ -42,7 +40,12 @@ in
|
|||||||
../../modules/nfc
|
../../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
|
inherit
|
||||||
inputs
|
inputs
|
||||||
config
|
config
|
||||||
@@ -51,14 +54,12 @@ in
|
|||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.hostName = hostName;
|
ssh.username = config.host.username;
|
||||||
|
|
||||||
ssh.username = username;
|
|
||||||
ssh.authorizedHosts = [ "andromache" ];
|
ssh.authorizedHosts = [ "andromache" ];
|
||||||
|
|
||||||
secrets.username = username;
|
secrets.username = config.host.username;
|
||||||
docker.user = username;
|
docker.user = config.host.username;
|
||||||
nfc.user = username;
|
nfc.user = config.host.username;
|
||||||
desktop.ly.enable = true;
|
desktop.ly.enable = true;
|
||||||
|
|
||||||
nix.settings.secret-key-files = [ config.sops.secrets.nix_signing_key_astyanax.path ];
|
nix.settings.secret-key-files = [ config.sops.secrets.nix_signing_key_astyanax.path ];
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, config, ... }:
|
||||||
|
|
||||||
# Raspberry Pi 3
|
# Raspberry Pi 3
|
||||||
# See <https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_3>
|
# See <https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_3>
|
||||||
|
|
||||||
let
|
|
||||||
username = "h";
|
|
||||||
hostName = "eetion-02";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./hard.nix
|
./hard.nix
|
||||||
../../modules/ssh
|
../../modules/ssh
|
||||||
|
../../modules/common
|
||||||
];
|
];
|
||||||
|
|
||||||
|
host = {
|
||||||
|
username = "h";
|
||||||
|
name = "eetion-02";
|
||||||
|
};
|
||||||
|
|
||||||
ssh = {
|
ssh = {
|
||||||
inherit username;
|
username = config.host.username;
|
||||||
publicHostname = "eetion-02";
|
publicHostname = config.host.name;
|
||||||
authorizedHosts = [
|
authorizedHosts = [
|
||||||
"andromache"
|
"andromache"
|
||||||
"astyanax"
|
"astyanax"
|
||||||
@@ -38,7 +40,7 @@ in
|
|||||||
hardware.enableRedistributableFirmware = true;
|
hardware.enableRedistributableFirmware = true;
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
inherit hostName;
|
hostName = config.host.name;
|
||||||
networkmanager.enable = true;
|
networkmanager.enable = true;
|
||||||
firewall = {
|
firewall = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -51,7 +53,7 @@ in
|
|||||||
|
|
||||||
users.users = {
|
users.users = {
|
||||||
root.hashedPassword = "!";
|
root.hashedPassword = "!";
|
||||||
${username} = {
|
${config.host.username} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, config, ... }:
|
||||||
|
|
||||||
# Orange Pi Zero2 H616
|
# Orange Pi Zero2 H616
|
||||||
# See <https://nixos.wiki/wiki/NixOS_on_ARM/Orange_Pi_Zero2_H616>
|
# See <https://nixos.wiki/wiki/NixOS_on_ARM/Orange_Pi_Zero2_H616>
|
||||||
|
|
||||||
let
|
|
||||||
username = "h";
|
|
||||||
hostName = "eetion";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./hard.nix
|
./hard.nix
|
||||||
../../modules/ssh
|
../../modules/ssh
|
||||||
|
../../modules/common
|
||||||
# ../../modules/uptime-kuma
|
# ../../modules/uptime-kuma
|
||||||
];
|
];
|
||||||
|
|
||||||
|
host = {
|
||||||
|
username = "h";
|
||||||
|
name = "eetion";
|
||||||
|
};
|
||||||
|
|
||||||
ssh = {
|
ssh = {
|
||||||
inherit username;
|
username = config.host.username;
|
||||||
publicHostname = "eetion";
|
publicHostname = config.host.name;
|
||||||
authorizedHosts = [
|
authorizedHosts = [
|
||||||
"andromache"
|
"andromache"
|
||||||
"astyanax"
|
"astyanax"
|
||||||
@@ -29,7 +31,7 @@ in
|
|||||||
};
|
};
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
inherit hostName;
|
hostName = config.host.name;
|
||||||
networkmanager.enable = true;
|
networkmanager.enable = true;
|
||||||
firewall = {
|
firewall = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -44,7 +46,7 @@ in
|
|||||||
|
|
||||||
users.users = {
|
users.users = {
|
||||||
root.hashedPassword = "!";
|
root.hashedPassword = "!";
|
||||||
${username} = {
|
${config.host.username} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" ];
|
||||||
};
|
};
|
||||||
@@ -57,19 +59,19 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
passwordFile = "/etc/paperless-admin-pass";
|
passwordFile = "/etc/paperless-admin-pass";
|
||||||
settings = {
|
settings = {
|
||||||
PAPERLESS_URL = "http://paperless.eetion";
|
PAPERLESS_URL = "http://paperless.${config.host.name}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# added (OPNSense) domain override to make this work on LAN
|
# added (OPNSense) domain override to make this work on LAN
|
||||||
#
|
#
|
||||||
# host: eetion
|
# host: <host-name>
|
||||||
# domain: <domain (e.g. lan)>
|
# domain: <domain (e.g. lan)>
|
||||||
# ip address: <eetion-ip>
|
# ip address: <host-ip>
|
||||||
#
|
#
|
||||||
# host: paperless
|
# host: paperless
|
||||||
# domain: eetion
|
# domain: <host-name>
|
||||||
# ip address: <eetion-ip>
|
# ip address: <host-ip>
|
||||||
nginx = {
|
nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
recommendedGzipSettings = true;
|
recommendedGzipSettings = true;
|
||||||
@@ -78,13 +80,13 @@ in
|
|||||||
recommendedTlsSettings = true;
|
recommendedTlsSettings = true;
|
||||||
|
|
||||||
virtualHosts = {
|
virtualHosts = {
|
||||||
"eetion" = {
|
"${config.host.name}" = {
|
||||||
default = true;
|
default = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://127.0.0.1:5006";
|
proxyPass = "http://127.0.0.1:5006";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
"paperless.eetion" = {
|
"paperless.${config.host.name}" = {
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://127.0.0.1:28981";
|
proxyPass = "http://127.0.0.1:28981";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
# 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 = [
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
@@ -19,9 +16,14 @@ in
|
|||||||
../../modules/docker
|
../../modules/docker
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = hostName;
|
host = {
|
||||||
|
username = "username";
|
||||||
|
name = "hecuba";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.hostName = config.host.name;
|
||||||
ssh = {
|
ssh = {
|
||||||
inherit username;
|
username = config.host.username;
|
||||||
publicHostname = "server.hektormisplon.xyz";
|
publicHostname = "server.hektormisplon.xyz";
|
||||||
authorizedHosts = [
|
authorizedHosts = [
|
||||||
"andromache"
|
"andromache"
|
||||||
@@ -29,7 +31,7 @@ in
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
docker.user = username;
|
docker.user = config.host.username;
|
||||||
|
|
||||||
fileSystems."/" = {
|
fileSystems."/" = {
|
||||||
device = "/dev/disk/by-label/nixos";
|
device = "/dev/disk/by-label/nixos";
|
||||||
@@ -50,7 +52,7 @@ in
|
|||||||
|
|
||||||
users.users = {
|
users.users = {
|
||||||
root.hashedPassword = "!";
|
root.hashedPassword = "!";
|
||||||
username = {
|
${config.host.username} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,10 +5,6 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
username = "h";
|
|
||||||
hostName = "vm";
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.disko.nixosModules.disko
|
inputs.disko.nixosModules.disko
|
||||||
@@ -18,7 +14,7 @@ in
|
|||||||
./disk.nix
|
./disk.nix
|
||||||
../../modules/boot/bootloader.nix
|
../../modules/boot/bootloader.nix
|
||||||
../../modules/keyboard
|
../../modules/keyboard
|
||||||
(import ../../modules/networking { inherit hostName; })
|
(import ../../modules/networking { hostName = config.host.name; })
|
||||||
../../modules/users
|
../../modules/users
|
||||||
../../modules/audio
|
../../modules/audio
|
||||||
../../modules/localization
|
../../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;
|
inherit inputs config pkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.hostName = hostName;
|
networking.hostName = config.host.name;
|
||||||
ssh.username = username;
|
ssh.username = config.host.username;
|
||||||
|
|
||||||
secrets.username = username;
|
secrets.username = config.host.username;
|
||||||
|
|
||||||
disko = {
|
disko = {
|
||||||
devices.disk.main = {
|
devices.disk.main = {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ in
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
inputs.home-manager.nixosModules.default
|
inputs.home-manager.nixosModules.default
|
||||||
|
./host.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.nixpkgs.allowedUnfree = lib.mkOption {
|
options.nixpkgs.allowedUnfree = lib.mkOption {
|
||||||
|
|||||||
13
modules/common/host.nix
Normal file
13
modules/common/host.nix
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options.host = {
|
||||||
|
username = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
};
|
||||||
|
|
||||||
|
name = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user