add locations to configVars and apply to nixos config

This commit is contained in:
Sam 2025-01-12 20:25:44 +00:00
parent 93b0fd3425
commit 23edddbea1
7 changed files with 35 additions and 24 deletions

View File

@ -1,5 +1,7 @@
{ {configVars, ...}: let
fileSystems."/media/media" = { mediaDataMountPoint = configVars.locations.mediaDataMountPoint;
in {
fileSystems.${mediaDataMountPoint} = {
device = "10.0.10.30:/mnt/media"; device = "10.0.10.30:/mnt/media";
fsType = "nfs"; fsType = "nfs";
options = ["noatime" "_netdev"]; options = ["noatime" "_netdev"];

View File

@ -8,6 +8,7 @@
containerIp = configVars.networking.addresses.backup-server.ip; containerIp = configVars.networking.addresses.backup-server.ip;
gatewayIp = configVars.networking.addresses.gateway.ip; gatewayIp = configVars.networking.addresses.gateway.ip;
pubKeys = lib.filesystem.listFilesRecursive ../../users/keys; pubKeys = lib.filesystem.listFilesRecursive ../../users/keys;
backupContainerData = configVars.locations.backupContainerData;
in { in {
networking.nat.enable = true; networking.nat.enable = true;
networking.nat.internalInterfaces = ["ve-+"]; networking.nat.internalInterfaces = ["ve-+"];
@ -27,7 +28,7 @@ in {
nixpkgs = pkgs.path; nixpkgs = pkgs.path;
bindMounts = { bindMounts = {
"/srv/backup" = { "/srv/backup" = {
hostPath = "/media/main-ssd/backup"; hostPath = backupContainerData;
isReadOnly = false; isReadOnly = false;
}; };
}; };

View File

@ -8,6 +8,8 @@
containerName = "docker"; containerName = "docker";
containerIp = configVars.networking.addresses.docker.ip; containerIp = configVars.networking.addresses.docker.ip;
gatewayIp = configVars.networking.addresses.gateway.ip; gatewayIp = configVars.networking.addresses.gateway.ip;
dockerContainerData = configVars.locations.dockerContainerData;
mediaDataMountPoint = configVars.locations.mediaDataMountPoint;
pubKeys = lib.filesystem.listFilesRecursive ../../users/keys; pubKeys = lib.filesystem.listFilesRecursive ../../users/keys;
arion = inputs.arion; arion = inputs.arion;
sops-nix = inputs.sops-nix; sops-nix = inputs.sops-nix;
@ -19,7 +21,7 @@ in {
services.restic.backups = { services.restic.backups = {
daily = { daily = {
paths = [ paths = [
"/media/main-ssd/docker/media-server" dockerContainerData
]; ];
exclude = [ exclude = [
]; ];
@ -76,11 +78,11 @@ in {
isReadOnly = false; isReadOnly = false;
}; };
"/media/media" = { "/media/media" = {
hostPath = "/media/media"; hostPath = mediaDataMountPoint;
isReadOnly = false; isReadOnly = false;
}; };
"/srv/docker" = { "/srv/docker" = {
hostPath = "/media/main-ssd/docker"; hostPath = dockerContainerData;
isReadOnly = false; isReadOnly = false;
}; };
"/etc/ssh/ssh_host_ed25519_key" = { "/etc/ssh/ssh_host_ed25519_key" = {

View File

@ -9,10 +9,24 @@
containerName = "bitcoin-node"; containerName = "bitcoin-node";
containerIp = configVars.networking.addresses.bitcoin-node.ip; containerIp = configVars.networking.addresses.bitcoin-node.ip;
mempoolPort = configVars.networking.addresses.bitcoin-node.services.mempool.port; mempoolPort = configVars.networking.addresses.bitcoin-node.services.mempool.port;
bitcoinNodeContainerData = configVars.locations.bitcoinNodeContainerData;
gatewayIp = configVars.networking.addresses.gateway.ip; gatewayIp = configVars.networking.addresses.gateway.ip;
allowip = configVars.networking.addresses.bitcoin-node.services.bitcoind.allowip; allowip = configVars.networking.addresses.bitcoin-node.services.bitcoind.allowip;
pubKeys = lib.filesystem.listFilesRecursive ../../users/keys; pubKeys = lib.filesystem.listFilesRecursive ../../users/keys;
in { in {
services.restic.backups = {
daily = {
paths = [
bitcoinNodeContainerData
];
exclude = [
"${bitcoinNodeContainerData}/bitcoind"
"${bitcoinNodeContainerData}/electrs"
];
};
};
environment.persistence."/persist" = { environment.persistence."/persist" = {
hideMounts = true; hideMounts = true;
directories = [ directories = [
@ -20,18 +34,6 @@ in {
]; ];
}; };
services.restic.backups = {
daily = {
paths = [
"/media/main-ssd/nix-bitcoin/"
];
exclude = [
"/media/main-ssd/nix-bitcoin/bitcoind"
"/media/main-ssd/nix-bitcoin/electrs"
];
};
};
networking.nat.enable = true; networking.nat.enable = true;
networking.nat.internalInterfaces = ["ve-+"]; networking.nat.internalInterfaces = ["ve-+"];
networking.nat.externalInterface = "br0"; networking.nat.externalInterface = "br0";
@ -43,7 +45,7 @@ in {
nixpkgs = pkgs.path; nixpkgs = pkgs.path;
bindMounts = { bindMounts = {
"/var/lib/" = { "/var/lib/" = {
hostPath = "/media/main-ssd/nix-bitcoin/"; hostPath = bitcoinNodeContainerData;
isReadOnly = false; isReadOnly = false;
}; };
}; };

View File

@ -12,6 +12,7 @@
containerIp = configVars.networking.addresses.postgres.ip; containerIp = configVars.networking.addresses.postgres.ip;
subnetIp = configVars.networking.addresses.subnet.ip; subnetIp = configVars.networking.addresses.subnet.ip;
gatewayIp = configVars.networking.addresses.gateway.ip; gatewayIp = configVars.networking.addresses.gateway.ip;
postgresContainerData = configVars.locations.postgresContainerData;
in { in {
sops.secrets = { sops.secrets = {
"software/postgres/postgres/password" = { "software/postgres/postgres/password" = {
@ -36,7 +37,7 @@ in {
nixpkgs = pkgs.path; nixpkgs = pkgs.path;
bindMounts = { bindMounts = {
"/var/lib/postgresql" = { "/var/lib/postgresql" = {
hostPath = "/media/main-ssd/postgresql"; hostPath = postgresContainerData;
isReadOnly = false; isReadOnly = false;
}; };
}; };

View File

@ -62,10 +62,6 @@ in {
../common/optional/nixos-containers/backup-server.nix ../common/optional/nixos-containers/backup-server.nix
../common/optional/nixos-containers/docker.nix ../common/optional/nixos-containers/docker.nix
# # docker containers
# ../common/optional/arion-containers/jellyfin.nix
# ../common/optional/arion-containers/arrstack.nix
# # Build nix derivations on remote machine # # Build nix derivations on remote machine
# ../common/optional/distributed_builds/local-machine.nix # ../common/optional/distributed_builds/local-machine.nix
]; ];

View File

@ -4,5 +4,12 @@
networking networking
email email
; ;
locations = {
dockerContainerData = "/media/main-ssd/docker";
mediaDataMountPoint = "/media/media";
bitcoinNodeContainerData = "/media/main-ssd/nix-bitcoin";
backupContainerData = "/media/main-ssd/backup";
postgresContainerData = "/media/main-ssd/postgresql";
};
} }