diff --git a/hosts/common/optional/nfs-mounts/media.nix b/hosts/common/optional/nfs-mounts/media.nix index 6e68f14..7375f95 100644 --- a/hosts/common/optional/nfs-mounts/media.nix +++ b/hosts/common/optional/nfs-mounts/media.nix @@ -1,5 +1,7 @@ -{ - fileSystems."/media/media" = { +{configVars, ...}: let + mediaDataMountPoint = configVars.locations.mediaDataMountPoint; +in { + fileSystems.${mediaDataMountPoint} = { device = "10.0.10.30:/mnt/media"; fsType = "nfs"; options = ["noatime" "_netdev"]; diff --git a/hosts/common/optional/nixos-containers/backup-server.nix b/hosts/common/optional/nixos-containers/backup-server.nix index d18ed5e..d0cbaee 100644 --- a/hosts/common/optional/nixos-containers/backup-server.nix +++ b/hosts/common/optional/nixos-containers/backup-server.nix @@ -8,6 +8,7 @@ containerIp = configVars.networking.addresses.backup-server.ip; gatewayIp = configVars.networking.addresses.gateway.ip; pubKeys = lib.filesystem.listFilesRecursive ../../users/keys; + backupContainerData = configVars.locations.backupContainerData; in { networking.nat.enable = true; networking.nat.internalInterfaces = ["ve-+"]; @@ -27,7 +28,7 @@ in { nixpkgs = pkgs.path; bindMounts = { "/srv/backup" = { - hostPath = "/media/main-ssd/backup"; + hostPath = backupContainerData; isReadOnly = false; }; }; diff --git a/hosts/common/optional/nixos-containers/docker.nix b/hosts/common/optional/nixos-containers/docker.nix index 58d25cc..1439328 100644 --- a/hosts/common/optional/nixos-containers/docker.nix +++ b/hosts/common/optional/nixos-containers/docker.nix @@ -8,6 +8,8 @@ containerName = "docker"; containerIp = configVars.networking.addresses.docker.ip; gatewayIp = configVars.networking.addresses.gateway.ip; + dockerContainerData = configVars.locations.dockerContainerData; + mediaDataMountPoint = configVars.locations.mediaDataMountPoint; pubKeys = lib.filesystem.listFilesRecursive ../../users/keys; arion = inputs.arion; sops-nix = inputs.sops-nix; @@ -19,7 +21,7 @@ in { services.restic.backups = { daily = { paths = [ - "/media/main-ssd/docker/media-server" + dockerContainerData ]; exclude = [ ]; @@ -76,11 +78,11 @@ in { isReadOnly = false; }; "/media/media" = { - hostPath = "/media/media"; + hostPath = mediaDataMountPoint; isReadOnly = false; }; "/srv/docker" = { - hostPath = "/media/main-ssd/docker"; + hostPath = dockerContainerData; isReadOnly = false; }; "/etc/ssh/ssh_host_ed25519_key" = { diff --git a/hosts/common/optional/nixos-containers/nix-bitcoin.nix b/hosts/common/optional/nixos-containers/nix-bitcoin.nix index ca4753f..95eccd2 100644 --- a/hosts/common/optional/nixos-containers/nix-bitcoin.nix +++ b/hosts/common/optional/nixos-containers/nix-bitcoin.nix @@ -9,10 +9,24 @@ containerName = "bitcoin-node"; containerIp = configVars.networking.addresses.bitcoin-node.ip; mempoolPort = configVars.networking.addresses.bitcoin-node.services.mempool.port; + bitcoinNodeContainerData = configVars.locations.bitcoinNodeContainerData; gatewayIp = configVars.networking.addresses.gateway.ip; allowip = configVars.networking.addresses.bitcoin-node.services.bitcoind.allowip; pubKeys = lib.filesystem.listFilesRecursive ../../users/keys; in { + + services.restic.backups = { + daily = { + paths = [ + bitcoinNodeContainerData + ]; + exclude = [ + "${bitcoinNodeContainerData}/bitcoind" + "${bitcoinNodeContainerData}/electrs" + ]; + }; + }; + environment.persistence."/persist" = { hideMounts = true; 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.internalInterfaces = ["ve-+"]; networking.nat.externalInterface = "br0"; @@ -43,7 +45,7 @@ in { nixpkgs = pkgs.path; bindMounts = { "/var/lib/" = { - hostPath = "/media/main-ssd/nix-bitcoin/"; + hostPath = bitcoinNodeContainerData; isReadOnly = false; }; }; diff --git a/hosts/common/optional/nixos-containers/postgres.nix b/hosts/common/optional/nixos-containers/postgres.nix index f48aadd..cfbcf9e 100644 --- a/hosts/common/optional/nixos-containers/postgres.nix +++ b/hosts/common/optional/nixos-containers/postgres.nix @@ -12,6 +12,7 @@ containerIp = configVars.networking.addresses.postgres.ip; subnetIp = configVars.networking.addresses.subnet.ip; gatewayIp = configVars.networking.addresses.gateway.ip; + postgresContainerData = configVars.locations.postgresContainerData; in { sops.secrets = { "software/postgres/postgres/password" = { @@ -36,7 +37,7 @@ in { nixpkgs = pkgs.path; bindMounts = { "/var/lib/postgresql" = { - hostPath = "/media/main-ssd/postgresql"; + hostPath = postgresContainerData; isReadOnly = false; }; }; diff --git a/hosts/semita/default.nix b/hosts/semita/default.nix index e39b5e3..d0f768c 100644 --- a/hosts/semita/default.nix +++ b/hosts/semita/default.nix @@ -62,10 +62,6 @@ in { ../common/optional/nixos-containers/backup-server.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 # ../common/optional/distributed_builds/local-machine.nix ]; diff --git a/vars/default.nix b/vars/default.nix index 3e575d9..a25e3ac 100644 --- a/vars/default.nix +++ b/vars/default.nix @@ -4,5 +4,12 @@ networking 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"; + }; }