0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Merge pull request #148785 from pennae/more-option-doc-staticizing

treewide: more defaultText for options
This commit is contained in:
Graham Christensen 2021-12-17 11:14:08 -05:00 committed by GitHub
commit 06edb74413
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
107 changed files with 591 additions and 161 deletions

View file

@ -614,6 +614,8 @@ rec {
definitions = map (def: def.value) res.defsFinal; definitions = map (def: def.value) res.defsFinal;
files = map (def: def.file) res.defsFinal; files = map (def: def.file) res.defsFinal;
inherit (res) isDefined; inherit (res) isDefined;
# This allows options to be correctly displayed using `${options.path.to.it}`
__toString = _: showOption loc;
}; };
# Merge definitions of a value of a given type. # Merge definitions of a value of a given type.

View file

@ -1,12 +1,13 @@
# /etc files related to networking, such as /etc/services. # /etc files related to networking, such as /etc/services.
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.networking; cfg = config.networking;
opt = options.networking;
localhostMultiple = any (elem "localhost") (attrValues (removeAttrs cfg.hosts [ "127.0.0.1" "::1" ])); localhostMultiple = any (elem "localhost") (attrValues (removeAttrs cfg.hosts [ "127.0.0.1" "::1" ]));
@ -78,6 +79,7 @@ in
httpProxy = lib.mkOption { httpProxy = lib.mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = cfg.proxy.default; default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
description = '' description = ''
This option specifies the http_proxy environment variable. This option specifies the http_proxy environment variable.
''; '';
@ -87,6 +89,7 @@ in
httpsProxy = lib.mkOption { httpsProxy = lib.mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = cfg.proxy.default; default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
description = '' description = ''
This option specifies the https_proxy environment variable. This option specifies the https_proxy environment variable.
''; '';
@ -96,6 +99,7 @@ in
ftpProxy = lib.mkOption { ftpProxy = lib.mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = cfg.proxy.default; default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
description = '' description = ''
This option specifies the ftp_proxy environment variable. This option specifies the ftp_proxy environment variable.
''; '';
@ -105,6 +109,7 @@ in
rsyncProxy = lib.mkOption { rsyncProxy = lib.mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = cfg.proxy.default; default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
description = '' description = ''
This option specifies the rsync_proxy environment variable. This option specifies the rsync_proxy environment variable.
''; '';
@ -114,6 +119,7 @@ in
allProxy = lib.mkOption { allProxy = lib.mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = cfg.proxy.default; default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
description = '' description = ''
This option specifies the all_proxy environment variable. This option specifies the all_proxy environment variable.
''; '';

View file

@ -41,12 +41,17 @@ let
pkgs.zstd pkgs.zstd
]; ];
defaultPackages = map (pkg: setPrio ((pkg.meta.priority or 5) + 3) pkg) defaultPackageNames =
[ pkgs.nano [ "nano"
pkgs.perl "perl"
pkgs.rsync "rsync"
pkgs.strace "strace"
]; ];
defaultPackages =
map
(n: let pkg = pkgs.${n}; in setPrio ((pkg.meta.priority or 5) + 3) pkg)
defaultPackageNames;
defaultPackagesText = "[ ${concatMapStringsSep " " (n: "pkgs.${n}") defaultPackageNames } ]";
in in
@ -73,6 +78,11 @@ in
defaultPackages = mkOption { defaultPackages = mkOption {
type = types.listOf types.package; type = types.listOf types.package;
default = defaultPackages; default = defaultPackages;
defaultText = literalDocBook ''
these packages, with their <literal>meta.priority</literal> numerically increased
(thus lowering their installation priority):
<programlisting>${defaultPackagesText}</programlisting>
'';
example = []; example = [];
description = '' description = ''
Set of default packages that aren't strictly necessary Set of default packages that aren't strictly necessary

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
let let
inherit (lib) mkOption mkEnableOption types mkIf mkMerge optional versionOlder; inherit (lib) literalExpression mkOption mkEnableOption types mkIf mkMerge optional versionOlder;
cfg = config.hardware.system76; cfg = config.hardware.system76;
opt = options.hardware.system76;
kpkgs = config.boot.kernelPackages; kpkgs = config.boot.kernelPackages;
modules = [ "system76" "system76-io" ] ++ (optional (versionOlder kpkgs.kernel.version "5.5") "system76-acpi"); modules = [ "system76" "system76-io" ] ++ (optional (versionOlder kpkgs.kernel.version "5.5") "system76-acpi");
@ -60,6 +61,7 @@ in {
firmware-daemon.enable = mkOption { firmware-daemon.enable = mkOption {
default = cfg.enableAll; default = cfg.enableAll;
defaultText = literalExpression "config.${opt.enableAll}";
example = true; example = true;
description = "Whether to enable the system76 firmware daemon"; description = "Whether to enable the system76 firmware daemon";
type = types.bool; type = types.bool;
@ -67,6 +69,7 @@ in {
kernel-modules.enable = mkOption { kernel-modules.enable = mkOption {
default = cfg.enableAll; default = cfg.enableAll;
defaultText = literalExpression "config.${opt.enableAll}";
example = true; example = true;
description = "Whether to make the system76 out-of-tree kernel modules available"; description = "Whether to make the system76 out-of-tree kernel modules available";
type = types.bool; type = types.bool;
@ -74,6 +77,7 @@ in {
power-daemon.enable = mkOption { power-daemon.enable = mkOption {
default = cfg.enableAll; default = cfg.enableAll;
defaultText = literalExpression "config.${opt.enableAll}";
example = true; example = true;
description = "Whether to enable the system76 power daemon"; description = "Whether to enable the system76 power daemon";
type = types.bool; type = types.bool;

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.system.nixos; cfg = config.system.nixos;
opt = options.system.nixos;
in in
{ {
@ -53,6 +54,7 @@ in
stateVersion = mkOption { stateVersion = mkOption {
type = types.str; type = types.str;
default = cfg.release; default = cfg.release;
defaultText = literalExpression "config.${opt.release}";
description = '' description = ''
Every once in a while, a new NixOS release may change Every once in a while, a new NixOS release may change
configuration defaults in a way incompatible with stateful configuration defaults in a way incompatible with stateful

View file

@ -3,6 +3,18 @@
with lib; with lib;
let let
cfg = config.programs.captive-browser; cfg = config.programs.captive-browser;
browserDefault = chromium: concatStringsSep " " [
''env XDG_CONFIG_HOME="$PREV_CONFIG_HOME"''
''${chromium}/bin/chromium''
''--user-data-dir=''${XDG_DATA_HOME:-$HOME/.local/share}/chromium-captive''
''--proxy-server="socks5://$PROXY"''
''--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE localhost"''
''--no-first-run''
''--new-window''
''--incognito''
''-no-default-browser-check''
''http://cache.nixos.org/''
];
in in
{ {
###### interface ###### interface
@ -26,18 +38,8 @@ in
# the options below are the same as in "captive-browser.toml" # the options below are the same as in "captive-browser.toml"
browser = mkOption { browser = mkOption {
type = types.str; type = types.str;
default = concatStringsSep " " [ default = browserDefault pkgs.chromium;
''env XDG_CONFIG_HOME="$PREV_CONFIG_HOME"'' defaultText = literalExpression (browserDefault "\${pkgs.chromium}");
''${pkgs.chromium}/bin/chromium''
''--user-data-dir=''${XDG_DATA_HOME:-$HOME/.local/share}/chromium-captive''
''--proxy-server="socks5://$PROXY"''
''--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE localhost"''
''--no-first-run''
''--new-window''
''--incognito''
''-no-default-browser-check''
''http://cache.nixos.org/''
];
description = '' description = ''
The shell (/bin/sh) command executed once the proxy starts. The shell (/bin/sh) command executed once the proxy starts.
When browser exits, the proxy exits. An extra env var PROXY is available. When browser exits, the proxy exits. An extra env var PROXY is available.

View file

@ -71,6 +71,7 @@ in
type = types.nullOr (types.enum pkgs.pinentry.flavors); type = types.nullOr (types.enum pkgs.pinentry.flavors);
example = "gnome3"; example = "gnome3";
default = defaultPinentryFlavor; default = defaultPinentryFlavor;
defaultText = literalDocBook ''matching the configured desktop environment'';
description = '' description = ''
Which pinentry interface to use. If not null, the path to the Which pinentry interface to use. If not null, the path to the
pinentry binary will be passed to gpg-agent via commandline and pinentry binary will be passed to gpg-agent via commandline and

View file

@ -1,6 +1,6 @@
# This module defines global configuration for the zshell. # This module defines global configuration for the zshell.
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
@ -9,6 +9,7 @@ let
cfge = config.environment; cfge = config.environment;
cfg = config.programs.zsh; cfg = config.programs.zsh;
opt = options.programs.zsh;
zshAliases = concatStringsSep "\n" ( zshAliases = concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
@ -147,6 +148,7 @@ in
enableGlobalCompInit = mkOption { enableGlobalCompInit = mkOption {
default = cfg.enableCompletion; default = cfg.enableCompletion;
defaultText = literalExpression "config.${opt.enableCompletion}";
description = '' description = ''
Enable execution of compinit call for all interactive zsh shells. Enable execution of compinit call for all interactive zsh shells.

View file

@ -2,6 +2,7 @@
with lib; with lib;
let let
cfg = config.security.acme; cfg = config.security.acme;
opt = options.security.acme;
# Used to calculate timer accuracy for coalescing # Used to calculate timer accuracy for coalescing
numCerts = length (builtins.attrNames cfg.certs); numCerts = length (builtins.attrNames cfg.certs);
@ -485,6 +486,7 @@ let
email = mkOption { email = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = cfg.email; default = cfg.email;
defaultText = literalExpression "config.${opt.email}";
description = "Contact email address for the CA to be able to reach you."; description = "Contact email address for the CA to be able to reach you.";
}; };

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
let let
inherit (lib) mkOption types; inherit (lib) literalExpression mkOption types;
cfg = config.security.dhparams; cfg = config.security.dhparams;
opt = options.security.dhparams;
bitType = types.addCheck types.int (b: b >= 16) // { bitType = types.addCheck types.int (b: b >= 16) // {
name = "bits"; name = "bits";
@ -13,6 +14,7 @@ let
options.bits = mkOption { options.bits = mkOption {
type = bitType; type = bitType;
default = cfg.defaultBitSize; default = cfg.defaultBitSize;
defaultText = literalExpression "config.${opt.defaultBitSize}";
description = '' description = ''
The bit size for the prime that is used during a Diffie-Hellman The bit size for the prime that is used during a Diffie-Hellman
key exchange. key exchange.

View file

@ -1,10 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.mpdscribble; cfg = config.services.mpdscribble;
mpdCfg = config.services.mpd; mpdCfg = config.services.mpd;
mpdOpt = options.services.mpd;
endpointUrls = { endpointUrls = {
"last.fm" = "http://post.audioscrobbler.com"; "last.fm" = "http://post.audioscrobbler.com";
@ -108,6 +109,11 @@ in {
mpdCfg.network.listenAddress mpdCfg.network.listenAddress
else else
"localhost"); "localhost");
defaultText = literalExpression ''
if config.${mpdOpt.network.listenAddress} != "any"
then config.${mpdOpt.network.listenAddress}
else "localhost"
'';
type = types.str; type = types.str;
description = '' description = ''
Host for the mpdscribble daemon to search for a mpd daemon on. Host for the mpdscribble daemon to search for a mpd daemon on.
@ -122,6 +128,10 @@ in {
mpdCfg.credentials).passwordFile mpdCfg.credentials).passwordFile
else else
null; null;
defaultText = literalDocBook ''
The first password file with read access configured for MPD when using a local instance,
otherwise <literal>null</literal>.
'';
type = types.nullOr types.str; type = types.nullOr types.str;
description = '' description = ''
File containing the password for the mpd daemon. File containing the password for the mpd daemon.
@ -132,6 +142,7 @@ in {
port = mkOption { port = mkOption {
default = mpdCfg.network.port; default = mpdCfg.network.port;
defaultText = literalExpression "config.${mpdOpt.network.port}";
type = types.port; type = types.port;
description = '' description = ''
Port for the mpdscribble daemon to search for a mpd daemon on. Port for the mpdscribble daemon to search for a mpd daemon on.

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, utils, ... }: { config, lib, options, pkgs, utils, ... }:
with lib; with lib;
let let
gcfg = config.services.tarsnap; gcfg = config.services.tarsnap;
opt = options.services.tarsnap;
configFile = name: cfg: '' configFile = name: cfg: ''
keyfile ${cfg.keyfile} keyfile ${cfg.keyfile}
@ -59,12 +60,13 @@ in
}; };
archives = mkOption { archives = mkOption {
type = types.attrsOf (types.submodule ({ config, ... }: type = types.attrsOf (types.submodule ({ config, options, ... }:
{ {
options = { options = {
keyfile = mkOption { keyfile = mkOption {
type = types.str; type = types.str;
default = gcfg.keyfile; default = gcfg.keyfile;
defaultText = literalExpression "config.${opt.keyfile}";
description = '' description = ''
Set a specific keyfile for this archive. This defaults to Set a specific keyfile for this archive. This defaults to
<literal>"/root/tarsnap.key"</literal> if left unspecified. <literal>"/root/tarsnap.key"</literal> if left unspecified.
@ -87,6 +89,9 @@ in
cachedir = mkOption { cachedir = mkOption {
type = types.nullOr types.path; type = types.nullOr types.path;
default = "/var/cache/tarsnap/${utils.escapeSystemdPath config.keyfile}"; default = "/var/cache/tarsnap/${utils.escapeSystemdPath config.keyfile}";
defaultText = literalExpression ''
"/var/cache/tarsnap/''${utils.escapeSystemdPath config.${options.keyfile}}"
'';
description = '' description = ''
The cache allows tarsnap to identify previously stored data The cache allows tarsnap to identify previously stored data
blocks, reducing archival time and bandwidth usage. blocks, reducing archival time and bandwidth usage.

View file

@ -1,6 +1,7 @@
{ config, lib, pkgs, ...}: { config, lib, options, pkgs, ...}:
let let
cfg = config.services.hadoop; cfg = config.services.hadoop;
opt = options.services.hadoop;
in in
with lib; with lib;
{ {
@ -44,6 +45,14 @@ with lib;
"mapreduce.map.env" = "HADOOP_MAPRED_HOME=${cfg.package}/lib/${cfg.package.untarDir}"; "mapreduce.map.env" = "HADOOP_MAPRED_HOME=${cfg.package}/lib/${cfg.package.untarDir}";
"mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=${cfg.package}/lib/${cfg.package.untarDir}"; "mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=${cfg.package}/lib/${cfg.package.untarDir}";
}; };
defaultText = literalExpression ''
{
"mapreduce.framework.name" = "yarn";
"yarn.app.mapreduce.am.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}/lib/''${config.${opt.package}.untarDir}";
"mapreduce.map.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}/lib/''${config.${opt.package}.untarDir}";
"mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}/lib/''${config.${opt.package}.untarDir}";
}
'';
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
example = literalExpression '' example = literalExpression ''
options.services.hadoop.mapredSite.default // { options.services.hadoop.mapredSite.default // {
@ -98,6 +107,9 @@ with lib;
log4jProperties = mkOption { log4jProperties = mkOption {
default = "${cfg.package}/lib/${cfg.package.untarDir}/etc/hadoop/log4j.properties"; default = "${cfg.package}/lib/${cfg.package.untarDir}/etc/hadoop/log4j.properties";
defaultText = literalExpression ''
"''${config.${opt.package}}/lib/''${config.${opt.package}.untarDir}/etc/hadoop/log4j.properties"
'';
type = types.path; type = types.path;
example = literalExpression '' example = literalExpression ''
"''${pkgs.hadoop}/lib/''${pkgs.hadoop.untarDir}/etc/hadoop/log4j.properties"; "''${pkgs.hadoop}/lib/''${pkgs.hadoop.untarDir}/etc/hadoop/log4j.properties";

View file

@ -1,9 +1,10 @@
{ config, pkgs, lib, ... }: { config, options, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.services.kubernetes.addons.dashboard; cfg = config.services.kubernetes.addons.dashboard;
opt = options.services.kubernetes.addons.dashboard;
in { in {
imports = [ imports = [
(mkRenamedOptionModule [ "services" "kubernetes" "addons" "dashboard" "enableRBAC" ] [ "services" "kubernetes" "addons" "dashboard" "rbac" "enable" ]) (mkRenamedOptionModule [ "services" "kubernetes" "addons" "dashboard" "enableRBAC" ] [ "services" "kubernetes" "addons" "dashboard" "rbac" "enable" ])
@ -28,6 +29,9 @@ in {
description = "Whether to enable role based access control is enabled for kubernetes dashboard"; description = "Whether to enable role based access control is enabled for kubernetes dashboard";
type = types.bool; type = types.bool;
default = elem "RBAC" config.services.kubernetes.apiserver.authorizationMode; default = elem "RBAC" config.services.kubernetes.apiserver.authorizationMode;
defaultText = literalExpression ''
elem "RBAC" config.${options.services.kubernetes.apiserver.authorizationMode}
'';
}; };
clusterAdmin = mkOption { clusterAdmin = mkOption {
@ -54,6 +58,14 @@ in {
finalImageTag = cfg.version; finalImageTag = cfg.version;
sha256 = "01xrr4pwgr2hcjrjsi3d14ifpzdfbxzqpzxbk2fkbjb9zkv38zxy"; sha256 = "01xrr4pwgr2hcjrjsi3d14ifpzdfbxzqpzxbk2fkbjb9zkv38zxy";
}; };
defaultText = literalExpression ''
{
imageName = "k8s.gcr.io/kubernetes-dashboard-amd64";
imageDigest = "sha256:0ae6b69432e78069c5ce2bcde0fe409c5c4d6f0f4d9cd50a17974fea38898747";
finalImageTag = config.${opt.version};
sha256 = "01xrr4pwgr2hcjrjsi3d14ifpzdfbxzqpzxbk2fkbjb9zkv38zxy";
};
'';
}; };
}; };

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { config, options, pkgs, lib, ... }:
with lib; with lib;
@ -23,6 +23,10 @@ in {
take 3 (splitString "." config.services.kubernetes.apiserver.serviceClusterIpRange take 3 (splitString "." config.services.kubernetes.apiserver.serviceClusterIpRange
)) ))
) + ".254"; ) + ".254";
defaultText = literalDocBook ''
The <literal>x.y.z.254</literal> IP of
<literal>config.${options.services.kubernetes.apiserver.serviceClusterIpRange}</literal>.
'';
type = types.str; type = types.str;
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
top = config.services.kubernetes; top = config.services.kubernetes;
otop = options.services.kubernetes;
cfg = top.apiserver; cfg = top.apiserver;
isRBACEnabled = elem "RBAC" cfg.authorizationMode; isRBACEnabled = elem "RBAC" cfg.authorizationMode;
@ -84,6 +85,7 @@ in
clientCaFile = mkOption { clientCaFile = mkOption {
description = "Kubernetes apiserver CA file for client auth."; description = "Kubernetes apiserver CA file for client auth.";
default = top.caFile; default = top.caFile;
defaultText = literalExpression "config.${otop.caFile}";
type = nullOr path; type = nullOr path;
}; };
@ -138,6 +140,7 @@ in
caFile = mkOption { caFile = mkOption {
description = "Etcd ca file."; description = "Etcd ca file.";
default = top.caFile; default = top.caFile;
defaultText = literalExpression "config.${otop.caFile}";
type = types.nullOr types.path; type = types.nullOr types.path;
}; };
}; };
@ -157,6 +160,7 @@ in
featureGates = mkOption { featureGates = mkOption {
description = "List set of feature gates"; description = "List set of feature gates";
default = top.featureGates; default = top.featureGates;
defaultText = literalExpression "config.${otop.featureGates}";
type = listOf str; type = listOf str;
}; };
@ -175,6 +179,7 @@ in
kubeletClientCaFile = mkOption { kubeletClientCaFile = mkOption {
description = "Path to a cert file for connecting to kubelet."; description = "Path to a cert file for connecting to kubelet.";
default = top.caFile; default = top.caFile;
defaultText = literalExpression "config.${otop.caFile}";
type = nullOr path; type = nullOr path;
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
top = config.services.kubernetes; top = config.services.kubernetes;
otop = options.services.kubernetes;
cfg = top.controllerManager; cfg = top.controllerManager;
in in
{ {
@ -30,6 +31,7 @@ in
clusterCidr = mkOption { clusterCidr = mkOption {
description = "Kubernetes CIDR Range for Pods in cluster."; description = "Kubernetes CIDR Range for Pods in cluster.";
default = top.clusterCidr; default = top.clusterCidr;
defaultText = literalExpression "config.${otop.clusterCidr}";
type = str; type = str;
}; };
@ -44,6 +46,7 @@ in
featureGates = mkOption { featureGates = mkOption {
description = "List set of feature gates"; description = "List set of feature gates";
default = top.featureGates; default = top.featureGates;
defaultText = literalExpression "config.${otop.featureGates}";
type = listOf str; type = listOf str;
}; };
@ -67,6 +70,7 @@ in
service account's token secret. service account's token secret.
''; '';
default = top.caFile; default = top.caFile;
defaultText = literalExpression "config.${otop.caFile}";
type = nullOr path; type = nullOr path;
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.kubernetes; cfg = config.services.kubernetes;
opt = options.services.kubernetes;
defaultContainerdSettings = { defaultContainerdSettings = {
version = 2; version = 2;
@ -87,6 +88,7 @@ let
description = "${prefix} certificate authority file used to connect to kube-apiserver."; description = "${prefix} certificate authority file used to connect to kube-apiserver.";
type = types.nullOr types.path; type = types.nullOr types.path;
default = cfg.caFile; default = cfg.caFile;
defaultText = literalExpression "config.${opt.caFile}";
}; };
certFile = mkOption { certFile = mkOption {

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
top = config.services.kubernetes; top = config.services.kubernetes;
otop = options.services.kubernetes;
cfg = top.kubelet; cfg = top.kubelet;
cniConfig = cniConfig =
@ -35,6 +36,7 @@ let
key = mkOption { key = mkOption {
description = "Key of taint."; description = "Key of taint.";
default = name; default = name;
defaultText = literalDocBook "Name of this submodule.";
type = str; type = str;
}; };
value = mkOption { value = mkOption {
@ -76,12 +78,14 @@ in
clusterDomain = mkOption { clusterDomain = mkOption {
description = "Use alternative domain."; description = "Use alternative domain.";
default = config.services.kubernetes.addons.dns.clusterDomain; default = config.services.kubernetes.addons.dns.clusterDomain;
defaultText = literalExpression "config.${options.services.kubernetes.addons.dns.clusterDomain}";
type = str; type = str;
}; };
clientCaFile = mkOption { clientCaFile = mkOption {
description = "Kubernetes apiserver CA file for client authentication."; description = "Kubernetes apiserver CA file for client authentication.";
default = top.caFile; default = top.caFile;
defaultText = literalExpression "config.${otop.caFile}";
type = nullOr path; type = nullOr path;
}; };
@ -148,6 +152,7 @@ in
featureGates = mkOption { featureGates = mkOption {
description = "List set of feature gates"; description = "List set of feature gates";
default = top.featureGates; default = top.featureGates;
defaultText = literalExpression "config.${otop.featureGates}";
type = listOf str; type = listOf str;
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
top = config.services.kubernetes; top = config.services.kubernetes;
otop = options.services.kubernetes;
cfg = top.proxy; cfg = top.proxy;
in in
{ {
@ -31,6 +32,7 @@ in
featureGates = mkOption { featureGates = mkOption {
description = "List set of feature gates"; description = "List set of feature gates";
default = top.featureGates; default = top.featureGates;
defaultText = literalExpression "config.${otop.featureGates}";
type = listOf str; type = listOf str;
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
top = config.services.kubernetes; top = config.services.kubernetes;
otop = options.services.kubernetes;
cfg = top.scheduler; cfg = top.scheduler;
in in
{ {
@ -27,6 +28,7 @@ in
featureGates = mkOption { featureGates = mkOption {
description = "List set of feature gates"; description = "List set of feature gates";
default = top.featureGates; default = top.featureGates;
defaultText = literalExpression "config.${otop.featureGates}";
type = listOf str; type = listOf str;
}; };

View file

@ -1,10 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.slurm; cfg = config.services.slurm;
opt = options.services.slurm;
# configuration file can be generated by http://slurm.schedmd.com/configurator.html # configuration file can be generated by http://slurm.schedmd.com/configurator.html
defaultUser = "slurm"; defaultUser = "slurm";
@ -90,6 +91,7 @@ in
storageUser = mkOption { storageUser = mkOption {
type = types.str; type = types.str;
default = cfg.user; default = cfg.user;
defaultText = literalExpression "config.${opt.user}";
description = '' description = ''
Database user name. Database user name.
''; '';
@ -154,6 +156,7 @@ in
controlAddr = mkOption { controlAddr = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = cfg.controlMachine; default = cfg.controlMachine;
defaultText = literalExpression "config.${opt.controlMachine}";
example = null; example = null;
description = '' description = ''
Name that ControlMachine should be referred to in establishing a Name that ControlMachine should be referred to in establishing a
@ -279,6 +282,10 @@ in
type = types.path; type = types.path;
internal = true; internal = true;
default = etcSlurm; default = etcSlurm;
defaultText = literalDocBook ''
Directory created from generated config files and
<literal>config.${opt.extraConfigPaths}</literal>.
'';
description = '' description = ''
Path to directory with slurm config files. This option is set by default from the Path to directory with slurm config files. This option is set by default from the
Slurm module and is meant to make the Slurm config file available to other modules. Slurm module and is meant to make the Slurm config file available to other modules.

View file

@ -1,11 +1,12 @@
# NixOS module for Buildbot continous integration server. # NixOS module for Buildbot continous integration server.
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.buildbot-master; cfg = config.services.buildbot-master;
opt = options.services.buildbot-master;
python = cfg.package.pythonModule; python = cfg.package.pythonModule;
@ -152,6 +153,7 @@ in {
buildbotDir = mkOption { buildbotDir = mkOption {
default = "${cfg.home}/master"; default = "${cfg.home}/master";
defaultText = literalExpression ''"''${config.${opt.home}}/master"'';
type = types.path; type = types.path;
description = "Specifies the Buildbot directory."; description = "Specifies the Buildbot directory.";
}; };

View file

@ -1,11 +1,12 @@
# NixOS module for Buildbot Worker. # NixOS module for Buildbot Worker.
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.buildbot-worker; cfg = config.services.buildbot-worker;
opt = options.services.buildbot-worker;
python = cfg.package.pythonModule; python = cfg.package.pythonModule;
@ -77,6 +78,7 @@ in {
buildbotDir = mkOption { buildbotDir = mkOption {
default = "${cfg.home}/worker"; default = "${cfg.home}/worker";
defaultText = literalExpression ''"''${config.${opt.home}}/worker"'';
type = types.path; type = types.path;
description = "Specifies the Buildbot directory."; description = "Specifies the Buildbot directory.";
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.gocd-agent; cfg = config.services.gocd-agent;
opt = options.services.gocd-agent;
in { in {
options = { options = {
services.gocd-agent = { services.gocd-agent = {
@ -98,6 +99,15 @@ in {
"-Dcruise.console.publish.interval=10" "-Dcruise.console.publish.interval=10"
"-Djava.security.egd=file:/dev/./urandom" "-Djava.security.egd=file:/dev/./urandom"
]; ];
defaultText = literalExpression ''
[
"-Xms''${config.${opt.initialJavaHeapSize}}"
"-Xmx''${config.${opt.maxJavaHeapMemory}}"
"-Djava.io.tmpdir=/tmp"
"-Dcruise.console.publish.interval=10"
"-Djava.security.egd=file:/dev/./urandom"
]
'';
description = '' description = ''
Specifies startup command line arguments to pass to Go.CD agent Specifies startup command line arguments to pass to Go.CD agent
java process. java process.

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.gocd-server; cfg = config.services.gocd-server;
opt = options.services.gocd-server;
in { in {
options = { options = {
services.gocd-server = { services.gocd-server = {
@ -106,6 +107,20 @@ in {
"-Dcruise.server.port=${toString cfg.port}" "-Dcruise.server.port=${toString cfg.port}"
"-Dcruise.server.ssl.port=${toString cfg.sslPort}" "-Dcruise.server.ssl.port=${toString cfg.sslPort}"
]; ];
defaultText = literalExpression ''
[
"-Xms''${config.${opt.initialJavaHeapSize}}"
"-Xmx''${config.${opt.maxJavaHeapMemory}}"
"-Dcruise.listen.host=''${config.${opt.listenAddress}}"
"-Duser.language=en"
"-Djruby.rack.request.size.threshold.bytes=30000000"
"-Duser.country=US"
"-Dcruise.config.dir=''${config.${opt.workDir}}/conf"
"-Dcruise.config.file=''${config.${opt.workDir}}/conf/cruise-config.xml"
"-Dcruise.server.port=''${toString config.${opt.port}}"
"-Dcruise.server.ssl.port=''${toString config.${opt.sslPort}}"
]
'';
description = '' description = ''
Specifies startup command line arguments to pass to Go.CD server Specifies startup command line arguments to pass to Go.CD server

View file

@ -1,14 +1,10 @@
{ config, lib, pkgs, ... }: { config, options, lib, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.hbase; cfg = config.services.hbase;
opt = options.services.hbase;
defaultConfig = {
"hbase.rootdir" = "file://${cfg.dataDir}/hbase";
"hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper";
};
buildProperty = configAttr: buildProperty = configAttr:
(builtins.concatStringsSep "\n" (builtins.concatStringsSep "\n"
@ -23,7 +19,7 @@ let
configFile = pkgs.writeText "hbase-site.xml" configFile = pkgs.writeText "hbase-site.xml"
''<configuration> ''<configuration>
${buildProperty (defaultConfig // cfg.settings)} ${buildProperty (opt.settings.default // cfg.settings)}
</configuration> </configuration>
''; '';
@ -96,7 +92,16 @@ in {
settings = mkOption { settings = mkOption {
type = with lib.types; attrsOf (oneOf [ str int bool ]); type = with lib.types; attrsOf (oneOf [ str int bool ]);
default = defaultConfig; default = {
"hbase.rootdir" = "file://${cfg.dataDir}/hbase";
"hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper";
};
defaultText = literalExpression ''
{
"hbase.rootdir" = "file://''${config.${opt.dataDir}}/hbase";
"hbase.zookeeper.property.dataDir" = "''${config.${opt.dataDir}}/zookeeper";
}
'';
description = '' description = ''
configurations in hbase-site.xml, see <link xlink:href="https://github.com/apache/hbase/blob/master/hbase-server/src/test/resources/hbase-site.xml"/> for details. configurations in hbase-site.xml, see <link xlink:href="https://github.com/apache/hbase/blob/master/hbase-server/src/test/resources/hbase-site.xml"/> for details.
''; '';

View file

@ -4,6 +4,7 @@ with lib;
let let
cfg = config.services.neo4j; cfg = config.services.neo4j;
opt = options.services.neo4j;
certDirOpt = options.services.neo4j.directories.certificates; certDirOpt = options.services.neo4j.directories.certificates;
isDefaultPathOption = opt: isOption opt && opt.type == types.path && opt.highestPrio >= 1500; isDefaultPathOption = opt: isOption opt && opt.type == types.path && opt.highestPrio >= 1500;
@ -256,6 +257,7 @@ in {
certificates = mkOption { certificates = mkOption {
type = types.path; type = types.path;
default = "${cfg.directories.home}/certificates"; default = "${cfg.directories.home}/certificates";
defaultText = literalExpression ''"''${config.${opt.directories.home}}/certificates"'';
description = '' description = ''
Directory for storing certificates to be used by Neo4j for Directory for storing certificates to be used by Neo4j for
TLS connections. TLS connections.
@ -280,6 +282,7 @@ in {
data = mkOption { data = mkOption {
type = types.path; type = types.path;
default = "${cfg.directories.home}/data"; default = "${cfg.directories.home}/data";
defaultText = literalExpression ''"''${config.${opt.directories.home}}/data"'';
description = '' description = ''
Path of the data directory. You must not configure more than one Path of the data directory. You must not configure more than one
Neo4j installation to use the same data directory. Neo4j installation to use the same data directory.
@ -305,6 +308,7 @@ in {
imports = mkOption { imports = mkOption {
type = types.path; type = types.path;
default = "${cfg.directories.home}/import"; default = "${cfg.directories.home}/import";
defaultText = literalExpression ''"''${config.${opt.directories.home}}/import"'';
description = '' description = ''
The root directory for file URLs used with the Cypher The root directory for file URLs used with the Cypher
<literal>LOAD CSV</literal> clause. Only meaningful when <literal>LOAD CSV</literal> clause. Only meaningful when
@ -321,6 +325,7 @@ in {
plugins = mkOption { plugins = mkOption {
type = types.path; type = types.path;
default = "${cfg.directories.home}/plugins"; default = "${cfg.directories.home}/plugins";
defaultText = literalExpression ''"''${config.${opt.directories.home}}/plugins"'';
description = '' description = ''
Path of the database plugin directory. Compiled Java JAR files that Path of the database plugin directory. Compiled Java JAR files that
contain database procedures will be loaded if they are placed in contain database procedures will be loaded if they are placed in
@ -432,6 +437,7 @@ in {
baseDirectory = mkOption { baseDirectory = mkOption {
type = types.path; type = types.path;
default = "${cfg.directories.certificates}/${name}"; default = "${cfg.directories.certificates}/${name}";
defaultText = literalExpression ''"''${config.${opt.directories.certificates}}/''${name}"'';
description = '' description = ''
The mandatory base directory for cryptographic objects of this The mandatory base directory for cryptographic objects of this
policy. This path is only automatically generated when this policy. This path is only automatically generated when this
@ -493,6 +499,7 @@ in {
revokedDir = mkOption { revokedDir = mkOption {
type = types.path; type = types.path;
default = "${config.baseDirectory}/revoked"; default = "${config.baseDirectory}/revoked";
defaultText = literalExpression ''"''${config.${options.baseDirectory}}/revoked"'';
description = '' description = ''
Path to directory of CRLs (Certificate Revocation Lists) in Path to directory of CRLs (Certificate Revocation Lists) in
PEM format. Must be an absolute path. The existence of this PEM format. Must be an absolute path. The existence of this
@ -528,6 +535,7 @@ in {
trustedDir = mkOption { trustedDir = mkOption {
type = types.path; type = types.path;
default = "${config.baseDirectory}/trusted"; default = "${config.baseDirectory}/trusted";
defaultText = literalExpression ''"''${config.${options.baseDirectory}}/trusted"'';
description = '' description = ''
Path to directory of X.509 certificates in PEM format for Path to directory of X.509 certificates in PEM format for
trusted parties. Must be an absolute path. The existence of this trusted parties. Must be an absolute path. The existence of this

View file

@ -71,6 +71,7 @@ in {
baseq3 = mkOption { baseq3 = mkOption {
type = types.either types.package types.path; type = types.either types.package types.path;
default = defaultBaseq3; default = defaultBaseq3;
defaultText = literalDocBook "Manually downloaded Quake 3 installation directory.";
example = "/var/lib/q3ds"; example = "/var/lib/q3ds";
description = '' description = ''
Path to the baseq3 files (pak*.pk3). If this is on the nix store (type = package) all .pk3 files should be saved Path to the baseq3 files (pak*.pk3). If this is on the nix store (type = package) all .pk3 files should be saved

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.terraria; cfg = config.services.terraria;
opt = options.services.terraria;
worldSizeMap = { small = 1; medium = 2; large = 3; }; worldSizeMap = { small = 1; medium = 2; large = 3; };
valFlag = name: val: optionalString (val != null) "-${name} \"${escape ["\\" "\""] (toString val)}\""; valFlag = name: val: optionalString (val != null) "-${name} \"${escape ["\\" "\""] (toString val)}\"";
boolFlag = name: val: optionalString val "-${name}"; boolFlag = name: val: optionalString val "-${name}";
@ -36,7 +37,7 @@ in
type = types.bool; type = types.bool;
default = false; default = false;
description = '' description = ''
If enabled, starts a Terraria server. The server can be connected to via <literal>tmux -S ${cfg.dataDir}/terraria.sock attach</literal> If enabled, starts a Terraria server. The server can be connected to via <literal>tmux -S ''${config.${opt.dataDir}}/terraria.sock attach</literal>
for administration by users who are a part of the <literal>terraria</literal> group (use <literal>C-b d</literal> shortcut to detach again). for administration by users who are a part of the <literal>terraria</literal> group (use <literal>C-b d</literal> shortcut to detach again).
''; '';
}; };

View file

@ -1,11 +1,12 @@
# tcsd daemon. # tcsd daemon.
{ config, pkgs, lib, ... }: { config, options, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.services.tcsd; cfg = config.services.tcsd;
opt = options.services.tcsd;
tcsdConf = pkgs.writeText "tcsd.conf" '' tcsdConf = pkgs.writeText "tcsd.conf" ''
port = 30003 port = 30003
@ -83,6 +84,7 @@ in
platformCred = mkOption { platformCred = mkOption {
default = "${cfg.stateDir}/platform.cert"; default = "${cfg.stateDir}/platform.cert";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/platform.cert"'';
type = types.path; type = types.path;
description = '' description = ''
Path to the platform credential for your TPM. Your TPM Path to the platform credential for your TPM. Your TPM
@ -96,6 +98,7 @@ in
conformanceCred = mkOption { conformanceCred = mkOption {
default = "${cfg.stateDir}/conformance.cert"; default = "${cfg.stateDir}/conformance.cert";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/conformance.cert"'';
type = types.path; type = types.path;
description = '' description = ''
Path to the conformance credential for your TPM. Path to the conformance credential for your TPM.
@ -104,6 +107,7 @@ in
endorsementCred = mkOption { endorsementCred = mkOption {
default = "${cfg.stateDir}/endorsement.cert"; default = "${cfg.stateDir}/endorsement.cert";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/endorsement.cert"'';
type = types.path; type = types.path;
description = '' description = ''
Path to the endorsement credential for your TPM. Path to the endorsement credential for your TPM.

View file

@ -5,14 +5,10 @@ with lib;
let let
cfg = config.services.journalbeat; cfg = config.services.journalbeat;
lt6 = builtins.compareVersions cfg.package.version "6" < 0;
journalbeatYml = pkgs.writeText "journalbeat.yml" '' journalbeatYml = pkgs.writeText "journalbeat.yml" ''
name: ${cfg.name} name: ${cfg.name}
tags: ${builtins.toJSON cfg.tags} tags: ${builtins.toJSON cfg.tags}
${optionalString lt6 "journalbeat.cursor_state_file: /var/lib/${cfg.stateDir}/cursor-state"}
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
@ -57,17 +53,7 @@ in
extraConfig = mkOption { extraConfig = mkOption {
type = types.lines; type = types.lines;
default = optionalString lt6 '' default = "";
journalbeat:
seek_position: cursor
cursor_seek_fallback: tail
write_cursor_state: true
cursor_flush_period: 5s
clean_field_names: true
convert_to_numbers: false
move_metadata_to_field: journal
default_type: journal
'';
description = "Any other configuration options you want to add"; description = "Any other configuration options you want to add";
}; };

View file

@ -5,6 +5,7 @@ with lib;
let let
cfg = config.services.rspamd; cfg = config.services.rspamd;
opt = options.services.rspamd;
postfixCfg = config.services.postfix; postfixCfg = config.services.postfix;
bindSocketOpts = {options, config, ... }: { bindSocketOpts = {options, config, ... }: {
@ -285,8 +286,8 @@ in
bindSockets = [{ bindSockets = [{
socket = "/run/rspamd/rspamd.sock"; socket = "/run/rspamd/rspamd.sock";
mode = "0660"; mode = "0660";
owner = "${cfg.user}"; owner = "''${config.${opt.user}}";
group = "${cfg.group}"; group = "''${config.${opt.group}}";
}]; }];
}; };
controller = { controller = {

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.airsonic; cfg = config.services.airsonic;
opt = options.services.airsonic;
in { in {
options = { options = {
@ -78,7 +79,7 @@ in {
description = '' description = ''
List of paths to transcoder executables that should be accessible List of paths to transcoder executables that should be accessible
from Airsonic. Symlinks will be created to each executable inside from Airsonic. Symlinks will be created to each executable inside
${cfg.home}/transcoders. ''${config.${opt.home}}/transcoders.
''; '';
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.etcd; cfg = config.services.etcd;
opt = options.services.etcd;
in { in {
@ -24,6 +25,7 @@ in {
advertiseClientUrls = mkOption { advertiseClientUrls = mkOption {
description = "Etcd list of this member's client URLs to advertise to the rest of the cluster."; description = "Etcd list of this member's client URLs to advertise to the rest of the cluster.";
default = cfg.listenClientUrls; default = cfg.listenClientUrls;
defaultText = literalExpression "config.${opt.listenClientUrls}";
type = types.listOf types.str; type = types.listOf types.str;
}; };
@ -42,12 +44,14 @@ in {
initialAdvertisePeerUrls = mkOption { initialAdvertisePeerUrls = mkOption {
description = "Etcd list of this member's peer URLs to advertise to rest of the cluster."; description = "Etcd list of this member's peer URLs to advertise to rest of the cluster.";
default = cfg.listenPeerUrls; default = cfg.listenPeerUrls;
defaultText = literalExpression "config.${opt.listenPeerUrls}";
type = types.listOf types.str; type = types.listOf types.str;
}; };
initialCluster = mkOption { initialCluster = mkOption {
description = "Etcd initial cluster configuration for bootstrapping."; description = "Etcd initial cluster configuration for bootstrapping.";
default = ["${cfg.name}=http://127.0.0.1:2380"]; default = ["${cfg.name}=http://127.0.0.1:2380"];
defaultText = literalExpression ''["''${config.${opt.name}}=http://127.0.0.1:2380"]'';
type = types.listOf types.str; type = types.listOf types.str;
}; };
@ -96,18 +100,21 @@ in {
peerCertFile = mkOption { peerCertFile = mkOption {
description = "Cert file to use for peer to peer communication"; description = "Cert file to use for peer to peer communication";
default = cfg.certFile; default = cfg.certFile;
defaultText = literalExpression "config.${opt.certFile}";
type = types.nullOr types.path; type = types.nullOr types.path;
}; };
peerKeyFile = mkOption { peerKeyFile = mkOption {
description = "Key file to use for peer to peer communication"; description = "Key file to use for peer to peer communication";
default = cfg.keyFile; default = cfg.keyFile;
defaultText = literalExpression "config.${opt.keyFile}";
type = types.nullOr types.path; type = types.nullOr types.path;
}; };
peerTrustedCaFile = mkOption { peerTrustedCaFile = mkOption {
description = "Certificate authority file to use for peer to peer communication"; description = "Certificate authority file to use for peer to peer communication";
default = cfg.trustedCaFile; default = cfg.trustedCaFile;
defaultText = literalExpression "config.${opt.trustedCaFile}";
type = types.nullOr types.path; type = types.nullOr types.path;
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.exhibitor; cfg = config.services.exhibitor;
opt = options.services.exhibitor;
exhibitorConfig = '' exhibitorConfig = ''
zookeeper-install-directory=${cfg.baseDir}/zookeeper zookeeper-install-directory=${cfg.baseDir}/zookeeper
zookeeper-data-directory=${cfg.zkDataDir} zookeeper-data-directory=${cfg.zkDataDir}
@ -165,6 +166,7 @@ in
zkDataDir = mkOption { zkDataDir = mkOption {
type = types.str; type = types.str;
default = "${cfg.baseDir}/zkData"; default = "${cfg.baseDir}/zkData";
defaultText = literalExpression ''"''${config.${opt.baseDir}}/zkData"'';
description = '' description = ''
The Zookeeper data directory The Zookeeper data directory
''; '';
@ -172,6 +174,7 @@ in
zkLogDir = mkOption { zkLogDir = mkOption {
type = types.path; type = types.path;
default = "${cfg.baseDir}/zkLogs"; default = "${cfg.baseDir}/zkLogs";
defaultText = literalExpression ''"''${config.${opt.baseDir}}/zkLogs"'';
description = '' description = ''
The Zookeeper logs directory The Zookeeper logs directory
''; '';

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.gitea; cfg = config.services.gitea;
opt = options.services.gitea;
gitea = cfg.package; gitea = cfg.package;
pg = config.services.postgresql; pg = config.services.postgresql;
useMysql = cfg.database.type == "mysql"; useMysql = cfg.database.type == "mysql";
@ -51,6 +52,7 @@ in
log = { log = {
rootPath = mkOption { rootPath = mkOption {
default = "${cfg.stateDir}/log"; default = "${cfg.stateDir}/log";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/log"'';
type = types.str; type = types.str;
description = "Root path for log files."; description = "Root path for log files.";
}; };
@ -84,6 +86,11 @@ in
port = mkOption { port = mkOption {
type = types.port; type = types.port;
default = (if !usePostgresql then 3306 else pg.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."; description = "Database host port.";
}; };
@ -130,6 +137,7 @@ in
path = mkOption { path = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/data/gitea.db"; default = "${cfg.stateDir}/data/gitea.db";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/data/gitea.db"'';
description = "Path to the sqlite3 database file."; description = "Path to the sqlite3 database file.";
}; };
@ -166,6 +174,7 @@ in
backupDir = mkOption { backupDir = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/dump"; default = "${cfg.stateDir}/dump";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/dump"'';
description = "Path to the dump files."; description = "Path to the dump files.";
}; };
}; };
@ -199,6 +208,7 @@ in
contentDir = mkOption { contentDir = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/data/lfs"; default = "${cfg.stateDir}/data/lfs";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/data/lfs"'';
description = "Where to store LFS files."; description = "Where to store LFS files.";
}; };
}; };
@ -212,6 +222,7 @@ in
repositoryRoot = mkOption { repositoryRoot = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/repositories"; default = "${cfg.stateDir}/repositories";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/repositories"'';
description = "Path to the git repositories."; description = "Path to the git repositories.";
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, utils, ... }: { config, lib, options, pkgs, utils, ... }:
with lib; with lib;
let let
cfg = config.services.gitlab; cfg = config.services.gitlab;
opt = options.services.gitlab;
ruby = cfg.packages.gitlab.ruby; ruby = cfg.packages.gitlab.ruby;
@ -309,6 +310,7 @@ in {
backup.path = mkOption { backup.path = mkOption {
type = types.str; type = types.str;
default = cfg.statePath + "/backup"; default = cfg.statePath + "/backup";
defaultText = literalExpression ''config.${opt.statePath} + "/backup"'';
description = "GitLab path for backups."; description = "GitLab path for backups.";
}; };
@ -554,6 +556,7 @@ in {
defaultForProjects = mkOption { defaultForProjects = mkOption {
type = types.bool; type = types.bool;
default = cfg.registry.enable; default = cfg.registry.enable;
defaultText = literalExpression "config.${opt.registry.enable}";
description = "If GitLab container registry should be enabled by default for projects."; description = "If GitLab container registry should be enabled by default for projects.";
}; };
issuer = mkOption { issuer = mkOption {

View file

@ -47,6 +47,7 @@ in
$highlight_bin = "${pkgs.highlight}/bin/highlight"; $highlight_bin = "${pkgs.highlight}/bin/highlight";
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
defaultText = literalDocBook "generated config file";
type = types.path; type = types.path;
readOnly = true; readOnly = true;
internal = true; internal = true;

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.gogs; cfg = config.services.gogs;
opt = options.services.gogs;
configFile = pkgs.writeText "app.ini" '' configFile = pkgs.writeText "app.ini" ''
APP_NAME = ${cfg.appName} APP_NAME = ${cfg.appName}
RUN_USER = ${cfg.user} RUN_USER = ${cfg.user}
@ -129,6 +130,7 @@ in
path = mkOption { path = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/data/gogs.db"; default = "${cfg.stateDir}/data/gogs.db";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/data/gogs.db"'';
description = "Path to the sqlite3 database file."; description = "Path to the sqlite3 database file.";
}; };
}; };
@ -142,6 +144,7 @@ in
repositoryRoot = mkOption { repositoryRoot = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/repositories"; default = "${cfg.stateDir}/repositories";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/repositories"'';
description = "Path to the git repositories."; description = "Path to the git repositories.";
}; };

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
@ -7,6 +7,7 @@ let
name = "headphones"; name = "headphones";
cfg = config.services.headphones; cfg = config.services.headphones;
opt = options.services.headphones;
in in
@ -29,6 +30,7 @@ in
configFile = mkOption { configFile = mkOption {
type = types.path; type = types.path;
default = "${cfg.dataDir}/config.ini"; default = "${cfg.dataDir}/config.ini";
defaultText = literalExpression ''"''${config.${opt.dataDir}}/config.ini"'';
description = "Path to config file."; description = "Path to config file.";
}; };
host = mkOption { host = mkOption {

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, ... }: { config, options, pkgs, lib, ... }:
with lib; with lib;
@ -7,6 +7,7 @@ let
registrationFile = "${dataDir}/discord-registration.yaml"; registrationFile = "${dataDir}/discord-registration.yaml";
appDir = "${pkgs.matrix-appservice-discord}/${pkgs.matrix-appservice-discord.passthru.nodeAppDir}"; appDir = "${pkgs.matrix-appservice-discord}/${pkgs.matrix-appservice-discord.passthru.nodeAppDir}";
cfg = config.services.matrix-appservice-discord; cfg = config.services.matrix-appservice-discord;
opt = options.services.matrix-appservice-discord;
# TODO: switch to configGen.json once RFC42 is implemented # TODO: switch to configGen.json once RFC42 is implemented
settingsFile = pkgs.writeText "matrix-appservice-discord-settings.json" (builtins.toJSON cfg.settings); settingsFile = pkgs.writeText "matrix-appservice-discord-settings.json" (builtins.toJSON cfg.settings);
@ -74,6 +75,7 @@ in {
url = mkOption { url = mkOption {
type = types.str; type = types.str;
default = "http://localhost:${toString cfg.port}"; default = "http://localhost:${toString cfg.port}";
defaultText = literalExpression ''"http://localhost:''${toString config.${opt.port}}"'';
description = '' description = ''
The URL where the application service is listening for HS requests. The URL where the application service is listening for HS requests.
''; '';

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.matrix-synapse; cfg = config.services.matrix-synapse;
opt = options.services.matrix-synapse;
pg = config.services.postgresql; pg = config.services.postgresql;
usePostgresql = cfg.database_type == "psycopg2"; usePostgresql = cfg.database_type == "psycopg2";
logConfigFile = pkgs.writeText "log_config.yaml" cfg.logConfig; logConfigFile = pkgs.writeText "log_config.yaml" cfg.logConfig;
@ -197,7 +198,7 @@ in {
tls_certificate_path = mkOption { tls_certificate_path = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "${cfg.dataDir}/homeserver.tls.crt"; example = "/var/lib/matrix-synapse/homeserver.tls.crt";
description = '' description = ''
PEM encoded X509 certificate for TLS. PEM encoded X509 certificate for TLS.
You can replace the self-signed certificate that synapse You can replace the self-signed certificate that synapse
@ -209,7 +210,7 @@ in {
tls_private_key_path = mkOption { tls_private_key_path = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "${cfg.dataDir}/homeserver.tls.key"; example = "/var/lib/matrix-synapse/homeserver.tls.key";
description = '' description = ''
PEM encoded private key for TLS. Specify null if synapse is not PEM encoded private key for TLS. Specify null if synapse is not
speaking TLS directly. speaking TLS directly.
@ -218,7 +219,7 @@ in {
tls_dh_params_path = mkOption { tls_dh_params_path = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "${cfg.dataDir}/homeserver.tls.dh"; example = "/var/lib/matrix-synapse/homeserver.tls.dh";
description = '' description = ''
PEM dh parameters for ephemeral keys PEM dh parameters for ephemeral keys
''; '';
@ -408,6 +409,29 @@ in {
database = cfg.database_name; database = cfg.database_name;
}; };
}.${cfg.database_type}; }.${cfg.database_type};
defaultText = literalDocBook ''
<variablelist>
<varlistentry>
<term>using sqlite3</term>
<listitem>
<programlisting>
{ database = "''${config.${opt.dataDir}}/homeserver.db"; }
</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>using psycopg2</term>
<listitem>
<programlisting>
psycopg2 = {
user = config.${opt.database_user};
database = config.${opt.database_name};
}
</programlisting>
</listitem>
</varlistentry>
</variablelist>
'';
description = '' description = ''
Arguments to pass to the engine. Arguments to pass to the engine.
''; '';

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
@ -6,6 +6,7 @@ let
gid = config.ids.gids.mediatomb; gid = config.ids.gids.mediatomb;
cfg = config.services.mediatomb; cfg = config.services.mediatomb;
opt = options.services.mediatomb;
name = cfg.package.pname; name = cfg.package.pname;
pkg = cfg.package; pkg = cfg.package;
optionYesNo = option: if option then "yes" else "no"; optionYesNo = option: if option then "yes" else "no";
@ -261,6 +262,7 @@ in {
dataDir = mkOption { dataDir = mkOption {
type = types.path; type = types.path;
default = "/var/lib/${name}"; default = "/var/lib/${name}";
defaultText = literalExpression ''"/var/lib/''${config.${opt.package}.pname}"'';
description = '' description = ''
The directory where Gerbera/Mediatomb stores its state, data, etc. The directory where Gerbera/Mediatomb stores its state, data, etc.
''; '';
@ -277,13 +279,13 @@ in {
user = mkOption { user = mkOption {
type = types.str; type = types.str;
default = "mediatomb"; default = "mediatomb";
description = "User account under which ${name} runs."; description = "User account under which the service runs.";
}; };
group = mkOption { group = mkOption {
type = types.str; type = types.str;
default = "mediatomb"; default = "mediatomb";
description = "Group account under which ${name} runs."; description = "Group account under which the service runs.";
}; };
port = mkOption { port = mkOption {
@ -340,7 +342,7 @@ in {
type = types.bool; type = types.bool;
default = false; default = false;
description = '' description = ''
Allow ${name} to create and use its own config file inside the <literal>dataDir</literal> as Allow the service to create and use its own config file inside the <literal>dataDir</literal> as
configured by <option>services.mediatomb.dataDir</option>. configured by <option>services.mediatomb.dataDir</option>.
Deactivated by default, the service then runs with the configuration generated from this module. Deactivated by default, the service then runs with the configuration generated from this module.
Otherwise, when enabled, no service configuration is generated. Gerbera/Mediatomb then starts using Otherwise, when enabled, no service configuration is generated. Gerbera/Mediatomb then starts using

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
pkg = pkgs.moonraker; pkg = pkgs.moonraker;
cfg = config.services.moonraker; cfg = config.services.moonraker;
opt = options.services.moonraker;
format = pkgs.formats.ini { format = pkgs.formats.ini {
# https://github.com/NixOS/nixpkgs/pull/121613#issuecomment-885241996 # https://github.com/NixOS/nixpkgs/pull/121613#issuecomment-885241996
listToValue = l: listToValue = l:
@ -31,6 +32,7 @@ in {
configDir = mkOption { configDir = mkOption {
type = types.path; type = types.path;
default = cfg.stateDir + "/config"; default = cfg.stateDir + "/config";
defaultText = literalExpression ''config.${opt.stateDir} + "/config"'';
description = '' description = ''
The directory containing client-writable configuration files. The directory containing client-writable configuration files.

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.mwlib; cfg = config.services.mwlib;
opt = options.services.mwlib;
pypkgs = pkgs.python27Packages; pypkgs = pkgs.python27Packages;
inherit (pypkgs) python mwlib; inherit (pypkgs) python mwlib;
@ -46,6 +47,9 @@ in
qserve = mkOption { qserve = mkOption {
default = [ "${cfg.qserve.address}:${toString cfg.qserve.port}" ]; default = [ "${cfg.qserve.address}:${toString cfg.qserve.port}" ];
defaultText = literalExpression ''
[ "''${config.${opt.qserve.address}}:''${toString config.${opt.qserve.port}}"
]'';
type = types.listOf types.str; type = types.listOf types.str;
description = "Register qserve instance."; description = "Register qserve instance.";
}; # nserve.qserve }; # nserve.qserve
@ -96,6 +100,7 @@ in
nslave = { nslave = {
enable = mkOption { enable = mkOption {
default = cfg.qserve.enable; default = cfg.qserve.enable;
defaultText = literalExpression "config.${opt.qserve.enable}";
type = types.bool; type = types.bool;
description = '' description = ''
Pulls new jobs from exactly one qserve instance Pulls new jobs from exactly one qserve instance
@ -127,7 +132,7 @@ in
You have to enable it, or use your own way for serving files You have to enable it, or use your own way for serving files
and set the http.url option accordingly. and set the http.url option accordingly.
''; '';
type = types.submodule ({ type = types.submodule ({ config, options, ... }: {
options = { options = {
enable = mkOption { enable = mkOption {
default = true; default = true;
@ -148,7 +153,8 @@ in
}; # nslave.http.address }; # nslave.http.address
url = mkOption { url = mkOption {
default = "http://localhost:${toString cfg.nslave.http.port}/cache"; default = "http://localhost:${toString config.port}/cache";
defaultText = literalExpression ''"http://localhost:''${toString config.${options.port}}/cache"'';
type = types.str; type = types.str;
description = '' description = ''
Specify URL for accessing generated files from cache. Specify URL for accessing generated files from cache.

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.rippled; cfg = config.services.rippled;
opt = options.services.rippled;
b2i = val: if val then "1" else "0"; b2i = val: if val then "1" else "0";
@ -165,6 +166,7 @@ let
description = "Location to store the database."; description = "Location to store the database.";
type = types.path; type = types.path;
default = cfg.databasePath; default = cfg.databasePath;
defaultText = literalExpression "config.${opt.databasePath}";
}; };
compression = mkOption { compression = mkOption {
@ -177,6 +179,7 @@ let
description = "Enable automatic purging of older ledger information."; description = "Enable automatic purging of older ledger information.";
type = types.nullOr (types.addCheck types.int (v: v > 256)); type = types.nullOr (types.addCheck types.int (v: v > 256));
default = cfg.ledgerHistory; default = cfg.ledgerHistory;
defaultText = literalExpression "config.${opt.ledgerHistory}";
}; };
advisoryDelete = mkOption { advisoryDelete = mkOption {
@ -398,6 +401,7 @@ in
config = mkOption { config = mkOption {
internal = true; internal = true;
default = pkgs.writeText "rippled.conf" rippledCfg; default = pkgs.writeText "rippled.conf" rippledCfg;
defaultText = literalDocBook "generated config file";
}; };
}; };
}; };

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
@ -7,6 +7,7 @@ let
name = "sickbeard"; name = "sickbeard";
cfg = config.services.sickbeard; cfg = config.services.sickbeard;
opt = options.services.sickbeard;
sickbeard = cfg.package; sickbeard = cfg.package;
in in
@ -39,6 +40,7 @@ in
configFile = mkOption { configFile = mkOption {
type = types.path; type = types.path;
default = "${cfg.dataDir}/config.ini"; default = "${cfg.dataDir}/config.ini";
defaultText = literalExpression ''"''${config.${opt.dataDir}}/config.ini"'';
description = "Path to config file."; description = "Path to config file.";
}; };
port = mkOption { port = mkOption {

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
scfg = cfg.builds; scfg = cfg.builds;
rcfg = config.services.redis; rcfg = config.services.redis;
iniKey = "builds.sr.ht"; iniKey = "builds.sr.ht";
@ -38,6 +39,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/buildsrht"; default = "${cfg.statePath}/buildsrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/buildsrht"'';
description = '' description = ''
State path for builds.sr.ht. State path for builds.sr.ht.
''; '';
@ -61,7 +63,7 @@ in
rev = "ff96a0fa5635770390b184ae74debea75c3fd534"; rev = "ff96a0fa5635770390b184ae74debea75c3fd534";
ref = "nixos-unstable"; ref = "nixos-unstable";
}; };
image_from_nixpkgs = pkgs_unstable: (import ("${pkgs.sourcehut.buildsrht}/lib/images/nixos/image.nix") { image_from_nixpkgs = pkgs_unstable: (import ("''${pkgs.sourcehut.buildsrht}/lib/images/nixos/image.nix") {
pkgs = (import pkgs_unstable {}); pkgs = (import pkgs_unstable {});
}); });
in in

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
cfgIni = cfg.settings; cfgIni = cfg.settings;
scfg = cfg.dispatch; scfg = cfg.dispatch;
iniKey = "dispatch.sr.ht"; iniKey = "dispatch.sr.ht";
@ -38,6 +39,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/dispatchsrht"; default = "${cfg.statePath}/dispatchsrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/dispatchsrht"'';
description = '' description = ''
State path for dispatch.sr.ht. State path for dispatch.sr.ht.
''; '';

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
scfg = cfg.git; scfg = cfg.git;
iniKey = "git.sr.ht"; iniKey = "git.sr.ht";
@ -41,6 +42,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/gitsrht"; default = "${cfg.statePath}/gitsrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/gitsrht"'';
description = '' description = ''
State path for git.sr.ht. State path for git.sr.ht.
''; '';

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
scfg = cfg.hg; scfg = cfg.hg;
iniKey = "hg.sr.ht"; iniKey = "hg.sr.ht";
@ -40,6 +41,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/hgsrht"; default = "${cfg.statePath}/hgsrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/hgsrht"'';
description = '' description = ''
State path for hg.sr.ht. State path for hg.sr.ht.
''; '';

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
cfgIni = cfg.settings; cfgIni = cfg.settings;
scfg = cfg.hub; scfg = cfg.hub;
iniKey = "hub.sr.ht"; iniKey = "hub.sr.ht";
@ -38,6 +39,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/hubsrht"; default = "${cfg.statePath}/hubsrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/hubsrht"'';
description = '' description = ''
State path for hub.sr.ht. State path for hub.sr.ht.
''; '';

View file

@ -1,11 +1,12 @@
# Email setup is fairly involved, useful references: # Email setup is fairly involved, useful references:
# https://drewdevault.com/2018/08/05/Local-mail-server.html # https://drewdevault.com/2018/08/05/Local-mail-server.html
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
cfgIni = cfg.settings; cfgIni = cfg.settings;
scfg = cfg.lists; scfg = cfg.lists;
iniKey = "lists.sr.ht"; iniKey = "lists.sr.ht";
@ -42,6 +43,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/listssrht"; default = "${cfg.statePath}/listssrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/listssrht"'';
description = '' description = ''
State path for lists.sr.ht. State path for lists.sr.ht.
''; '';

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
cfgIni = cfg.settings; cfgIni = cfg.settings;
scfg = cfg.man; scfg = cfg.man;
iniKey = "man.sr.ht"; iniKey = "man.sr.ht";
@ -38,6 +39,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/mansrht"; default = "${cfg.statePath}/mansrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/mansrht"'';
description = '' description = ''
State path for man.sr.ht. State path for man.sr.ht.
''; '';

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
cfgIni = cfg.settings; cfgIni = cfg.settings;
scfg = cfg.meta; scfg = cfg.meta;
iniKey = "meta.sr.ht"; iniKey = "meta.sr.ht";
@ -39,6 +40,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/metasrht"; default = "${cfg.statePath}/metasrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/metasrht"'';
description = '' description = ''
State path for meta.sr.ht. State path for meta.sr.ht.
''; '';

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
cfgIni = cfg.settings; cfgIni = cfg.settings;
scfg = cfg.paste; scfg = cfg.paste;
iniKey = "paste.sr.ht"; iniKey = "paste.sr.ht";
@ -39,6 +40,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/pastesrht"; default = "${cfg.statePath}/pastesrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/pastesrht"'';
description = '' description = ''
State path for pastesrht.sr.ht. State path for pastesrht.sr.ht.
''; '';

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.sourcehut; cfg = config.services.sourcehut;
opt = options.services.sourcehut;
cfgIni = cfg.settings; cfgIni = cfg.settings;
scfg = cfg.todo; scfg = cfg.todo;
iniKey = "todo.sr.ht"; iniKey = "todo.sr.ht";
@ -39,6 +40,7 @@ in
statePath = mkOption { statePath = mkOption {
type = types.path; type = types.path;
default = "${cfg.statePath}/todosrht"; default = "${cfg.statePath}/todosrht";
defaultText = literalExpression ''"''${config.${opt.statePath}}/todosrht"'';
description = '' description = ''
State path for todo.sr.ht. State path for todo.sr.ht.
''; '';

View file

@ -1,8 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let cfg = config.services.subsonic; in { let
cfg = config.services.subsonic;
opt = options.services.subsonic;
in {
options = { options = {
services.subsonic = { services.subsonic = {
enable = mkEnableOption "Subsonic daemon"; enable = mkEnableOption "Subsonic daemon";
@ -97,7 +100,7 @@ let cfg = config.services.subsonic; in {
description = '' description = ''
List of paths to transcoder executables that should be accessible List of paths to transcoder executables that should be accessible
from Subsonic. Symlinks will be created to each executable inside from Subsonic. Symlinks will be created to each executable inside
${cfg.home}/transcoders. ''${config.${opt.home}}/transcoders.
''; '';
}; };
}; };

View file

@ -171,7 +171,7 @@ in {
example = "/storage/tank"; example = "/storage/tank";
description = '' description = ''
ZoneMinder can generate quite a lot of data, so in case you don't want ZoneMinder can generate quite a lot of data, so in case you don't want
to use the default ${home}, you can override the path here. to use the default ${defaultDir}, you can override the path here.
''; '';
}; };

View file

@ -404,6 +404,7 @@ in {
path = mkOption { path = mkOption {
description = "Database path."; description = "Database path.";
default = "${cfg.dataDir}/data/grafana.db"; default = "${cfg.dataDir}/data/grafana.db";
defaultText = literalExpression ''"''${config.${opt.dataDir}}/data/grafana.db"'';
type = types.path; type = types.path;
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.graphite; cfg = config.services.graphite;
opt = options.services.graphite;
writeTextOrNull = f: t: mapNullable (pkgs.writeTextDir f) t; writeTextOrNull = f: t: mapNullable (pkgs.writeTextDir f) t;
dataDir = cfg.dataDir; dataDir = cfg.dataDir;
@ -171,6 +172,13 @@ in {
directories: directories:
- ${dataDir}/whisper - ${dataDir}/whisper
''; '';
defaultText = literalExpression ''
'''
whisper:
directories:
- ''${config.${opt.dataDir}}/whisper
'''
'';
example = '' example = ''
allowed_origins: allowed_origins:
- dashboard.example.com - dashboard.example.com
@ -312,12 +320,14 @@ in {
seyrenUrl = mkOption { seyrenUrl = mkOption {
default = "http://localhost:${toString cfg.seyren.port}/"; default = "http://localhost:${toString cfg.seyren.port}/";
defaultText = literalExpression ''"http://localhost:''${toString config.${opt.seyren.port}}/"'';
description = "Host where seyren is accessible."; description = "Host where seyren is accessible.";
type = types.str; type = types.str;
}; };
graphiteUrl = mkOption { graphiteUrl = mkOption {
default = "http://${cfg.web.listenAddress}:${toString cfg.web.port}"; default = "http://${cfg.web.listenAddress}:${toString cfg.web.port}";
defaultText = literalExpression ''"http://''${config.${opt.web.listenAddress}}:''${toString config.${opt.web.port}}"'';
description = "Host where graphite service runs."; description = "Host where graphite service runs.";
type = types.str; type = types.str;
}; };

View file

@ -1,7 +1,8 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
let let
cfg = config.services.parsedmarc; cfg = config.services.parsedmarc;
opt = options.services.parsedmarc;
ini = pkgs.formats.ini {}; ini = pkgs.formats.ini {};
in in
{ {
@ -80,6 +81,9 @@ in
datasource = lib.mkOption { datasource = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = cfg.provision.elasticsearch && config.services.grafana.enable; default = cfg.provision.elasticsearch && config.services.grafana.enable;
defaultText = lib.literalExpression ''
config.${opt.provision.elasticsearch} && config.${options.services.grafana.enable}
'';
apply = x: x && cfg.provision.elasticsearch; apply = x: x && cfg.provision.elasticsearch;
description = '' description = ''
Whether the automatically provisioned Elasticsearch Whether the automatically provisioned Elasticsearch

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
@ -8,6 +8,7 @@ let
+ optionalString (config.networking.domain != null) ".${config.networking.domain}"; + optionalString (config.networking.domain != null) ".${config.networking.domain}";
cfg = config.services.smartd; cfg = config.services.smartd;
opt = options.services.smartd;
nm = cfg.notifications.mail; nm = cfg.notifications.mail;
nw = cfg.notifications.wall; nw = cfg.notifications.wall;
@ -211,6 +212,7 @@ in
autodetected = mkOption { autodetected = mkOption {
default = cfg.defaults.monitored; default = cfg.defaults.monitored;
defaultText = literalExpression "config.${opt.defaults.monitored}";
type = types.separatedString " "; type = types.separatedString " ";
description = '' description = ''
Like <option>services.smartd.defaults.monitored</option>, but for the Like <option>services.smartd.defaults.monitored</option>, but for the

View file

@ -83,6 +83,9 @@ let
mkArgumentsOption = cmd: mkOption { mkArgumentsOption = cmd: mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = argumentsOf cmd; default = argumentsOf cmd;
defaultText = literalDocBook ''
calculated from <literal>config.services.thanos.${cmd}</literal>
'';
description = '' description = ''
Arguments to the <literal>thanos ${cmd}</literal> command. Arguments to the <literal>thanos ${cmd}</literal> command.

View file

@ -1,8 +1,9 @@
{ config, pkgs, lib, ... }: { config, options, pkgs, lib, ... }:
let let
inherit (lib) mkOption mkEnableOption mkIf mkMerge types optional; inherit (lib) literalExpression mkOption mkEnableOption mkIf mkMerge types optional;
cfg = config.services.uptime; cfg = config.services.uptime;
opt = options.services.uptime;
configDir = pkgs.runCommand "config" { preferLocalBuild = true; } configDir = pkgs.runCommand "config" { preferLocalBuild = true; }
(if cfg.configFile != null then '' (if cfg.configFile != null then ''
@ -52,7 +53,10 @@ in {
enableWebService = mkEnableOption "the uptime monitoring program web service"; enableWebService = mkEnableOption "the uptime monitoring program web service";
enableSeparateMonitoringService = mkEnableOption "the uptime monitoring service" // { default = cfg.enableWebService; }; enableSeparateMonitoringService = mkEnableOption "the uptime monitoring service" // {
default = cfg.enableWebService;
defaultText = literalExpression "config.${opt.enableWebService}";
};
nodeEnv = mkOption { nodeEnv = mkOption {
description = "The node environment to run in (development, production, etc.)"; description = "The node environment to run in (development, production, etc.)";

View file

@ -1,7 +1,8 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
let let
cfg = config.services.zabbixProxy; cfg = config.services.zabbixProxy;
opt = options.services.zabbixProxy;
pgsql = config.services.postgresql; pgsql = config.services.postgresql;
mysql = config.services.mysql; mysql = config.services.mysql;
@ -103,6 +104,11 @@ in
port = mkOption { port = mkOption {
type = types.int; type = types.int;
default = if cfg.database.type == "mysql" then mysql.port else pgsql.port; default = if cfg.database.type == "mysql" then mysql.port else pgsql.port;
defaultText = literalExpression ''
if config.${opt.database.type} == "mysql"
then config.${options.services.mysql.port}
else config.${options.services.postgresql.port}
'';
description = "Database host port."; description = "Database host port.";
}; };

View file

@ -1,7 +1,8 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
let let
cfg = config.services.zabbixServer; cfg = config.services.zabbixServer;
opt = options.services.zabbixServer;
pgsql = config.services.postgresql; pgsql = config.services.postgresql;
mysql = config.services.mysql; mysql = config.services.mysql;
@ -95,6 +96,11 @@ in
port = mkOption { port = mkOption {
type = types.int; type = types.int;
default = if cfg.database.type == "mysql" then mysql.port else pgsql.port; default = if cfg.database.type == "mysql" then mysql.port else pgsql.port;
defaultText = literalExpression ''
if config.${opt.database.type} == "mysql"
then config.${options.services.mysql.port}
else config.${options.services.postgresql.port}
'';
description = "Database host port."; description = "Database host port.";
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.amule; cfg = config.services.amule;
opt = options.services.amule;
user = if cfg.user != null then cfg.user else "amule"; user = if cfg.user != null then cfg.user else "amule";
in in
@ -26,6 +27,9 @@ in
dataDir = mkOption { dataDir = mkOption {
type = types.str; type = types.str;
default = "/home/${user}/"; default = "/home/${user}/";
defaultText = literalExpression ''
"/home/''${config.${opt.user}}/"
'';
description = '' description = ''
The directory holding configuration, incoming and temporary files. The directory holding configuration, incoming and temporary files.
''; '';

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
let let
cfg = config.services.ergo; cfg = config.services.ergo;
opt = options.services.ergo;
inherit (lib) mkEnableOption mkIf mkOption optionalString types; inherit (lib) literalExpression mkEnableOption mkIf mkOption optionalString types;
configFile = pkgs.writeText "ergo.conf" ('' configFile = pkgs.writeText "ergo.conf" (''
ergo { ergo {
@ -92,6 +93,7 @@ in {
group = mkOption { group = mkOption {
type = types.str; type = types.str;
default = cfg.user; default = cfg.user;
defaultText = literalExpression "config.${opt.user}";
description = "The group as which to run the Ergo node."; description = "The group as which to run the Ergo node.";
}; };

View file

@ -421,6 +421,7 @@ in
checkReversePath = mkOption { checkReversePath = mkOption {
type = types.either types.bool (types.enum ["strict" "loose"]); type = types.either types.bool (types.enum ["strict" "loose"]);
default = kernelHasRPFilter; default = kernelHasRPFilter;
defaultText = literalDocBook "<literal>true</literal> if supported by the chosen kernel";
example = "loose"; example = "loose";
description = description =
'' ''

View file

@ -132,7 +132,7 @@ in
pkgs.writeScript "finalize_recording.sh" '''''' pkgs.writeScript "finalize_recording.sh" ''''''
#!/bin/sh #!/bin/sh
RECORDINGS_DIR=$1 RECORDINGS_DIR=$1
${pkgs.rclone}/bin/rclone copy $RECORDINGS_DIR RCLONE_REMOTE:jibri-recordings/ -v --log-file=/var/log/jitsi/jibri/recording-upload.txt ''${pkgs.rclone}/bin/rclone copy $RECORDINGS_DIR RCLONE_REMOTE:jibri-recordings/ -v --log-file=/var/log/jitsi/jibri/recording-upload.txt
exit 0 exit 0
''''''; '''''';
''; '';

View file

@ -1,10 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.ntopng; cfg = config.services.ntopng;
opt = options.services.ntopng;
redisCfg = config.services.redis; redisCfg = config.services.redis;
configFile = if cfg.configText != "" then configFile = if cfg.configText != "" then
@ -35,8 +36,8 @@ in
collection tool. collection tool.
With the default configuration, ntopng monitors all network With the default configuration, ntopng monitors all network
interfaces and displays its findings at http://localhost:${toString interfaces and displays its findings at http://localhost:''${toString
cfg.http-port}. Default username and password is admin/admin. config.${opt.http-port}}. Default username and password is admin/admin.
See the ntopng(8) manual page and http://www.ntop.org/products/ntop/ See the ntopng(8) manual page and http://www.ntop.org/products/ntop/
for more info. for more info.

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.quassel; cfg = config.services.quassel;
opt = options.services.quassel;
quassel = cfg.package; quassel = cfg.package;
user = if cfg.user != null then cfg.user else "quassel"; user = if cfg.user != null then cfg.user else "quassel";
in in
@ -63,6 +64,9 @@ in
dataDir = mkOption { dataDir = mkOption {
default = "/home/${user}/.config/quassel-irc.org"; default = "/home/${user}/.config/quassel-irc.org";
defaultText = literalExpression ''
"/home/''${config.${opt.user}}/.config/quassel-irc.org"
'';
type = types.str; type = types.str;
description = '' description = ''
The directory holding configuration files, the SQlite database and the SSL Cert. The directory holding configuration files, the SQlite database and the SSL Cert.

View file

@ -1,9 +1,10 @@
{ config, pkgs, lib, ... }: { config, options, pkgs, lib, ... }:
let let
inherit (lib) mkEnableOption mkIf mkOption literalExpression types optionalString; inherit (lib) mkEnableOption mkIf mkOption literalExpression types optionalString;
cfg = config.services.quorum; cfg = config.services.quorum;
opt = options.services.quorum;
dataDir = "/var/lib/quorum"; dataDir = "/var/lib/quorum";
genesisFile = pkgs.writeText "genesis.json" (builtins.toJSON cfg.genesis); genesisFile = pkgs.writeText "genesis.json" (builtins.toJSON cfg.genesis);
staticNodesFile = pkgs.writeText "static-nodes.json" (builtins.toJSON cfg.staticNodes); staticNodesFile = pkgs.writeText "static-nodes.json" (builtins.toJSON cfg.staticNodes);
@ -23,6 +24,7 @@ in {
group = mkOption { group = mkOption {
type = types.str; type = types.str;
default = cfg.user; default = cfg.user;
defaultText = literalExpression "config.${opt.user}";
description = "The group as which to run quorum."; description = "The group as which to run quorum.";
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.syncthing; cfg = config.services.syncthing;
opt = options.services.syncthing;
defaultUser = "syncthing"; defaultUser = "syncthing";
defaultGroup = defaultUser; defaultGroup = defaultUser;
@ -431,7 +432,26 @@ in {
The path where the settings and keys will exist. The path where the settings and keys will exist.
''; '';
default = cfg.dataDir + optionalString cond "/.config/syncthing"; default = cfg.dataDir + optionalString cond "/.config/syncthing";
defaultText = literalExpression "dataDir${optionalString cond " + \"/.config/syncthing\""}"; defaultText = literalDocBook ''
<variablelist>
<varlistentry>
<term><literal>stateVersion >= 19.03</literal></term>
<listitem>
<programlisting>
config.${opt.dataDir} + "/.config/syncthing"
</programlisting>
</listitem>
</varlistentry>
<varlistentry>
<term>otherwise</term>
<listitem>
<programlisting>
config.${opt.dataDir}
</programlisting>
</listitem>
</varlistentry>
</variablelist>
'';
}; };
extraFlags = mkOption { extraFlags = mkOption {

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
let let
cfg = config.services.wasabibackend; cfg = config.services.wasabibackend;
opt = options.services.wasabibackend;
inherit (lib) mkEnableOption mkIf mkOption optionalAttrs optionalString types; inherit (lib) literalExpression mkEnableOption mkIf mkOption optionalAttrs optionalString types;
confOptions = { confOptions = {
BitcoinRpcConnectionString = "${cfg.rpc.user}:${cfg.rpc.password}"; BitcoinRpcConnectionString = "${cfg.rpc.user}:${cfg.rpc.password}";
@ -103,6 +104,7 @@ in {
group = mkOption { group = mkOption {
type = types.str; type = types.str;
default = cfg.user; default = cfg.user;
defaultText = literalExpression "config.${opt.user}";
description = "The group as which to run the wasabibackend node."; description = "The group as which to run the wasabibackend node.";
}; };
}; };

View file

@ -1,10 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.networking.wireguard; cfg = config.networking.wireguard;
opt = options.networking.wireguard;
kernel = config.boot.kernelPackages; kernel = config.boot.kernelPackages;
@ -438,6 +439,7 @@ in
type = types.bool; type = types.bool;
# 2019-05-25: Backwards compatibility. # 2019-05-25: Backwards compatibility.
default = cfg.interfaces != {}; default = cfg.interfaces != {};
defaultText = literalExpression "config.${opt.interfaces} != { }";
example = true; example = true;
}; };

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, utils, ... }: { config, lib, options, pkgs, utils, ... }:
with lib; with lib;
@ -8,6 +8,7 @@ let
else pkgs.wpa_supplicant; else pkgs.wpa_supplicant;
cfg = config.networking.wireless; cfg = config.networking.wireless;
opt = options.networking.wireless;
# Content of wpa_supplicant.conf # Content of wpa_supplicant.conf
generatedConfig = concatStringsSep "\n" ( generatedConfig = concatStringsSep "\n" (
@ -421,6 +422,7 @@ in {
dbusControlled = mkOption { dbusControlled = mkOption {
type = types.bool; type = types.bool;
default = lib.length cfg.interfaces < 2; default = lib.length cfg.interfaces < 2;
defaultText = literalExpression "length config.${opt.interfaces} < 2";
description = '' description = ''
Whether to enable the DBus control interface. Whether to enable the DBus control interface.
This is only needed when using NetworkManager or connman. This is only needed when using NetworkManager or connman.

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.kibana; cfg = config.services.kibana;
opt = options.services.kibana;
ge7 = builtins.compareVersions cfg.package.version "7" >= 0; ge7 = builtins.compareVersions cfg.package.version "7" >= 0;
lt6_6 = builtins.compareVersions cfg.package.version "6.6" < 0; lt6_6 = builtins.compareVersions cfg.package.version "6.6" < 0;
@ -130,6 +131,9 @@ in {
This defaults to the singleton list [ca] when the <option>ca</option> option is defined. This defaults to the singleton list [ca] when the <option>ca</option> option is defined.
''; '';
default = if cfg.elasticsearch.ca == null then [] else [ca]; default = if cfg.elasticsearch.ca == null then [] else [ca];
defaultText = literalExpression ''
if config.${opt.elasticsearch.ca} == null then [ ] else [ ca ]
'';
type = types.listOf types.path; type = types.listOf types.path;
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.privacyidea; cfg = config.services.privacyidea;
opt = options.services.privacyidea;
uwsgi = pkgs.uwsgi.override { plugins = [ "python3" ]; }; uwsgi = pkgs.uwsgi.override { plugins = [ "python3" ]; };
python = uwsgi.python3; python = uwsgi.python3;
@ -112,6 +113,7 @@ in
encFile = mkOption { encFile = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/enckey"; default = "${cfg.stateDir}/enckey";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/enckey"'';
description = '' description = ''
This is used to encrypt the token data and token passwords This is used to encrypt the token data and token passwords
''; '';
@ -120,6 +122,7 @@ in
auditKeyPrivate = mkOption { auditKeyPrivate = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/private.pem"; default = "${cfg.stateDir}/private.pem";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/private.pem"'';
description = '' description = ''
Private Key for signing the audit log. Private Key for signing the audit log.
''; '';
@ -128,6 +131,7 @@ in
auditKeyPublic = mkOption { auditKeyPublic = mkOption {
type = types.str; type = types.str;
default = "${cfg.stateDir}/public.pem"; default = "${cfg.stateDir}/public.pem";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/public.pem"'';
description = '' description = ''
Public key for checking signatures of the audit log. Public key for checking signatures of the audit log.
''; '';

View file

@ -1,10 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with builtins; with builtins;
with lib; with lib;
let let
cfg = config.services.tor; cfg = config.services.tor;
opt = options.services.tor;
stateDir = "/var/lib/tor"; stateDir = "/var/lib/tor";
runDir = "/run/tor"; runDir = "/run/tor";
descriptionGeneric = option: '' descriptionGeneric = option: ''
@ -799,6 +800,11 @@ in
options.SOCKSPort = mkOption { options.SOCKSPort = mkOption {
description = descriptionGeneric "SOCKSPort"; description = descriptionGeneric "SOCKSPort";
default = if cfg.settings.HiddenServiceNonAnonymousMode == true then [{port = 0;}] else []; default = if cfg.settings.HiddenServiceNonAnonymousMode == true then [{port = 0;}] else [];
defaultText = literalExpression ''
if config.${opt.settings}.HiddenServiceNonAnonymousMode == true
then [ { port = 0; } ]
else [ ]
'';
example = [{port = 9090;}]; example = [{port = 9090;}];
type = types.listOf (optionSOCKSPort true); type = types.listOf (optionSOCKSPort true);
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.vault; cfg = config.services.vault;
opt = options.services.vault;
configFile = pkgs.writeText "vault.hcl" '' configFile = pkgs.writeText "vault.hcl" ''
listener "tcp" { listener "tcp" {
@ -83,6 +84,11 @@ in
storagePath = mkOption { storagePath = mkOption {
type = types.nullOr types.path; type = types.nullOr types.path;
default = if cfg.storageBackend == "file" then "/var/lib/vault" else null; default = if cfg.storageBackend == "file" then "/var/lib/vault" else null;
defaultText = literalExpression ''
if config.${opt.storageBackend} == "file"
then "/var/lib/vault"
else null
'';
description = "Data directory for file backend"; description = "Data directory for file backend";
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.peerflix; cfg = config.services.peerflix;
opt = options.services.peerflix;
configFile = pkgs.writeText "peerflix-config.json" '' configFile = pkgs.writeText "peerflix-config.json" ''
{ {
@ -32,6 +33,7 @@ in {
downloadDir = mkOption { downloadDir = mkOption {
description = "Peerflix temporary download directory."; description = "Peerflix temporary download directory.";
default = "${cfg.stateDir}/torrents"; default = "${cfg.stateDir}/torrents";
defaultText = literalExpression ''"''${config.${opt.stateDir}}/torrents"'';
type = types.path; type = types.path;
}; };
}; };

View file

@ -1,10 +1,11 @@
{ config, pkgs, lib, ... }: { config, options, pkgs, lib, ... }:
with lib; with lib;
let let
cfg = config.services.rtorrent; cfg = config.services.rtorrent;
opt = options.services.rtorrent;
in { in {
options.services.rtorrent = { options.services.rtorrent = {
@ -21,6 +22,7 @@ in {
downloadDir = mkOption { downloadDir = mkOption {
type = types.str; type = types.str;
default = "${cfg.dataDir}/download"; default = "${cfg.dataDir}/download";
defaultText = literalExpression ''"''${config.${opt.dataDir}}/download"'';
description = '' description = ''
Where to put downloaded files. Where to put downloaded files.
''; '';

View file

@ -4,6 +4,7 @@ with lib;
let let
cfg = config.services.transmission; cfg = config.services.transmission;
opt = options.services.transmission;
inherit (config.environment) etc; inherit (config.environment) etc;
apparmor = config.security.apparmor; apparmor = config.security.apparmor;
rootDir = "/run/transmission"; rootDir = "/run/transmission";
@ -47,11 +48,13 @@ in
options.download-dir = mkOption { options.download-dir = mkOption {
type = types.path; type = types.path;
default = "${cfg.home}/${downloadsDir}"; default = "${cfg.home}/${downloadsDir}";
defaultText = literalExpression ''"''${config.${opt.home}}/${downloadsDir}"'';
description = "Directory where to download torrents."; description = "Directory where to download torrents.";
}; };
options.incomplete-dir = mkOption { options.incomplete-dir = mkOption {
type = types.path; type = types.path;
default = "${cfg.home}/${incompleteDir}"; default = "${cfg.home}/${incompleteDir}";
defaultText = literalExpression ''"''${config.${opt.home}}/${incompleteDir}"'';
description = '' description = ''
When enabled with When enabled with
services.transmission.home services.transmission.home
@ -147,6 +150,7 @@ in
options.watch-dir = mkOption { options.watch-dir = mkOption {
type = types.path; type = types.path;
default = "${cfg.home}/${watchDir}"; default = "${cfg.home}/${watchDir}";
defaultText = literalExpression ''"''${config.${opt.home}}/${watchDir}"'';
description = "Watch a directory for torrent files and add them to transmission."; description = "Watch a directory for torrent files and add them to transmission.";
}; };
options.watch-dir-enabled = mkOption { options.watch-dir-enabled = mkOption {

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.epgstation; cfg = config.services.epgstation;
opt = options.services.epgstation;
username = config.users.users.epgstation.name; username = config.users.users.epgstation.name;
groupname = config.users.users.epgstation.group; groupname = config.users.users.epgstation.group;
@ -72,6 +73,7 @@ in
socketioPort = mkOption { socketioPort = mkOption {
type = types.port; type = types.port;
default = cfg.port + 1; default = cfg.port + 1;
defaultText = literalExpression "config.${opt.port} + 1";
description = '' description = ''
Socket.io port for EPGStation to listen on. Socket.io port for EPGStation to listen on.
''; '';
@ -80,6 +82,7 @@ in
clientSocketioPort = mkOption { clientSocketioPort = mkOption {
type = types.port; type = types.port;
default = cfg.socketioPort; default = cfg.socketioPort;
defaultText = literalExpression "config.${opt.socketioPort}";
description = '' description = ''
Socket.io port that the web client is going to connect to. This may be Socket.io port that the web client is going to connect to. This may be
different from <option>socketioPort</option> if EPGStation is hidden different from <option>socketioPort</option> if EPGStation is hidden
@ -183,6 +186,9 @@ in
in { in {
type = types.str; type = types.str;
default = "http+unix://${replaceStrings ["/"] ["%2F"] sockPath}"; default = "http+unix://${replaceStrings ["/"] ["%2F"] sockPath}";
defaultText = literalExpression ''
"http+unix://''${replaceStrings ["/"] ["%2F"] config.${options.services.mirakurun.unixSocket}}"
'';
example = "http://localhost:40772"; example = "http://localhost:40772";
description = "URL to connect to Mirakurun."; description = "URL to connect to Mirakurun.";
}); });

View file

@ -1,7 +1,8 @@
{ config, lib, pkgs, utils, ... }: { config, lib, options, pkgs, utils, ... }:
with lib; with lib;
let let
cfg = config.services.unifi-video; cfg = config.services.unifi-video;
opt = options.services.unifi-video;
mainClass = "com.ubnt.airvision.Main"; mainClass = "com.ubnt.airvision.Main";
cmd = '' cmd = ''
${pkgs.jsvc}/bin/jsvc \ ${pkgs.jsvc}/bin/jsvc \
@ -164,6 +165,7 @@ in
pidFile = mkOption { pidFile = mkOption {
type = types.path; type = types.path;
default = "${cfg.dataDir}/unifi-video.pid"; default = "${cfg.dataDir}/unifi-video.pid";
defaultText = literalExpression ''"''${config.${opt.dataDir}}/unifi-video.pid"'';
description = "Location of unifi-video pid file."; description = "Location of unifi-video pid file.";
}; };

View file

@ -4,6 +4,7 @@ let
json = pkgs.formats.json {}; json = pkgs.formats.json {};
cfg = config.services.discourse; cfg = config.services.discourse;
opt = options.services.discourse;
# Keep in sync with https://github.com/discourse/discourse_docker/blob/master/image/base/Dockerfile#L5 # Keep in sync with https://github.com/discourse/discourse_docker/blob/master/image/base/Dockerfile#L5
upstreamPostgresqlVersion = lib.getVersion pkgs.postgresql_13; upstreamPostgresqlVersion = lib.getVersion pkgs.postgresql_13;
@ -327,6 +328,7 @@ in
useSSL = lib.mkOption { useSSL = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = cfg.redis.host != "localhost"; default = cfg.redis.host != "localhost";
defaultText = lib.literalExpression ''config.${opt.redis.host} != "localhost"'';
description = '' description = ''
Connect to Redis with SSL. Connect to Redis with SSL.
''; '';
@ -399,6 +401,7 @@ in
domain = lib.mkOption { domain = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = cfg.hostname; default = cfg.hostname;
defaultText = lib.literalExpression "config.${opt.hostname}";
description = '' description = ''
HELO domain to use for outgoing mail. HELO domain to use for outgoing mail.
''; '';

View file

@ -1,8 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.galene; cfg = config.services.galene;
opt = options.services.galene;
defaultstateDir = "/var/lib/galene"; defaultstateDir = "/var/lib/galene";
defaultrecordingsDir = "${cfg.stateDir}/recordings"; defaultrecordingsDir = "${cfg.stateDir}/recordings";
defaultgroupsDir = "${cfg.stateDir}/groups"; defaultgroupsDir = "${cfg.stateDir}/groups";
@ -88,6 +89,7 @@ in
recordingsDir = mkOption { recordingsDir = mkOption {
type = types.str; type = types.str;
default = defaultrecordingsDir; default = defaultrecordingsDir;
defaultText = literalExpression ''"''${config.${opt.stateDir}}/recordings"'';
example = "/var/lib/galene/recordings"; example = "/var/lib/galene/recordings";
description = "Recordings directory."; description = "Recordings directory.";
}; };
@ -95,6 +97,7 @@ in
dataDir = mkOption { dataDir = mkOption {
type = types.str; type = types.str;
default = defaultdataDir; default = defaultdataDir;
defaultText = literalExpression ''"''${config.${opt.stateDir}}/data"'';
example = "/var/lib/galene/data"; example = "/var/lib/galene/data";
description = "Data directory."; description = "Data directory.";
}; };
@ -102,6 +105,7 @@ in
groupsDir = mkOption { groupsDir = mkOption {
type = types.str; type = types.str;
default = defaultgroupsDir; default = defaultgroupsDir;
defaultText = literalExpression ''"''${config.${opt.stateDir}}/groups"'';
example = "/var/lib/galene/groups"; example = "/var/lib/galene/groups";
description = "Web server directory."; description = "Web server directory.";
}; };

View file

@ -33,7 +33,7 @@ in
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
description = '' description = ''
Groups to which the user ${name} should be added. Groups to which the service user should be added.
''; '';
}; };

View file

@ -225,6 +225,7 @@ in
port = lib.mkOption { port = lib.mkOption {
type = types.port; type = types.port;
default = options.services.postgresql.port.default; default = options.services.postgresql.port.default;
defaultText = lib.literalExpression "options.services.postgresql.port.default";
description = '' description = ''
The port of the database Invidious should use. The port of the database Invidious should use.

View file

@ -1,7 +1,8 @@
{ config, pkgs, lib, ... }: { config, options, pkgs, lib, ... }:
let let
cfg = config.services.keycloak; cfg = config.services.keycloak;
opt = options.services.keycloak;
in in
{ {
options.services.keycloak = { options.services.keycloak = {
@ -139,6 +140,7 @@ in
lib.mkOption { lib.mkOption {
type = lib.types.port; type = lib.types.port;
default = dbPorts.${cfg.database.type}; default = dbPorts.${cfg.database.type};
defaultText = lib.literalDocBook "default port of selected database";
description = '' description = ''
Port of the database to connect to. Port of the database to connect to.
''; '';
@ -147,6 +149,7 @@ in
useSSL = lib.mkOption { useSSL = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = cfg.database.host != "localhost"; default = cfg.database.host != "localhost";
defaultText = lib.literalExpression ''config.${opt.database.host} != "localhost"'';
description = '' description = ''
Whether the database connection should be secured by SSL / Whether the database connection should be secured by SSL /
TLS. TLS.

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.matomo; cfg = config.services.matomo;
@ -12,10 +12,7 @@ let
phpExecutionUnit = "phpfpm-${pool}"; phpExecutionUnit = "phpfpm-${pool}";
databaseService = "mysql.service"; databaseService = "mysql.service";
fqdn = fqdn = if config.networking.domain != null then config.networking.fqdn else config.networking.hostName;
let
join = hostName: domain: hostName + optionalString (domain != null) ".${domain}";
in join config.networking.hostName config.networking.domain;
in { in {
imports = [ imports = [
@ -81,9 +78,14 @@ in {
hostname = mkOption { hostname = mkOption {
type = types.str; type = types.str;
default = "${user}.${fqdn}"; 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"; example = "matomo.yourdomain.org";
description = '' description = ''
URL of the host, without https prefix. By default, this is ${user}.${fqdn}, but you may want to change it if you URL of the host, without https prefix. You may want to change it if you
run Matomo on a different URL than matomo.yourdomain. run Matomo on a different URL than matomo.yourdomain.
''; '';
}; };

View file

@ -499,6 +499,7 @@ in {
occ = mkOption { occ = mkOption {
type = types.package; type = types.package;
default = occ; default = occ;
defaultText = literalDocBook "generated script";
internal = true; internal = true;
description = '' description = ''
The nextcloud-occ program preconfigured to target this Nextcloud instance. The nextcloud-occ program preconfigured to target this Nextcloud instance.

View file

@ -1,7 +1,8 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, options, ... }:
let let
cfg = config.services.peertube; cfg = config.services.peertube;
opt = options.services.peertube;
settingsFormat = pkgs.formats.json {}; settingsFormat = pkgs.formats.json {};
configFile = settingsFormat.generate "production.json" cfg.settings; configFile = settingsFormat.generate "production.json" cfg.settings;
@ -153,6 +154,11 @@ in {
host = lib.mkOption { host = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = if cfg.database.createLocally then "/run/postgresql" else null; default = if cfg.database.createLocally then "/run/postgresql" else null;
defaultText = lib.literalExpression ''
if config.${opt.database.createLocally}
then "/run/postgresql"
else null
'';
example = "192.168.15.47"; example = "192.168.15.47";
description = "Database host address or unix socket."; description = "Database host address or unix socket.";
}; };
@ -193,12 +199,22 @@ in {
host = lib.mkOption { host = lib.mkOption {
type = lib.types.nullOr lib.types.str; type = lib.types.nullOr lib.types.str;
default = if cfg.redis.createLocally && !cfg.redis.enableUnixSocket then "127.0.0.1" else null; default = if cfg.redis.createLocally && !cfg.redis.enableUnixSocket then "127.0.0.1" else null;
defaultText = lib.literalExpression ''
if config.${opt.redis.createLocally} && !config.${opt.redis.enableUnixSocket}
then "127.0.0.1"
else null
'';
description = "Redis host."; description = "Redis host.";
}; };
port = lib.mkOption { port = lib.mkOption {
type = lib.types.nullOr lib.types.port; type = lib.types.nullOr lib.types.port;
default = if cfg.redis.createLocally && cfg.redis.enableUnixSocket then null else 6379; default = if cfg.redis.createLocally && cfg.redis.enableUnixSocket then null else 6379;
defaultText = lib.literalExpression ''
if config.${opt.redis.createLocally} && config.${opt.redis.enableUnixSocket}
then null
else 6379
'';
description = "Redis port."; description = "Redis port.";
}; };
@ -212,6 +228,7 @@ in {
enableUnixSocket = lib.mkOption { enableUnixSocket = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = cfg.redis.createLocally; default = cfg.redis.createLocally;
defaultText = lib.literalExpression "config.${opt.redis.createLocally}";
description = "Use Unix socket."; description = "Use Unix socket.";
}; };
}; };

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
@ -6,6 +6,7 @@ let
cfg = config.services.pgpkeyserver-lite; cfg = config.services.pgpkeyserver-lite;
sksCfg = config.services.sks; sksCfg = config.services.sks;
sksOpt = options.services.sks;
webPkg = cfg.package; webPkg = cfg.package;
@ -37,6 +38,7 @@ in
hkpAddress = mkOption { hkpAddress = mkOption {
default = builtins.head sksCfg.hkpAddress; default = builtins.head sksCfg.hkpAddress;
defaultText = literalExpression "head config.${sksOpt.hkpAddress}";
type = types.str; type = types.str;
description = " description = "
Wich ip address the sks-keyserver is listening on. Wich ip address the sks-keyserver is listening on.
@ -45,6 +47,7 @@ in
hkpPort = mkOption { hkpPort = mkOption {
default = sksCfg.hkpPort; default = sksCfg.hkpPort;
defaultText = literalExpression "config.${sksOpt.hkpPort}";
type = types.int; type = types.int;
description = " description = "
Which port the sks-keyserver is listening on. Which port the sks-keyserver is listening on.

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
let let
@ -6,6 +6,7 @@ let
inherit (lib) literalExpression mapAttrs optionalString versionAtLeast; inherit (lib) literalExpression mapAttrs optionalString versionAtLeast;
cfg = config.services.zabbixWeb; cfg = config.services.zabbixWeb;
opt = options.services.zabbixWeb;
fpm = config.services.phpfpm.pools.zabbix; fpm = config.services.phpfpm.pools.zabbix;
user = "zabbix"; user = "zabbix";
@ -82,6 +83,11 @@ in
if cfg.database.type == "mysql" then config.services.mysql.port if cfg.database.type == "mysql" then config.services.mysql.port
else if cfg.database.type == "pgsql" then config.services.postgresql.port else if cfg.database.type == "pgsql" then config.services.postgresql.port
else 1521; else 1521;
defaultText = literalExpression ''
if config.${opt.database.type} == "mysql" then config.${options.services.mysql.port}
else if config.${opt.database.type} == "pgsql" then config.${options.services.postgresql.port}
else 1521
'';
description = "Database host port."; description = "Database host port.";
}; };

View file

@ -1,9 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.lighttpd.collectd; cfg = config.services.lighttpd.collectd;
opt = options.services.lighttpd.collectd;
collectionConf = pkgs.writeText "collection.conf" '' collectionConf = pkgs.writeText "collection.conf" ''
datadir: "${config.services.collectd.dataDir}" datadir: "${config.services.collectd.dataDir}"
@ -29,6 +30,9 @@ in
collectionCgi = mkOption { collectionCgi = mkOption {
type = types.path; type = types.path;
default = defaultCollectionCgi; default = defaultCollectionCgi;
defaultText = literalDocBook ''
<literal>config.${options.services.collectd.package}</literal> configured for lighttpd
'';
description = '' description = ''
Path to collection.cgi script from (collectd sources)/contrib/collection.cgi Path to collection.cgi script from (collectd sources)/contrib/collection.cgi
This option allows to use a customized version This option allows to use a customized version

View file

@ -7,13 +7,14 @@
# (e.g., KDE, Gnome or a plain xterm), and optionally the *window # (e.g., KDE, Gnome or a plain xterm), and optionally the *window
# manager* (e.g. kwin or twm). # manager* (e.g. kwin or twm).
{ config, lib, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib; with lib;
let let
cfg = config.services.xserver; cfg = config.services.xserver;
opt = options.services.xserver;
xorg = pkgs.xorg; xorg = pkgs.xorg;
fontconfig = config.fonts.fontconfig; fontconfig = config.fonts.fontconfig;
@ -147,6 +148,7 @@ in
xauthBin = mkOption { xauthBin = mkOption {
internal = true; internal = true;
default = "${xorg.xauth}/bin/xauth"; default = "${xorg.xauth}/bin/xauth";
defaultText = literalExpression ''"''${pkgs.xorg.xauth}/bin/xauth"'';
description = "Path to the <command>xauth</command> program used by display managers."; description = "Path to the <command>xauth</command> program used by display managers.";
}; };
@ -278,6 +280,9 @@ in
defaultSessionFromLegacyOptions defaultSessionFromLegacyOptions
else else
null; null;
defaultText = literalDocBook ''
Taken from display manager settings or window manager settings, if either is set.
'';
example = "gnome"; example = "gnome";
description = '' description = ''
Graphical session to pre-select in the session chooser (only effective for GDM, LightDM and SDDM). Graphical session to pre-select in the session chooser (only effective for GDM, LightDM and SDDM).
@ -337,11 +342,12 @@ in
# Configuration for automatic login. Common for all DM. # Configuration for automatic login. Common for all DM.
autoLogin = mkOption { autoLogin = mkOption {
type = types.submodule { type = types.submodule ({ config, options, ... }: {
options = { options = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = cfg.displayManager.autoLogin.user != null; default = config.user != null;
defaultText = literalExpression "config.${options.user} != null";
description = '' description = ''
Automatically log in as <option>autoLogin.user</option>. Automatically log in as <option>autoLogin.user</option>.
''; '';
@ -355,7 +361,7 @@ in
''; '';
}; };
}; };
}; });
default = {}; default = {};
description = '' description = ''

Some files were not shown because too many files have changed in this diff Show more