diff --git a/modules/custom/data-disk.nix b/modules/custom/data-disk.nix index 4e2d485..99fa46d 100644 --- a/modules/custom/data-disk.nix +++ b/modules/custom/data-disk.nix @@ -3,17 +3,35 @@ let cfg = config.custom.dataDisk; in { options = { custom = { - dataDisk.enable = lib.mkOption { - default = false; - type = lib.types.bool; - description = '' - Whether to automatically mount /dev/sda1 on /mnt/data - ''; + dataDisk = { + enable = lib.mkOption { + default = false; + type = lib.types.bool; + description = '' + Whether to automatically mount a disk to be used as a data disk. + ''; + }; + + mountPoint = lib.mkOption { + default = "/mnt/data"; + type = lib.types.str; + description = '' + Mount point of the data disk (if enabled). + ''; + }; + + devicePath = lib.mkOption { + default = "/dev/sda1"; + type = lib.types.str; + description = '' + Path of the device to be used as a data disk. + ''; + }; }; }; }; config = lib.mkIf cfg.enable { - fileSystems."/mnt/data" = { device = "/dev/sda1"; }; + fileSystems.${cfg.mountPoint} = { device = cfg.devicePath; }; }; } diff --git a/modules/custom/k3s.nix b/modules/custom/k3s.nix index f851be6..e37ff0a 100644 --- a/modules/custom/k3s.nix +++ b/modules/custom/k3s.nix @@ -17,17 +17,15 @@ in { environment.systemPackages = [ pkgs.k3s ]; services.k3s.enable = true; services.k3s.role = "server"; - # TODO: parameterize data disk mount point. - services.k3s.extraFlags = "--tls-san ${config.networking.fqdn} --data-dir /mnt/data/k3s"; + services.k3s.extraFlags = "--tls-san ${config.networking.fqdn} --data-dir ${config.custom.dataDisk.mountPoint}/k3s"; - # TODO: parameterize data disk mount point. # TODO: use kubenix for this. system.activationScripts.k3s-bootstrap.text = let k3sBootstrapFile = pkgs.writeText "k3s-bootstrap" (builtins.readFile ./k3s-bootstrap.yaml); in '' - ln -sf ${k3sBootstrapFile} /mnt/data/k3s/server/manifests/k3s-bootstrap.yaml + ln -sf ${k3sBootstrapFile} ${config.custom.dataDisk.mountPoint}/k3s/server/manifests/k3s-bootstrap.yaml ''; }; } diff --git a/modules/custom/terraform-database.nix b/modules/custom/terraform-database.nix index 0625311..01b7bb5 100644 --- a/modules/custom/terraform-database.nix +++ b/modules/custom/terraform-database.nix @@ -20,7 +20,7 @@ in { package = pkgs.postgresql_15; enableTCPIP = true; dataDir = lib.mkIf config.custom.dataDisk.enable - "/mnt/data/postgresql/${config.services.postgresql.package.psqlSchema}"; + "${config.custom.dataDisk.mountPoint}/postgresql/${config.services.postgresql.package.psqlSchema}"; authentication = '' hostssl terraformstates terraform all cert '';