treewide: add defaultText for options with simple cfg.* expression defaults
adds defaultText for options with defaults that use only literals, full config.* paths, and the cfg shortcut binding.
This commit is contained in:
parent
fb0e5be843
commit
ed673a69db
|
@ -1,9 +1,10 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{ config, options, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.kubernetes.addons.dashboard;
|
||||
opt = options.services.kubernetes.addons.dashboard;
|
||||
in {
|
||||
imports = [
|
||||
(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";
|
||||
type = types.bool;
|
||||
default = elem "RBAC" config.services.kubernetes.apiserver.authorizationMode;
|
||||
defaultText = literalExpression ''
|
||||
elem "RBAC" config.${options.services.kubernetes.apiserver.authorizationMode}
|
||||
'';
|
||||
};
|
||||
|
||||
clusterAdmin = mkOption {
|
||||
|
@ -54,6 +58,14 @@ in {
|
|||
finalImageTag = cfg.version;
|
||||
sha256 = "01xrr4pwgr2hcjrjsi3d14ifpzdfbxzqpzxbk2fkbjb9zkv38zxy";
|
||||
};
|
||||
defaultText = literalExpression ''
|
||||
{
|
||||
imageName = "k8s.gcr.io/kubernetes-dashboard-amd64";
|
||||
imageDigest = "sha256:0ae6b69432e78069c5ce2bcde0fe409c5c4d6f0f4d9cd50a17974fea38898747";
|
||||
finalImageTag = config.${opt.version};
|
||||
sha256 = "01xrr4pwgr2hcjrjsi3d14ifpzdfbxzqpzxbk2fkbjb9zkv38zxy";
|
||||
};
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -310,6 +310,7 @@ in {
|
|||
backup.path = mkOption {
|
||||
type = types.str;
|
||||
default = cfg.statePath + "/backup";
|
||||
defaultText = literalExpression ''config.${opt.statePath} + "/backup"'';
|
||||
description = "GitLab path for backups.";
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
pkg = pkgs.moonraker;
|
||||
cfg = config.services.moonraker;
|
||||
opt = options.services.moonraker;
|
||||
format = pkgs.formats.ini {
|
||||
# https://github.com/NixOS/nixpkgs/pull/121613#issuecomment-885241996
|
||||
listToValue = l:
|
||||
|
@ -30,6 +31,7 @@ in {
|
|||
configDir = mkOption {
|
||||
type = types.path;
|
||||
default = cfg.stateDir + "/config";
|
||||
defaultText = literalExpression ''config.${opt.stateDir} + "/config"'';
|
||||
description = ''
|
||||
The directory containing client-writable configuration files.
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.parsedmarc;
|
||||
opt = options.services.parsedmarc;
|
||||
ini = pkgs.formats.ini {};
|
||||
in
|
||||
{
|
||||
|
@ -80,6 +81,9 @@ in
|
|||
datasource = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
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;
|
||||
description = ''
|
||||
Whether the automatically provisioned Elasticsearch
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{ config, options, pkgs, lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption mkEnableOption mkIf mkMerge types optional;
|
||||
inherit (lib) literalExpression mkOption mkEnableOption mkIf mkMerge types optional;
|
||||
|
||||
cfg = config.services.uptime;
|
||||
opt = options.services.uptime;
|
||||
|
||||
configDir = pkgs.runCommand "config" { preferLocalBuild = true; }
|
||||
(if cfg.configFile != null then ''
|
||||
|
@ -52,7 +53,10 @@ in {
|
|||
|
||||
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 {
|
||||
description = "The node environment to run in (development, production, etc.)";
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.networking.wireguard;
|
||||
opt = options.networking.wireguard;
|
||||
|
||||
kernel = config.boot.kernelPackages;
|
||||
|
||||
|
@ -438,6 +439,7 @@ in
|
|||
type = types.bool;
|
||||
# 2019-05-25: Backwards compatibility.
|
||||
default = cfg.interfaces != {};
|
||||
defaultText = literalExpression "config.${opt.interfaces} != { }";
|
||||
example = true;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, utils, ... }:
|
||||
{ config, lib, options, pkgs, utils, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
|
@ -8,6 +8,7 @@ let
|
|||
else pkgs.wpa_supplicant;
|
||||
|
||||
cfg = config.networking.wireless;
|
||||
opt = options.networking.wireless;
|
||||
|
||||
# Content of wpa_supplicant.conf
|
||||
generatedConfig = concatStringsSep "\n" (
|
||||
|
@ -421,6 +422,7 @@ in {
|
|||
dbusControlled = mkOption {
|
||||
type = types.bool;
|
||||
default = lib.length cfg.interfaces < 2;
|
||||
defaultText = literalExpression "length config.${opt.interfaces} < 2";
|
||||
description = ''
|
||||
Whether to enable the DBus control interface.
|
||||
This is only needed when using NetworkManager or connman.
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.kibana;
|
||||
opt = options.services.kibana;
|
||||
|
||||
ge7 = builtins.compareVersions cfg.package.version "7" >= 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.
|
||||
'';
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
with builtins;
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.tor;
|
||||
opt = options.services.tor;
|
||||
stateDir = "/var/lib/tor";
|
||||
runDir = "/run/tor";
|
||||
descriptionGeneric = option: ''
|
||||
|
@ -799,6 +800,11 @@ in
|
|||
options.SOCKSPort = mkOption {
|
||||
description = descriptionGeneric "SOCKSPort";
|
||||
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;}];
|
||||
type = types.listOf (optionSOCKSPort true);
|
||||
};
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.vault;
|
||||
opt = options.services.vault;
|
||||
|
||||
configFile = pkgs.writeText "vault.hcl" ''
|
||||
listener "tcp" {
|
||||
|
@ -83,6 +84,11 @@ in
|
|||
storagePath = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
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";
|
||||
};
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ in
|
|||
socketioPort = mkOption {
|
||||
type = types.port;
|
||||
default = cfg.port + 1;
|
||||
defaultText = literalExpression "config.${opt.port} + 1";
|
||||
description = ''
|
||||
Socket.io port for EPGStation to listen on.
|
||||
'';
|
||||
|
|
|
@ -328,6 +328,7 @@ in
|
|||
useSSL = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = cfg.redis.host != "localhost";
|
||||
defaultText = lib.literalExpression ''config.${opt.redis.host} != "localhost"'';
|
||||
description = ''
|
||||
Connect to Redis with SSL.
|
||||
'';
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{ config, options, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.keycloak;
|
||||
opt = options.services.keycloak;
|
||||
in
|
||||
{
|
||||
options.services.keycloak = {
|
||||
|
@ -147,6 +148,7 @@ in
|
|||
useSSL = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = cfg.database.host != "localhost";
|
||||
defaultText = lib.literalExpression ''config.${opt.database.host} != "localhost"'';
|
||||
description = ''
|
||||
Whether the database connection should be secured by SSL /
|
||||
TLS.
|
||||
|
|
|
@ -154,6 +154,11 @@ in {
|
|||
host = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
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";
|
||||
description = "Database host address or unix socket.";
|
||||
};
|
||||
|
@ -194,12 +199,22 @@ in {
|
|||
host = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
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.";
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.port;
|
||||
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.";
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
|
@ -6,6 +6,7 @@ let
|
|||
inherit (lib) literalExpression mapAttrs optionalString versionAtLeast;
|
||||
|
||||
cfg = config.services.zabbixWeb;
|
||||
opt = options.services.zabbixWeb;
|
||||
fpm = config.services.phpfpm.pools.zabbix;
|
||||
|
||||
user = "zabbix";
|
||||
|
@ -82,6 +83,11 @@ in
|
|||
if cfg.database.type == "mysql" then config.services.mysql.port
|
||||
else if cfg.database.type == "pgsql" then config.services.postgresql.port
|
||||
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.";
|
||||
};
|
||||
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
# (e.g., KDE, Gnome or a plain xterm), and optionally the *window
|
||||
# manager* (e.g. kwin or twm).
|
||||
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.xserver;
|
||||
opt = options.services.xserver;
|
||||
xorg = pkgs.xorg;
|
||||
|
||||
fontconfig = config.fonts.fontconfig;
|
||||
|
@ -337,11 +338,12 @@ in
|
|||
|
||||
# Configuration for automatic login. Common for all DM.
|
||||
autoLogin = mkOption {
|
||||
type = types.submodule {
|
||||
type = types.submodule ({ config, options, ... }: {
|
||||
options = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = cfg.displayManager.autoLogin.user != null;
|
||||
default = config.user != null;
|
||||
defaultText = literalExpression "config.${options.user} != null";
|
||||
description = ''
|
||||
Automatically log in as <option>autoLogin.user</option>.
|
||||
'';
|
||||
|
@ -355,7 +357,7 @@ in
|
|||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
default = {};
|
||||
description = ''
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, options, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.picom;
|
||||
opt = options.services.picom;
|
||||
|
||||
pairOf = x: with types;
|
||||
addCheck (listOf x) (y: length y == 2)
|
||||
|
@ -178,7 +179,16 @@ in {
|
|||
|
||||
wintypes = mkOption {
|
||||
type = types.attrs;
|
||||
default = { popup_menu = { opacity = cfg.menuOpacity; }; dropdown_menu = { opacity = cfg.menuOpacity; }; };
|
||||
default = {
|
||||
popup_menu = { opacity = cfg.menuOpacity; };
|
||||
dropdown_menu = { opacity = cfg.menuOpacity; };
|
||||
};
|
||||
defaultText = literalExpression ''
|
||||
{
|
||||
popup_menu = { opacity = config.${opt.menuOpacity}; };
|
||||
dropdown_menu = { opacity = config.${opt.menuOpacity}; };
|
||||
}
|
||||
'';
|
||||
example = {};
|
||||
description = ''
|
||||
Rules for specific window types.
|
||||
|
|
|
@ -6,6 +6,7 @@ with utils;
|
|||
let
|
||||
|
||||
cfg = config.networking;
|
||||
opt = options.networking;
|
||||
interfaces = attrValues cfg.interfaces;
|
||||
hasVirtuals = any (i: i.virtual) interfaces;
|
||||
hasSits = cfg.sits != { };
|
||||
|
@ -1169,6 +1170,9 @@ in
|
|||
|
||||
networking.tempAddresses = mkOption {
|
||||
default = if cfg.enableIPv6 then "default" else "disabled";
|
||||
defaultText = literalExpression ''
|
||||
if ''${config.${opt.enableIPv6}} then "default" else "disabled"
|
||||
'';
|
||||
type = types.enum (lib.attrNames tempaddrValues);
|
||||
description = ''
|
||||
Whether to enable IPv6 Privacy Extensions for interfaces not
|
||||
|
|
Loading…
Reference in New Issue
Block a user