Addressed some things nixd complained about
This commit is contained in:
alejandro-angulo 2024-08-03 10:32:02 -07:00
parent 7d8c009c64
commit b9b996bd66
Signed by: alejandro-angulo
GPG key ID: 75579581C74554B6
25 changed files with 145 additions and 187 deletions

View file

@ -1,14 +1,14 @@
{ {
options,
config, config,
pkgs, pkgs,
lib, lib,
... ...
}: }: let
with lib; let inherit (lib) mkEnableOption mkIf;
cfg = config.aa.apps.yubikey; cfg = config.aa.apps.yubikey;
in { in {
options.aa.apps.yubikey = with types; { options.aa.apps.yubikey = {
enable = mkEnableOption "yubikey"; enable = mkEnableOption "yubikey";
}; };
@ -25,7 +25,6 @@ in {
security.pam.yubico = { security.pam.yubico = {
enable = true; enable = true;
#debug = true;
mode = "challenge-response"; mode = "challenge-response";
# Uncomment below for 2FA # Uncomment below for 2FA
#control = "required"; #control = "required";

View file

@ -1,14 +1,13 @@
{ {
options,
config, config,
pkgs,
lib, lib,
... ...
}: }: let
with lib; let inherit (lib) mkIf mkEnableOption;
cfg = config.aa.archetypes.workstation; cfg = config.aa.archetypes.workstation;
in { in {
options.aa.archetypes.workstation = with types; { options.aa.archetypes.workstation = {
enable = mkEnableOption "workstation archetype"; enable = mkEnableOption "workstation archetype";
}; };

View file

@ -1,14 +1,14 @@
{ {
options,
config, config,
lib, lib,
pkgs, pkgs,
... ...
}: }: let
with lib; let inherit (lib) mkEnableOption mkIf;
cfg = config.aa.hardware.audio; cfg = config.aa.hardware.audio;
in { in {
options.aa.hardware.audio = with types; { options.aa.hardware.audio = {
enable = mkEnableOption "audio"; enable = mkEnableOption "audio";
}; };

View file

@ -1,14 +1,13 @@
{ {
options,
config, config,
lib, lib,
pkgs,
... ...
}: }: let
with lib; let inherit (lib) mkIf mkEnableOption;
cfg = config.aa.hardware.bluetooth; cfg = config.aa.hardware.bluetooth;
in { in {
options.aa.hardware.bluetooth = with types; { options.aa.hardware.bluetooth = {
enable = mkEnableOption "bluetooth"; enable = mkEnableOption "bluetooth";
}; };
@ -17,4 +16,3 @@ in {
services.blueman.enable = true; services.blueman.enable = true;
}; };
} }

View file

@ -1,14 +1,13 @@
{ {
options,
config, config,
pkgs,
lib, lib,
... ...
}: }: let
with lib; let inherit (lib) mkEnableOption mkIf;
cfg = config.aa.hardware.tlp; cfg = config.aa.hardware.tlp;
in { in {
options.aa.hardware.tlp = with types; { options.aa.hardware.tlp = {
enable = mkEnableOption "tlp"; enable = mkEnableOption "tlp";
}; };

View file

@ -1,18 +1,18 @@
{ {
options,
config, config,
pkgs, pkgs,
lib, lib,
... ...
}: }: let
with lib; let inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.aa.nix; cfg = config.aa.nix;
selfHostedCacheHost = "https://cache.kilonull.com/"; selfHostedCacheHost = "https://cache.kilonull.com/";
in { in {
options.aa.nix = with types; { options.aa.nix = {
enable = mkEnableOption "manage nix configuration."; enable = mkEnableOption "manage nix configuration.";
package = mkOption { package = mkOption {
type = package; type = types.package;
default = pkgs.nixVersions.git; default = pkgs.nixVersions.git;
description = "Which nix package to use."; description = "Which nix package to use.";
}; };
@ -46,9 +46,8 @@ in {
] ]
else []; else [];
trusted-public-keys = trusted-public-keys =
if cfg.useSelfhostedCache mkIf cfg.useSelfhostedCache
then ["gospelCache:9cbn8Wm54BbwpPS0TXw+15wrYZBpfOJt4Fzfbfcq/pc="] ["gospelCache:9cbn8Wm54BbwpPS0TXw+15wrYZBpfOJt4Fzfbfcq/pc="];
else [];
}; };
# TODO: Configure distributedBuilds and buildMachines? # TODO: Configure distributedBuilds and buildMachines?
@ -58,12 +57,6 @@ in {
dates = "weekly"; dates = "weekly";
options = "--delete-older-than 30d"; options = "--delete-older-than 30d";
}; };
# TODO: Not sure if I want this
# flake-utils-plus
# generateRegistryFromInputs = true;
# generateNixPathFromInputs = true;
# linkInputs = true;
}; };
}; };
} }

View file

@ -1,18 +1,17 @@
{ {
options,
config, config,
lib, lib,
pkgs, namespace,
format,
... ...
}: }: let
with lib; let inherit (lib) mkOption mkEnableOption mkIf types;
cfg = config.aa.security.acme; cfg = config.aa.security.acme;
in { in {
options.aa.security.acme = with types; { options.aa.security.acme = {
enable = mkEnableOption "Automatic Certificate Management Environment (ACME)"; enable = mkEnableOption "Automatic Certificate Management Environment (ACME)";
useStaging = mkOption { useStaging = mkOption {
type = bool; type = types.bool;
description = '' description = ''
Use the staging environment (use when configuring for the first time to Use the staging environment (use when configuring for the first time to
avoid being locked out). avoid being locked out).
@ -20,16 +19,16 @@ in {
default = false; default = false;
}; };
domainName = mkOption { domainName = mkOption {
type = str; type = types.str;
description = "The domain to request a wildcard cert for."; description = "The domain to request a wildcard cert for.";
}; };
isWildcard = mkOption { isWildcard = mkOption {
type = bool; type = types.bool;
default = true; default = true;
description = "Whether or not to request a wildcard cert."; description = "Whether or not to request a wildcard cert.";
}; };
dnsCredentialsFile = mkOption { dnsCredentialsFile = mkOption {
type = path; type = types.path;
description = "The path to the credentials file for the DNS provider."; description = "The path to the credentials file for the DNS provider.";
}; };
}; };

View file

@ -1,18 +1,17 @@
{ {
options,
config, config,
lib, lib,
pkgs, namespace,
format,
... ...
}: }: let
with lib; let inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.aa.services.adguardhome;
cfg = config.${namespace}.services.adguardhome;
in { in {
options.aa.services.adguardhome = with types; { options.${namespace}.services.adguardhome = {
enable = mkEnableOption "adguardhome"; enable = mkEnableOption "adguardhome";
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, forces SSL with the supplied acme If set to a non-empty string, forces SSL with the supplied acme

View file

@ -1,19 +1,18 @@
{ {
options,
config, config,
lib, lib,
pkgs, namespace,
format,
... ...
}: }: let
with lib; let inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.aa.services.gitea;
cfg = config.${namespace}.services.gitea;
gitea_cfg = config.services.gitea; gitea_cfg = config.services.gitea;
in { in {
options.aa.services.gitea = with types; { options.${namespace}.services.gitea = {
enable = mkEnableOption "gitea"; enable = mkEnableOption "gitea";
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, forces SSL with the supplied acme If set to a non-empty string, forces SSL with the supplied acme

View file

@ -1,18 +1,20 @@
{ {
options,
config, config,
lib, lib,
pkgs, pkgs,
namespace,
... ...
}: }: let
with lib; let inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.aa.services.grafana;
cfg = config.${namespace}.services.grafana;
server_settings = config.services.grafana.settings.server; server_settings = config.services.grafana.settings.server;
grafana_dashboards = pkgs.${namespace}.teslamate-grafana-dashboards;
in { in {
options.aa.services.grafana = with types; { options.${namespace}.services.grafana = {
enable = mkEnableOption "grafana"; enable = mkEnableOption "grafana";
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, forces SSL with the supplied acme If set to a non-empty string, forces SSL with the supplied acme
@ -84,7 +86,7 @@ in {
disableDeletion = false; disableDeletion = false;
editable = true; editable = true;
updateIntervalSeconds = 86400; updateIntervalSeconds = 86400;
options.path = "${pkgs.aa.teslamate-grafana-dashboards}/dashboards"; options.path = "${grafana_dashboards}/dashboards";
} }
{ {
name = "teslamate_internal"; name = "teslamate_internal";
@ -95,7 +97,7 @@ in {
disableDeletion = false; disableDeletion = false;
editable = true; editable = true;
updateIntervalSeconds = 86400; updateIntervalSeconds = 86400;
options.path = "${pkgs.aa.teslamate-grafana-dashboards}/dashboards/internal"; options.path = "${grafana_dashboards}/dashboards/internal";
} }
]; ];
}; };

View file

@ -1,19 +1,19 @@
{ {
options,
config, config,
lib, lib,
pkgs, pkgs,
format, namespace,
... ...
}: }: let
with lib; let inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.aa.services.homeassistant;
cfg = config.${namespace}.services.homeassistant;
hass_cfg = config.services.home-assistant; hass_cfg = config.services.home-assistant;
in { in {
options.aa.services.homeassistant = with types; { options.${namespace}.services.homeassistant = {
enable = mkEnableOption "home assistant"; enable = mkEnableOption "home assistant";
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, forces SSL with the supplied acme If set to a non-empty string, forces SSL with the supplied acme

View file

@ -1,11 +1,12 @@
{ {
config, config,
lib, lib,
namespace,
... ...
}: let }: let
cfg = config.aa.services.hydra; cfg = config.${namespace}.services.hydra;
in { in {
options.aa.services.hydra = with lib; { options.${namespace}.services.hydra = with lib; {
enable = mkEnableOption "hydra"; enable = mkEnableOption "hydra";
hostname = mkOption { hostname = mkOption {
type = types.str; type = types.str;

View file

@ -1,17 +1,17 @@
{ {
config, config,
lib, lib,
namespace,
... ...
}: }: let
with lib; let cfg = config.${namespace}.services.loki;
cfg = config.aa.services.loki;
loki = config.services.loki; loki = config.services.loki;
in { in {
options.aa.services.loki = with types; { options.${namespace}.services.loki = with lib; {
enable = mkEnableOption "loki"; enable = mkEnableOption "loki";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.loki = { services.loki = {
enable = true; enable = true;
configuration = { configuration = {

View file

@ -1,18 +1,15 @@
{ {
options,
config, config,
lib, lib,
pkgs, namespace,
... ...
}: }: let
with lib; let cfg = config.${namespace}.services.minio;
cfg = config.aa.services.minio;
minio_cfg = config.services.minio;
in { in {
options.aa.services.minio = with types; { options.${namespace}.services.minio = with lib; {
enable = mkEnableOption "minio"; enable = mkEnableOption "minio";
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, forces SSL with the supplied acme If set to a non-empty string, forces SSL with the supplied acme
@ -21,7 +18,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.minio = { services.minio = {
enable = true; enable = true;
}; };

View file

@ -1,19 +1,14 @@
{ {
options,
config, config,
lib, lib,
pkgs,
format,
... ...
}: }: let
with lib; let
cfg = config.aa.services.mosquitto; cfg = config.aa.services.mosquitto;
mosquitto_cfg = config.services.mosquitto;
in { in {
options.aa.services.mosquitto = with types; { options.aa.services.mosquitto = with lib; {
enable = mkEnableOption "home assistant"; enable = mkEnableOption "home assistant";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
age.secrets = { age.secrets = {
hass_mqtt.file = ../../../../secrets/hass_mqtt.age; hass_mqtt.file = ../../../../secrets/hass_mqtt.age;
theengs_ble_mqtt.file = ../../../../secrets/theengs_ble_mqtt.age; theengs_ble_mqtt.file = ../../../../secrets/theengs_ble_mqtt.age;

View file

@ -3,14 +3,13 @@
lib, lib,
pkgs, pkgs,
... ...
}: }: let
with lib; let
cfg = config.aa.services.nextcloud; cfg = config.aa.services.nextcloud;
in { in {
options.aa.services.nextcloud = with types; { options.aa.services.nextcloud = with lib; {
enable = mkEnableOption "nextcloud"; enable = mkEnableOption "nextcloud";
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, forces SSL with the supplied acme If set to a non-empty string, forces SSL with the supplied acme
@ -19,7 +18,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
age.secrets.nextcloud_admin = { age.secrets.nextcloud_admin = {
file = ../../../../secrets/nextcloud_admin.age; file = ../../../../secrets/nextcloud_admin.age;
owner = "nextcloud"; owner = "nextcloud";
@ -53,7 +52,7 @@ in {
}; };
# nextcloud module configures nginx, just need to specify SSL stuffs here # nextcloud module configures nginx, just need to specify SSL stuffs here
services.nginx.virtualHosts.${config.services.nextcloud.hostName} = mkIf (cfg.acmeCertName != "") { services.nginx.virtualHosts.${config.services.nextcloud.hostName} = lib.mkIf (cfg.acmeCertName != "") {
forceSSL = true; forceSSL = true;
useACMEHost = cfg.acmeCertName; useACMEHost = cfg.acmeCertName;
}; };

View file

@ -1,26 +1,23 @@
{ {
options,
config, config,
lib, lib,
pkgs, pkgs,
format,
... ...
}: }: let
with lib; let
cfg = config.aa.services.nix-serve; cfg = config.aa.services.nix-serve;
in { in {
options.aa.services.nix-serve = with types; { options.aa.services.nix-serve = with lib; {
enable = mkEnableOption "nix-serve"; enable = mkEnableOption "nix-serve";
domain_name = mkOption { domain_name = mkOption {
type = str; type = types.str;
description = "The domain to use."; description = "The domain to use.";
}; };
subdomain_name = mkOption { subdomain_name = mkOption {
type = str; type = types.str;
description = "The subdomain to use."; description = "The subdomain to use.";
}; };
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, forces SSL with the supplied acme If set to a non-empty string, forces SSL with the supplied acme
@ -29,7 +26,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
nix.settings = { nix.settings = {
allowed-users = ["nix-serve"]; allowed-users = ["nix-serve"];
trusted-users = ["nix-serve"]; trusted-users = ["nix-serve"];

View file

@ -1,17 +1,14 @@
{ {
options,
config, config,
lib, lib,
pkgs,
... ...
}: }: let
with lib; let
cfg = config.aa.services.octoprint; cfg = config.aa.services.octoprint;
in { in {
options.aa.services.octoprint = with types; { options.aa.services.octoprint = with lib; {
enable = mkEnableOption "octoprint"; enable = mkEnableOption "octoprint";
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, foces SSL with the supplied acme If set to a non-empty string, foces SSL with the supplied acme
@ -20,7 +17,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.octoprint.enable = true; services.octoprint.enable = true;
services.nginx = { services.nginx = {

View file

@ -1,23 +1,18 @@
{ {
options,
config, config,
lib, lib,
pkgs,
format, format,
... ...
}: }: let
with lib; let inherit (lib) mkIf mkEnableOption mkOption mkDefault types;
cfg = config.aa.services.openssh; cfg = config.aa.services.openssh;
user = config.users.users.${config.aa.user.name};
user-id = builtins.toString user.uid;
default-key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEmPdQcM0KCQ3YunF1gwN+B+i1Q8KrIfiUvNtgFQjTy2"; default-key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEmPdQcM0KCQ3YunF1gwN+B+i1Q8KrIfiUvNtgFQjTy2";
in { in {
options.aa.services.openssh = with types; { options.aa.services.openssh = {
enable = mkEnableOption "ssh"; enable = mkEnableOption "ssh";
authorizedKeys = mkOption { authorizedKeys = mkOption {
type = listOf str; type = types.listOf types.str;
default = [default-key]; default = [default-key];
description = "The public keys to authorize"; description = "The public keys to authorize";
}; };

View file

@ -1,18 +1,15 @@
{ {
options,
config, config,
lib, lib,
pkgs,
... ...
}: }: let
with lib; let
cfg = config.aa.apps.steam; cfg = config.aa.apps.steam;
in { in {
options.aa.services.printing = with types; { options.aa.services.printing = with lib; {
enable = mkEnableOption "printing"; enable = mkEnableOption "printing";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
# Setup printing over the network # Setup printing over the network
services.printing.enable = true; services.printing.enable = true;
services.avahi = { services.avahi = {

View file

@ -1,23 +1,22 @@
{ {
options,
config, config,
lib, lib,
pkgs,
... ...
}: }: let
with lib; let inherit (lib) mkIf;
cfg = config.aa.services.prometheus; cfg = config.aa.services.prometheus;
exporters = config.services.prometheus.exporters; exporters = config.services.prometheus.exporters;
in { in {
options.aa.services.prometheus = with types; { options.aa.services.prometheus = with lib; {
enable = mkEnableOption "prometheus"; enable = mkEnableOption "prometheus";
enableServer = mkOption { enableServer = mkOption {
type = bool; type = types.bool;
default = false; default = false;
description = "Whether or not to enable the prometheus server"; description = "Whether or not to enable the prometheus server";
}; };
enableNodeExporter = mkOption { enableNodeExporter = mkOption {
type = bool; type = types.bool;
default = true; default = true;
description = "Whether or not to enable the node exporter"; description = "Whether or not to enable the node exporter";
}; };

View file

@ -1,19 +1,15 @@
{ {
options,
config, config,
lib, lib,
pkgs,
... ...
}: }: let
with lib; let
cfg = config.aa.services.promtail; cfg = config.aa.services.promtail;
loki = config.services.loki;
in { in {
options.aa.services.promtail = with types; { options.aa.services.promtail = with lib; {
enable = mkEnableOption "promtail"; enable = mkEnableOption "promtail";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.promtail = { services.promtail = {
enable = true; enable = true;
configuration = { configuration = {

View file

@ -4,29 +4,30 @@
pkgs, pkgs,
lib, lib,
... ...
}: }: let
with lib; let inherit (lib) mkIf;
cfg = config.aa.services.syncoid; cfg = config.aa.services.syncoid;
in { in {
options.aa.services.syncoid = with types; { options.aa.services.syncoid = with lib; {
enable = mkEnableOption "syncoid (ZFS snap replication)"; enable = mkEnableOption "syncoid (ZFS snap replication)";
commands = mkOption { commands = mkOption {
type = attrs; type = types.attrs;
default = {}; default = {};
description = "Commands to pass directly to syncoid, see `services.syncoid.commands`"; description = "Commands to pass directly to syncoid, see `services.syncoid.commands`";
}; };
remoteTargetUser = mkOption { remoteTargetUser = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = "The user to use on the target machine."; description = "The user to use on the target machine.";
}; };
remoteTargetDatasets = mkOption { remoteTargetDatasets = mkOption {
type = listOf str; type = types.listOf types.str;
default = []; default = [];
description = "Datasets to be used as a remote target (e.g. a NAS's backups dataset)"; description = "Datasets to be used as a remote target (e.g. a NAS's backups dataset)";
}; };
remoteTargetPublicKeys = mkOption { remoteTargetPublicKeys = mkOption {
type = listOf str; type = types.listOf types.str;
default = []; default = [];
description = "SSH public keys that the syncoid service's user should trust"; description = "SSH public keys that the syncoid service's user should trust";
}; };
@ -45,7 +46,7 @@ in {
++ [ ++ [
"destroy" "destroy"
]; ];
commands = mkAliasDefinitions options.aa.services.syncoid.commands; commands = lib.mkAliasDefinitions options.aa.services.syncoid.commands;
}; };
environment.systemPackages = mkIf (cfg.remoteTargetUser != "") (with pkgs; [ environment.systemPackages = mkIf (cfg.remoteTargetUser != "") (with pkgs; [

View file

@ -1,17 +1,17 @@
{ {
options,
config, config,
pkgs, pkgs,
lib, lib,
... ...
}: }: let
with lib; let inherit (lib) mkIf;
cfg = config.aa.services.tailscale; cfg = config.aa.services.tailscale;
in { in {
options.aa.services.tailscale = with types; { options.aa.services.tailscale = with lib; {
enable = mkEnableOption "tailscale"; enable = mkEnableOption "tailscale";
configureClientRouting = mkOption { configureClientRouting = mkOption {
type = bool; type = types.bool;
default = false; default = false;
description = mdDoc '' description = mdDoc ''
Configures tailscale as a client. Configures tailscale as a client.
@ -20,7 +20,7 @@ in {
''; '';
}; };
configureServerRouting = mkOption { configureServerRouting = mkOption {
type = bool; type = types.bool;
default = false; default = false;
description = mdDoc '' description = mdDoc ''
Configures tailscale as a server. Configures tailscale as a server.

View file

@ -1,18 +1,15 @@
{ {
options,
config, config,
lib, lib,
pkgs,
... ...
}: }: let
with lib; let
cfg = config.aa.services.teslamate; cfg = config.aa.services.teslamate;
in { in {
options.aa.services.teslamate = with types; { options.aa.services.teslamate = with lib; {
enable = mkEnableOption "teslamate"; enable = mkEnableOption "teslamate";
acmeCertName = mkOption { acmeCertName = mkOption {
type = str; type = types.str;
default = ""; default = "";
description = '' description = ''
If set to a non-empty string, forces SSL with the supplied acme If set to a non-empty string, forces SSL with the supplied acme
@ -21,7 +18,7 @@ in {
}; };
user = mkOption { user = mkOption {
type = str; type = types.str;
default = "teslamate"; default = "teslamate";
description = '' description = ''
The user that should run teslamate The user that should run teslamate
@ -29,7 +26,7 @@ in {
}; };
group = mkOption { group = mkOption {
type = str; type = types.str;
default = "teslamate"; default = "teslamate";
description = '' description = ''
The group that should be assigned to the user running teslamate The group that should be assigned to the user running teslamate
@ -38,7 +35,7 @@ in {
database = { database = {
host = mkOption { host = mkOption {
type = str; type = types.str;
default = "127.0.0.1"; default = "127.0.0.1";
description = '' description = ''
Database host address Database host address
@ -46,7 +43,7 @@ in {
}; };
name = mkOption { name = mkOption {
type = str; type = types.str;
default = "teslamate"; default = "teslamate";
description = '' description = ''
The database name The database name
@ -54,7 +51,7 @@ in {
}; };
user = mkOption { user = mkOption {
type = str; type = types.str;
default = "teslamate"; default = "teslamate";
description = '' description = ''
The user that should have access to the database The user that should have access to the database
@ -62,15 +59,15 @@ in {
}; };
passwordFile = mkOption { passwordFile = mkOption {
type = path; type = types.path;
description = lib.mdDoc '' description = mdDoc ''
A file containing the password corresponding to A file containing the password corresponding to
{option}`database.user` {option}`database.user`
''; '';
}; };
createDatabase = mkOption { createDatabase = mkOption {
type = bool; type = types.bool;
default = false; default = false;
description = '' description = ''
Whether to create a local database automatically. Whether to create a local database automatically.
@ -79,7 +76,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
age.secrets = { age.secrets = {
teslamate_encryption.file = ../../../../secrets/teslamate_encryption.age; teslamate_encryption.file = ../../../../secrets/teslamate_encryption.age;
teslamate_mqtt.file = ../../../../secrets/teslamate_mqtt.age; teslamate_mqtt.file = ../../../../secrets/teslamate_mqtt.age;
@ -131,8 +128,8 @@ in {
}; };
users.groups.${cfg.group} = {}; users.groups.${cfg.group} = {};
services.postgresql = optionalAttrs cfg.database.createDatabase { services.postgresql = lib.optionalAttrs cfg.database.createDatabase {
enable = mkDefault true; enable = lib.mkDefault true;
ensureDatabases = [cfg.database.name]; ensureDatabases = [cfg.database.name];
ensureUsers = [ ensureUsers = [