mirror of
https://github.com/nickolaj-jepsen/nixos.git
synced 2026-01-22 08:06:50 +01:00
refactor: move homelab config to module
This commit is contained in:
parent
742a55e5a0
commit
e03f3af01d
19 changed files with 123 additions and 62 deletions
|
|
@ -44,6 +44,7 @@ with lib; let
|
|||
../modules/system
|
||||
../modules/programs
|
||||
../modules/desktop
|
||||
../modules/homelab
|
||||
(mkSystemImports hostname)
|
||||
{nixpkgs.config.allowUnfree = true;}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
...
|
||||
}: {
|
||||
fireproof.dev.enable = true;
|
||||
fireproof.homelab.enable = true;
|
||||
|
||||
boot = {
|
||||
# Use grub as bootloader as it works better with mdadm
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
username,
|
||||
...
|
||||
}: let
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable (let
|
||||
user = "media";
|
||||
group = "media";
|
||||
|
||||
|
|
@ -80,4 +82,4 @@ in {
|
|||
};
|
||||
prowlarr.enable = true;
|
||||
};
|
||||
}
|
||||
})
|
||||
19
modules/homelab/default.nix
Normal file
19
modules/homelab/default.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{lib, ...}: {
|
||||
options.fireproof.homelab = {
|
||||
enable = lib.mkEnableOption "Enable homelab services (arr, nginx, postgres, prometheus, etc.)";
|
||||
};
|
||||
|
||||
imports = [
|
||||
./arr.nix
|
||||
./flame.nix
|
||||
./home-assistant.nix
|
||||
./nextcloud.nix
|
||||
./nginx.nix
|
||||
./plex.nix
|
||||
./postgres.nix
|
||||
./prometheus.nix
|
||||
./restic.nix
|
||||
./sso.nix
|
||||
./vaultwarden.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -1,4 +1,9 @@
|
|||
_: let
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable (let
|
||||
dataDir = "/var/lib/flame";
|
||||
domain = "flame.nickolaj.com";
|
||||
in {
|
||||
|
|
@ -29,4 +34,4 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable (let
|
||||
mosquittoPort = 1883;
|
||||
zigbee2mqttPort = 8180;
|
||||
homeAssistantPort = 8123;
|
||||
|
|
@ -65,7 +67,7 @@ in {
|
|||
package = pkgs.home-assistant;
|
||||
customComponents = with pkgs.home-assistant-custom-components; [
|
||||
adaptive_lighting
|
||||
sleep_as_android
|
||||
sleep_as_android_mqtt
|
||||
(pkgs.buildHomeAssistantComponent rec {
|
||||
owner = "Sian-Lee-SA";
|
||||
domain = "switch_manager";
|
||||
|
|
@ -183,4 +185,4 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable {
|
||||
age.secrets.nextcloud-admin-pass = {
|
||||
rekeyFile = ../../secrets/hosts/homelab/nextcloud-admin-pass.age;
|
||||
owner = "nextcloud";
|
||||
|
|
@ -1,4 +1,9 @@
|
|||
_: {
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable {
|
||||
networking.firewall.allowedTCPPorts = [80 443];
|
||||
|
||||
services.nginx = {
|
||||
|
|
@ -1,4 +1,10 @@
|
|||
{pkgsUnstable, ...}: let
|
||||
{
|
||||
config,
|
||||
pkgsUnstable,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable (let
|
||||
domain = "plex.nickolaj.com";
|
||||
in {
|
||||
services.nginx.virtualHosts."${domain}" = {
|
||||
|
|
@ -18,4 +24,4 @@ in {
|
|||
user = "media";
|
||||
group = "media";
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
@ -1,4 +1,9 @@
|
|||
{config, ...}: {
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable {
|
||||
services = {
|
||||
restic.backups.homelab.paths = [config.services.postgresqlBackup.location];
|
||||
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
config,
|
||||
hostname,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable (let
|
||||
mkScrapeConfig = name: {
|
||||
job_name = name;
|
||||
static_configs = [
|
||||
|
|
@ -49,4 +51,4 @@ in {
|
|||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable {
|
||||
environment.systemPackages = with pkgs; [
|
||||
restic
|
||||
];
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
{
|
||||
config,
|
||||
pkgsUnstable,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable (let
|
||||
port = 9190;
|
||||
rootDomain = "nickolaj.com";
|
||||
zitadelDomain = "sso.${rootDomain}";
|
||||
|
|
@ -105,4 +107,4 @@ in {
|
|||
cookie-domain = ".${rootDomain}";
|
||||
};
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
@ -1,4 +1,9 @@
|
|||
{config, ...}: let
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
lib.mkIf config.fireproof.homelab.enable (let
|
||||
domain = "bitwarden.nickolaj.com";
|
||||
in {
|
||||
services = {
|
||||
|
|
@ -27,4 +32,4 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
@ -30,50 +30,52 @@ in {
|
|||
forwardAgent = true;
|
||||
serverAliveInterval = 60;
|
||||
serverAliveCountMax = 10;
|
||||
matchBlocks = {
|
||||
"*" = {
|
||||
identityFile = "${config.age.secrets.ssh-key.path}";
|
||||
matchBlocks =
|
||||
{
|
||||
"*" = {
|
||||
identityFile = "${config.age.secrets.ssh-key.path}";
|
||||
};
|
||||
homelab = {
|
||||
hostname = "x.nickolaj.com";
|
||||
user = "nickolaj";
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs workEnabled {
|
||||
# Work hostnames definded in ./networking.nix
|
||||
"bastion.ao" = {
|
||||
user = "nij";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"clickhouse.ao" = {
|
||||
user = "ubuntu";
|
||||
hostname = "51.158.205.48";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"flex.ao" = {
|
||||
user = "nij";
|
||||
hostname = "192.168.2.5";
|
||||
proxyJump = "bastion.ao";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"scw.ao" = {
|
||||
user = "nij";
|
||||
hostname = "51.15.81.1";
|
||||
proxyJump = lib.mkDefault "dev.ao";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"dev.ao" = {
|
||||
user = "nij";
|
||||
hostname = "192.168.2.28";
|
||||
proxyJump = lib.mkDefault "bastion.ao";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"staging.ao" = {
|
||||
user = "staging";
|
||||
hostname = "172.16.2.102";
|
||||
proxyJump = lib.mkDefault "bastion.ao";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
};
|
||||
homelab = {
|
||||
hostname = "x.nickolaj.com";
|
||||
user = "nickolaj";
|
||||
};
|
||||
} // lib.optionalAttrs workEnabled {
|
||||
# Work hostnames definded in ./networking.nix
|
||||
"bastion.ao" = {
|
||||
user = "nij";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"clickhouse.ao" = {
|
||||
user = "ubuntu";
|
||||
hostname = "51.158.205.48";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"flex.ao" = {
|
||||
user = "nij";
|
||||
hostname = "192.168.2.5";
|
||||
proxyJump = "bastion.ao";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"scw.ao" = {
|
||||
user = "nij";
|
||||
hostname = "51.15.81.1";
|
||||
proxyJump = lib.mkDefault "dev.ao";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"dev.ao" = {
|
||||
user = "nij";
|
||||
hostname = "192.168.2.28";
|
||||
proxyJump = lib.mkDefault "bastion.ao";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
"staging.ao" = {
|
||||
user = "staging";
|
||||
hostname = "172.16.2.102";
|
||||
proxyJump = lib.mkDefault "bastion.ao";
|
||||
identityFile = "${config.age.secrets.ssh-key-ao.path}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue