From e67a646a925bc3cda86101a3f3afb81db3030ef5 Mon Sep 17 00:00:00 2001 From: pennae Date: Sun, 5 Dec 2021 22:56:22 +0100 Subject: [PATCH] treewide: add defaultText to remaining options these are mostly options that use alias bindings, bindings to constants, or bindings to calculated values. --- nixos/modules/services/misc/gitea.nix | 5 +++++ nixos/modules/services/misc/mediatomb.nix | 4 +++- nixos/modules/services/monitoring/graphite.nix | 7 +++++++ nixos/modules/services/networking/amuled.nix | 6 +++++- nixos/modules/services/networking/quassel.nix | 6 +++++- nixos/modules/services/torrent/transmission.nix | 4 ++++ nixos/modules/services/video/epgstation/default.nix | 3 +++ nixos/modules/services/web-apps/galene.nix | 6 +++++- nixos/modules/services/web-apps/invidious.nix | 1 + nixos/modules/services/web-apps/matomo.nix | 12 +++++++----- 10 files changed, 45 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/misc/gitea.nix b/nixos/modules/services/misc/gitea.nix index 938bb28da90c..519bd8f57345 100644 --- a/nixos/modules/services/misc/gitea.nix +++ b/nixos/modules/services/misc/gitea.nix @@ -86,6 +86,11 @@ in port = mkOption { type = types.port; default = (if !usePostgresql then 3306 else pg.port); + defaultText = literalExpression '' + if config.${opt.database.type} != "postgresql" + then 3306 + else config.${options.services.postgresql.port} + ''; description = "Database host port."; }; diff --git a/nixos/modules/services/misc/mediatomb.nix b/nixos/modules/services/misc/mediatomb.nix index 0227e81cfd93..ea9ffbb86775 100644 --- a/nixos/modules/services/misc/mediatomb.nix +++ b/nixos/modules/services/misc/mediatomb.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, options, pkgs, ... }: with lib; @@ -6,6 +6,7 @@ let gid = config.ids.gids.mediatomb; cfg = config.services.mediatomb; + opt = options.services.mediatomb; name = cfg.package.pname; pkg = cfg.package; optionYesNo = option: if option then "yes" else "no"; @@ -261,6 +262,7 @@ in { dataDir = mkOption { type = types.path; default = "/var/lib/${name}"; + defaultText = literalExpression ''"/var/lib/''${config.${opt.package}.pname}"''; description = '' The directory where Gerbera/Mediatomb stores its state, data, etc. ''; diff --git a/nixos/modules/services/monitoring/graphite.nix b/nixos/modules/services/monitoring/graphite.nix index feb952324d44..7f4f2a0205a2 100644 --- a/nixos/modules/services/monitoring/graphite.nix +++ b/nixos/modules/services/monitoring/graphite.nix @@ -172,6 +172,13 @@ in { directories: - ${dataDir}/whisper ''; + defaultText = literalExpression '' + ''' + whisper: + directories: + - ''${config.${opt.dataDir}}/whisper + ''' + ''; example = '' allowed_origins: - dashboard.example.com diff --git a/nixos/modules/services/networking/amuled.nix b/nixos/modules/services/networking/amuled.nix index 39320643dd5e..e55ac7a6b18b 100644 --- a/nixos/modules/services/networking/amuled.nix +++ b/nixos/modules/services/networking/amuled.nix @@ -1,9 +1,10 @@ -{ config, lib, pkgs, ... }: +{ config, lib, options, pkgs, ... }: with lib; let cfg = config.services.amule; + opt = options.services.amule; user = if cfg.user != null then cfg.user else "amule"; in @@ -26,6 +27,9 @@ in dataDir = mkOption { type = types.str; default = "/home/${user}/"; + defaultText = literalExpression '' + "/home/''${config.${opt.user}}/" + ''; description = '' The directory holding configuration, incoming and temporary files. ''; diff --git a/nixos/modules/services/networking/quassel.nix b/nixos/modules/services/networking/quassel.nix index 22940ef7a13a..844c9a6b8b35 100644 --- a/nixos/modules/services/networking/quassel.nix +++ b/nixos/modules/services/networking/quassel.nix @@ -1,9 +1,10 @@ -{ config, lib, pkgs, ... }: +{ config, lib, options, pkgs, ... }: with lib; let cfg = config.services.quassel; + opt = options.services.quassel; quassel = cfg.package; user = if cfg.user != null then cfg.user else "quassel"; in @@ -63,6 +64,9 @@ in dataDir = mkOption { default = "/home/${user}/.config/quassel-irc.org"; + defaultText = literalExpression '' + "/home/''${config.${opt.user}}/.config/quassel-irc.org" + ''; type = types.str; description = '' The directory holding configuration files, the SQlite database and the SSL Cert. diff --git a/nixos/modules/services/torrent/transmission.nix b/nixos/modules/services/torrent/transmission.nix index a6ff467914a1..b75507a3a1b4 100644 --- a/nixos/modules/services/torrent/transmission.nix +++ b/nixos/modules/services/torrent/transmission.nix @@ -4,6 +4,7 @@ with lib; let cfg = config.services.transmission; + opt = options.services.transmission; inherit (config.environment) etc; apparmor = config.security.apparmor; rootDir = "/run/transmission"; @@ -47,11 +48,13 @@ in options.download-dir = mkOption { type = types.path; default = "${cfg.home}/${downloadsDir}"; + defaultText = literalExpression ''"''${config.${opt.home}}/${downloadsDir}"''; description = "Directory where to download torrents."; }; options.incomplete-dir = mkOption { type = types.path; default = "${cfg.home}/${incompleteDir}"; + defaultText = literalExpression ''"''${config.${opt.home}}/${incompleteDir}"''; description = '' When enabled with services.transmission.home @@ -147,6 +150,7 @@ in options.watch-dir = mkOption { type = types.path; default = "${cfg.home}/${watchDir}"; + defaultText = literalExpression ''"''${config.${opt.home}}/${watchDir}"''; description = "Watch a directory for torrent files and add them to transmission."; }; options.watch-dir-enabled = mkOption { diff --git a/nixos/modules/services/video/epgstation/default.nix b/nixos/modules/services/video/epgstation/default.nix index afaa88c15d10..db99f731b0a9 100644 --- a/nixos/modules/services/video/epgstation/default.nix +++ b/nixos/modules/services/video/epgstation/default.nix @@ -186,6 +186,9 @@ in in { type = types.str; default = "http+unix://${replaceStrings ["/"] ["%2F"] sockPath}"; + defaultText = literalExpression '' + "http+unix://''${replaceStrings ["/"] ["%2F"] config.${options.services.mirakurun.unixSocket}}" + ''; example = "http://localhost:40772"; description = "URL to connect to Mirakurun."; }); diff --git a/nixos/modules/services/web-apps/galene.nix b/nixos/modules/services/web-apps/galene.nix index db9dfeb47499..1d0a620585b0 100644 --- a/nixos/modules/services/web-apps/galene.nix +++ b/nixos/modules/services/web-apps/galene.nix @@ -1,8 +1,9 @@ -{ config, lib, pkgs, ... }: +{ config, lib, options, pkgs, ... }: with lib; let cfg = config.services.galene; + opt = options.services.galene; defaultstateDir = "/var/lib/galene"; defaultrecordingsDir = "${cfg.stateDir}/recordings"; defaultgroupsDir = "${cfg.stateDir}/groups"; @@ -88,6 +89,7 @@ in recordingsDir = mkOption { type = types.str; default = defaultrecordingsDir; + defaultText = literalExpression ''"''${config.${opt.stateDir}}/recordings"''; example = "/var/lib/galene/recordings"; description = "Recordings directory."; }; @@ -95,6 +97,7 @@ in dataDir = mkOption { type = types.str; default = defaultdataDir; + defaultText = literalExpression ''"''${config.${opt.stateDir}}/data"''; example = "/var/lib/galene/data"; description = "Data directory."; }; @@ -102,6 +105,7 @@ in groupsDir = mkOption { type = types.str; default = defaultgroupsDir; + defaultText = literalExpression ''"''${config.${opt.stateDir}}/groups"''; example = "/var/lib/galene/groups"; description = "Web server directory."; }; diff --git a/nixos/modules/services/web-apps/invidious.nix b/nixos/modules/services/web-apps/invidious.nix index 7fb826af5835..696fd7466f44 100644 --- a/nixos/modules/services/web-apps/invidious.nix +++ b/nixos/modules/services/web-apps/invidious.nix @@ -225,6 +225,7 @@ in port = lib.mkOption { type = types.port; default = options.services.postgresql.port.default; + defaultText = lib.literalExpression "options.services.postgresql.port.default"; description = '' The port of the database Invidious should use. diff --git a/nixos/modules/services/web-apps/matomo.nix b/nixos/modules/services/web-apps/matomo.nix index 318c4473b552..8a0ca33b51f0 100644 --- a/nixos/modules/services/web-apps/matomo.nix +++ b/nixos/modules/services/web-apps/matomo.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, options, pkgs, ... }: with lib; let cfg = config.services.matomo; @@ -12,10 +12,7 @@ let phpExecutionUnit = "phpfpm-${pool}"; databaseService = "mysql.service"; - fqdn = - let - join = hostName: domain: hostName + optionalString (domain != null) ".${domain}"; - in join config.networking.hostName config.networking.domain; + fqdn = if config.networking.domain != null then config.networking.fqdn else config.networking.hostName; in { imports = [ @@ -81,6 +78,11 @@ in { hostname = mkOption { type = types.str; default = "${user}.${fqdn}"; + defaultText = literalExpression '' + if config.${options.networking.domain} != null + then "${user}.''${config.${options.networking.fqdn}}" + else "${user}.''${config.${options.networking.hostName}}" + ''; example = "matomo.yourdomain.org"; description = '' URL of the host, without https prefix. You may want to change it if you