treewide/nixos: remove with lib; part 1 (#335603)

This commit is contained in:
Philip Taron 2024-08-29 15:42:04 -07:00 committed by GitHub
commit 117f3ceb51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
139 changed files with 1940 additions and 2343 deletions

View File

@ -1,10 +1,8 @@
{ config, lib, ... }:
with lib;
{
options = {
appstream.enable = mkOption {
type = types.bool;
appstream.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to install files to support the
@ -13,7 +11,7 @@ with lib;
};
};
config = mkIf config.appstream.enable {
config = lib.mkIf config.appstream.enable {
environment.pathsToLink = [
# per component metadata
"/share/metainfo"

View File

@ -1,27 +1,23 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.console;
makeColor = i: concatMapStringsSep "," (x: "0x" + substring (2*i) 2 x);
makeColor = i: lib.concatMapStringsSep "," (x: "0x" + lib.substring (2*i) 2 x);
isUnicode = hasSuffix "UTF-8" (toUpper config.i18n.defaultLocale);
isUnicode = lib.hasSuffix "UTF-8" (lib.toUpper config.i18n.defaultLocale);
optimizedKeymap = pkgs.runCommand "keymap" {
nativeBuildInputs = [ pkgs.buildPackages.kbd ];
LOADKEYS_KEYMAP_PATH = "${consoleEnv pkgs.kbd}/share/keymaps/**";
preferLocalBuild = true;
} ''
loadkeys -b ${optionalString isUnicode "-u"} "${cfg.keyMap}" > $out
loadkeys -b ${lib.optionalString isUnicode "-u"} "${cfg.keyMap}" > $out
'';
# Sadly, systemd-vconsole-setup doesn't support binary keymaps.
vconsoleConf = pkgs.writeText "vconsole.conf" ''
KEYMAP=${cfg.keyMap}
${optionalString (cfg.font != null) "FONT=${cfg.font}"}
${lib.optionalString (cfg.font != null) "FONT=${cfg.font}"}
'';
consoleEnv = kbd: pkgs.buildEnv {
@ -40,12 +36,12 @@ in
###### interface
options.console = {
enable = mkEnableOption "virtual console" // {
enable = lib.mkEnableOption "virtual console" // {
default = true;
};
font = mkOption {
type = with types; nullOr (either str path);
font = lib.mkOption {
type = with lib.types; nullOr (either str path);
default = null;
example = "LatArCyrHeb-16";
description = ''
@ -61,8 +57,8 @@ in
'';
};
keyMap = mkOption {
type = with types; either str path;
keyMap = lib.mkOption {
type = with lib.types; either str path;
default = "us";
example = "fr";
description = ''
@ -70,8 +66,8 @@ in
'';
};
colors = mkOption {
type = with types; listOf (strMatching "[[:xdigit:]]{6}");
colors = lib.mkOption {
type = with lib.types; listOf (strMatching "[[:xdigit:]]{6}");
default = [ ];
example = [
"002b36" "dc322f" "859900" "b58900"
@ -88,8 +84,8 @@ in
};
packages = mkOption {
type = types.listOf types.package;
packages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
description = ''
List of additional packages that provide console fonts, keymaps and
@ -97,8 +93,8 @@ in
'';
};
useXkbConfig = mkOption {
type = types.bool;
useXkbConfig = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
If set, configure the virtual console keymap from the xserver
@ -106,9 +102,9 @@ in
'';
};
earlySetup = mkOption {
earlySetup = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
Enable setting virtual console options as early as possible (in initrd).
'';
@ -119,12 +115,12 @@ in
###### implementation
config = mkMerge [
config = lib.mkMerge [
{ console.keyMap = with config.services.xserver;
mkIf cfg.useXkbConfig
lib.mkIf cfg.useXkbConfig
(pkgs.runCommand "xkb-console-keymap" { preferLocalBuild = true; } ''
'${pkgs.buildPackages.ckbcomp}/bin/ckbcomp' \
${optionalString (config.environment.sessionVariables ? XKB_CONFIG_ROOT)
${lib.optionalString (config.environment.sessionVariables ? XKB_CONFIG_ROOT)
"-I${config.environment.sessionVariables.XKB_CONFIG_ROOT}"
} \
-model '${xkb.model}' -layout '${xkb.layout}' \
@ -132,7 +128,7 @@ in
'');
}
(mkIf (!cfg.enable) {
(lib.mkIf (!cfg.enable) {
systemd.services = {
"serial-getty@ttyS0".enable = false;
"serial-getty@hvc0".enable = false;
@ -142,7 +138,7 @@ in
};
})
(mkIf cfg.enable (mkMerge [
(lib.mkIf cfg.enable (lib.mkMerge [
{ environment.systemPackages = [ pkgs.kbd ];
# Let systemd-vconsole-setup.service do the work of setting up the
@ -151,12 +147,12 @@ in
# Provide kbd with additional packages.
environment.etc.kbd.source = "${consoleEnv pkgs.kbd}/share";
boot.initrd.preLVMCommands = mkIf (!config.boot.initrd.systemd.enable) (mkBefore ''
boot.initrd.preLVMCommands = lib.mkIf (!config.boot.initrd.systemd.enable) (lib.mkBefore ''
kbd_mode ${if isUnicode then "-u" else "-a"} -C /dev/console
printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console
loadkmap < ${optimizedKeymap}
${optionalString (cfg.earlySetup && cfg.font != null) ''
${lib.optionalString (cfg.earlySetup && cfg.font != null) ''
setfont -C /dev/console $extraUtils/share/consolefonts/font.psf
''}
'');
@ -176,9 +172,9 @@ in
"${config.boot.initrd.systemd.package.kbd}/bin/setfont"
"${config.boot.initrd.systemd.package.kbd}/bin/loadkeys"
"${config.boot.initrd.systemd.package.kbd.gzip}/bin/gzip" # Fonts and keyboard layouts are compressed
] ++ optionals (cfg.font != null && hasPrefix builtins.storeDir cfg.font) [
] ++ lib.optionals (cfg.font != null && lib.hasPrefix builtins.storeDir cfg.font) [
"${cfg.font}"
] ++ optionals (hasPrefix builtins.storeDir cfg.keyMap) [
] ++ lib.optionals (lib.hasPrefix builtins.storeDir cfg.keyMap) [
"${cfg.keyMap}"
];
@ -195,7 +191,7 @@ in
};
}
(mkIf (cfg.colors != []) {
(lib.mkIf (cfg.colors != []) {
boot.kernelParams = [
"vt.default_red=${makeColor 0 cfg.colors}"
"vt.default_grn=${makeColor 1 cfg.colors}"
@ -203,10 +199,10 @@ in
];
})
(mkIf (cfg.earlySetup && cfg.font != null && !config.boot.initrd.systemd.enable) {
(lib.mkIf (cfg.earlySetup && cfg.font != null && !config.boot.initrd.systemd.enable) {
boot.initrd.extraUtilsCommands = ''
mkdir -p $out/share/consolefonts
${if substring 0 1 cfg.font == "/" then ''
${if lib.substring 0 1 cfg.font == "/" then ''
font="${cfg.font}"
'' else ''
font="$(echo ${consoleEnv pkgs.kbd}/share/consolefonts/${cfg.font}.*)"
@ -222,14 +218,14 @@ in
];
imports = [
(mkRenamedOptionModule [ "i18n" "consoleFont" ] [ "console" "font" ])
(mkRenamedOptionModule [ "i18n" "consoleKeyMap" ] [ "console" "keyMap" ])
(mkRenamedOptionModule [ "i18n" "consoleColors" ] [ "console" "colors" ])
(mkRenamedOptionModule [ "i18n" "consolePackages" ] [ "console" "packages" ])
(mkRenamedOptionModule [ "i18n" "consoleUseXkbConfig" ] [ "console" "useXkbConfig" ])
(mkRenamedOptionModule [ "boot" "earlyVconsoleSetup" ] [ "console" "earlySetup" ])
(mkRenamedOptionModule [ "boot" "extraTTYs" ] [ "console" "extraTTYs" ])
(mkRemovedOptionModule [ "console" "extraTTYs" ] ''
(lib.mkRenamedOptionModule [ "i18n" "consoleFont" ] [ "console" "font" ])
(lib.mkRenamedOptionModule [ "i18n" "consoleKeyMap" ] [ "console" "keyMap" ])
(lib.mkRenamedOptionModule [ "i18n" "consoleColors" ] [ "console" "colors" ])
(lib.mkRenamedOptionModule [ "i18n" "consolePackages" ] [ "console" "packages" ])
(lib.mkRenamedOptionModule [ "i18n" "consoleUseXkbConfig" ] [ "console" "useXkbConfig" ])
(lib.mkRenamedOptionModule [ "boot" "earlyVconsoleSetup" ] [ "console" "earlySetup" ])
(lib.mkRenamedOptionModule [ "boot" "extraTTYs" ] [ "console" "extraTTYs" ])
(lib.mkRemovedOptionModule [ "console" "extraTTYs" ] ''
Since NixOS switched to systemd (circa 2012), TTYs have been spawned on
demand, so there is no need to configure them manually.
'')

View File

@ -1,13 +1,10 @@
{ config, lib, ... }:
with lib;
{
options = {
environment.enableDebugInfo = mkOption {
type = types.bool;
environment.enableDebugInfo = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Some NixOS packages provide debug symbols. However, these are
@ -29,7 +26,7 @@ with lib;
};
config = mkIf config.environment.enableDebugInfo {
config = lib.mkIf config.environment.enableDebugInfo {
# FIXME: currently disabled because /lib is already in
# environment.pathsToLink, and we can't have both.

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.fonts.fontDir;
@ -12,7 +9,7 @@ let
find ${toString config.fonts.packages} -regex "$font_regexp" \
-exec ln -sf -t "$out/share/X11/fonts" '{}' \;
cd "$out/share/X11/fonts"
${optionalString cfg.decompressFonts ''
${lib.optionalString cfg.decompressFonts ''
${pkgs.gzip}/bin/gunzip -f *.gz
''}
${pkgs.xorg.mkfontscale}/bin/mkfontscale
@ -27,8 +24,8 @@ in
options = {
fonts.fontDir = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to create a directory with links to all fonts in
@ -36,10 +33,10 @@ in
'';
};
decompressFonts = mkOption {
type = types.bool;
decompressFonts = lib.mkOption {
type = lib.types.bool;
default = config.programs.xwayland.enable;
defaultText = literalExpression "config.programs.xwayland.enable";
defaultText = lib.literalExpression "config.programs.xwayland.enable";
description = ''
Whether to decompress fonts in
{file}`/run/current-system/sw/share/X11/fonts`.
@ -49,7 +46,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ x11Fonts ];
environment.pathsToLink = [ "/share/X11/fonts" ];
@ -61,7 +58,7 @@ in
};
imports = [
(mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
(lib.mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
];
}

View File

@ -1,11 +1,8 @@
{ config, lib, pkgs, ... }:
with lib;
{
options = {
fonts.enableGhostscriptFonts = mkOption {
type = types.bool;
fonts.enableGhostscriptFonts = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to add the fonts provided by Ghostscript (such as
@ -17,7 +14,7 @@ with lib;
};
config = mkIf config.fonts.enableGhostscriptFonts {
config = lib.mkIf config.fonts.enableGhostscriptFonts {
fonts.packages = [ pkgs.ghostscript.fonts ];
};
}

View File

@ -1,19 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
{
options = {
gtk.iconCache.enable = mkOption {
type = types.bool;
gtk.iconCache.enable = lib.mkOption {
type = lib.types.bool;
default = config.services.xserver.enable;
defaultText = literalExpression "config.services.xserver.enable";
defaultText = lib.literalExpression "config.services.xserver.enable";
description = ''
Whether to build icon theme caches for GTK applications.
'';
};
};
config = mkIf config.gtk.iconCache.enable {
config = lib.mkIf config.gtk.iconCache.enable {
# (Re)build icon theme caches
# ---------------------------

View File

@ -1,15 +1,12 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.networking.iproute2;
in
{
options.networking.iproute2 = {
enable = mkEnableOption "copying IP route configuration files";
rttablesExtraConfig = mkOption {
type = types.lines;
enable = lib.mkEnableOption "copying IP route configuration files";
rttablesExtraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Verbatim lines to add to /etc/iproute2/rt_tables
@ -17,7 +14,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.etc."iproute2/rt_tables.d/nixos.conf" = {
mode = "0644";
text = cfg.rttablesExtraConfig;

View File

@ -1,12 +1,9 @@
{ config, lib, pkgs, ... }:
with lib;
let
tzdir = "${pkgs.tzdata}/share/zoneinfo";
nospace = str: filter (c: c == " ") (stringToCharacters str) == [];
timezone = types.nullOr (types.addCheck types.str nospace)
nospace = str: lib.filter (c: c == " ") (lib.stringToCharacters str) == [];
timezone = lib.types.nullOr (lib.types.addCheck lib.types.str nospace)
// { description = "null or string without spaces"; };
lcfg = config.location;
@ -18,7 +15,7 @@ in
time = {
timeZone = mkOption {
timeZone = lib.mkOption {
default = null;
type = timezone;
example = "America/New_York";
@ -31,9 +28,9 @@ in
'';
};
hardwareClockInLocalTime = mkOption {
hardwareClockInLocalTime = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = "If set, keep the hardware clock in local time instead of UTC.";
};
@ -41,8 +38,8 @@ in
location = {
latitude = mkOption {
type = types.float;
latitude = lib.mkOption {
type = lib.types.float;
description = ''
Your current latitude, between
`-90.0` and `90.0`. Must be provided
@ -50,8 +47,8 @@ in
'';
};
longitude = mkOption {
type = types.float;
longitude = lib.mkOption {
type = lib.types.float;
description = ''
Your current longitude, between
between `-180.0` and `180.0`. Must be
@ -59,8 +56,8 @@ in
'';
};
provider = mkOption {
type = types.enum [ "manual" "geoclue2" ];
provider = lib.mkOption {
type = lib.types.enum [ "manual" "geoclue2" ];
default = "manual";
description = ''
The location provider to use for determining your location. If set to
@ -75,7 +72,7 @@ in
environment.sessionVariables.TZDIR = "/etc/zoneinfo";
services.geoclue2.enable = mkIf (lcfg.provider == "geoclue2") true;
services.geoclue2.enable = lib.mkIf (lcfg.provider == "geoclue2") true;
# This way services are restarted when tzdata changes.
systemd.globalEnvironment.TZDIR = tzdir;

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.environment.memoryAllocator;
@ -85,12 +83,12 @@ in
{
meta = {
maintainers = [ maintainers.joachifm ];
maintainers = [ lib.maintainers.joachifm ];
};
options = {
environment.memoryAllocator.provider = mkOption {
type = types.enum ([ "libc" ] ++ attrNames providers);
environment.memoryAllocator.provider = lib.mkOption {
type = lib.types.enum ([ "libc" ] ++ lib.attrNames providers);
default = "libc";
description = ''
The system-wide memory allocator.
@ -98,8 +96,8 @@ in
Briefly, the system-wide memory allocator providers are:
- `libc`: the standard allocator provided by libc
${concatStringsSep "\n" (mapAttrsToList
(name: value: "- `${name}`: ${replaceStrings [ "\n" ] [ " " ] value.description}")
${lib.concatStringsSep "\n" (lib.mapAttrsToList
(name: value: "- `${name}`: ${lib.replaceStrings [ "\n" ] [ " " ] value.description}")
providers)}
::: {.warning}
@ -111,7 +109,7 @@ in
};
};
config = mkIf (cfg.provider != "libc") {
config = lib.mkIf (cfg.provider != "libc") {
environment.etc."ld-nix.so.preload".text = ''
${providerLibPath}
'';

View File

@ -1,28 +1,24 @@
# /etc files related to networking, such as /etc/services.
{ config, lib, options, pkgs, ... }:
with lib;
let
cfg = config.networking;
opt = options.networking;
localhostMultiple = any (elem "localhost") (attrValues (removeAttrs cfg.hosts [ "127.0.0.1" "::1" ]));
localhostMultiple = lib.any (lib.elem "localhost") (lib.attrValues (removeAttrs cfg.hosts [ "127.0.0.1" "::1" ]));
in
{
imports = [
(mkRemovedOptionModule [ "networking" "hostConf" ] "Use environment.etc.\"host.conf\" instead.")
(lib.mkRemovedOptionModule [ "networking" "hostConf" ] "Use environment.etc.\"host.conf\" instead.")
];
options = {
networking.hosts = lib.mkOption {
type = types.attrsOf (types.listOf types.str);
example = literalExpression ''
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
example = lib.literalExpression ''
{
"127.0.0.1" = [ "foo.bar.baz" ];
"192.168.0.2" = [ "fileserver.local" "nameserver.local" ];
@ -34,16 +30,16 @@ in
};
networking.hostFiles = lib.mkOption {
type = types.listOf types.path;
defaultText = literalMD "Hosts from {option}`networking.hosts` and {option}`networking.extraHosts`";
example = literalExpression ''[ "''${pkgs.my-blocklist-package}/share/my-blocklist/hosts" ]'';
type = lib.types.listOf lib.types.path;
defaultText = lib.literalMD "Hosts from {option}`networking.hosts` and {option}`networking.extraHosts`";
example = lib.literalExpression ''[ "''${pkgs.my-blocklist-package}/share/my-blocklist/hosts" ]'';
description = ''
Files that should be concatenated together to form {file}`/etc/hosts`.
'';
};
networking.extraHosts = lib.mkOption {
type = types.lines;
type = lib.types.lines;
default = "";
example = "192.168.0.1 lanlocalhost";
description = ''
@ -52,14 +48,14 @@ in
'';
};
networking.timeServers = mkOption {
networking.timeServers = lib.mkOption {
default = [
"0.nixos.pool.ntp.org"
"1.nixos.pool.ntp.org"
"2.nixos.pool.ntp.org"
"3.nixos.pool.ntp.org"
];
type = types.listOf types.str;
type = lib.types.listOf lib.types.str;
description = ''
The set of NTP servers from which to synchronise.
'';
@ -68,7 +64,7 @@ in
networking.proxy = {
default = lib.mkOption {
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
This option specifies the default value for httpProxy, httpsProxy, ftpProxy and rsyncProxy.
@ -77,9 +73,9 @@ in
};
httpProxy = lib.mkOption {
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
defaultText = lib.literalExpression "config.${opt.proxy.default}";
description = ''
This option specifies the http_proxy environment variable.
'';
@ -87,9 +83,9 @@ in
};
httpsProxy = lib.mkOption {
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
defaultText = lib.literalExpression "config.${opt.proxy.default}";
description = ''
This option specifies the https_proxy environment variable.
'';
@ -97,9 +93,9 @@ in
};
ftpProxy = lib.mkOption {
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
defaultText = lib.literalExpression "config.${opt.proxy.default}";
description = ''
This option specifies the ftp_proxy environment variable.
'';
@ -107,9 +103,9 @@ in
};
rsyncProxy = lib.mkOption {
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
defaultText = lib.literalExpression "config.${opt.proxy.default}";
description = ''
This option specifies the rsync_proxy environment variable.
'';
@ -117,9 +113,9 @@ in
};
allProxy = lib.mkOption {
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
default = cfg.proxy.default;
defaultText = literalExpression "config.${opt.proxy.default}";
defaultText = lib.literalExpression "config.${opt.proxy.default}";
description = ''
This option specifies the all_proxy environment variable.
'';
@ -127,7 +123,7 @@ in
};
noProxy = lib.mkOption {
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
This option specifies the no_proxy environment variable.
@ -138,7 +134,7 @@ in
};
envVars = lib.mkOption {
type = types.attrs;
type = lib.types.attrs;
internal = true;
default = {};
description = ''
@ -163,11 +159,11 @@ in
# hostname and FQDN correctly:
networking.hosts = let
hostnames = # Note: The FQDN (canonical hostname) has to come first:
optional (cfg.hostName != "" && cfg.domain != null) "${cfg.hostName}.${cfg.domain}"
++ optional (cfg.hostName != "") cfg.hostName; # Then the hostname (without the domain)
lib.optional (cfg.hostName != "" && cfg.domain != null) "${cfg.hostName}.${cfg.domain}"
++ lib.optional (cfg.hostName != "") cfg.hostName; # Then the hostname (without the domain)
in {
"127.0.0.2" = hostnames;
} // optionalAttrs cfg.enableIPv6 {
} // lib.optionalAttrs cfg.enableIPv6 {
"::1" = hostnames;
};
@ -178,15 +174,15 @@ in
# FQDN so that e.g. "hostname -f" works correctly.
localhostHosts = pkgs.writeText "localhost-hosts" ''
127.0.0.1 localhost
${optionalString cfg.enableIPv6 "::1 localhost"}
${lib.optionalString cfg.enableIPv6 "::1 localhost"}
'';
stringHosts =
let
oneToString = set: ip: ip + " " + concatStringsSep " " set.${ip} + "\n";
allToString = set: concatMapStrings (oneToString set) (attrNames set);
in pkgs.writeText "string-hosts" (allToString (filterAttrs (_: v: v != []) cfg.hosts));
oneToString = set: ip: ip + " " + lib.concatStringsSep " " set.${ip} + "\n";
allToString = set: lib.concatMapStrings (oneToString set) (lib.attrNames set);
in pkgs.writeText "string-hosts" (allToString (lib.filterAttrs (_: v: v != []) cfg.hosts));
extraHosts = pkgs.writeText "extra-hosts" cfg.extraHosts;
in mkBefore [ localhostHosts stringHosts extraHosts ];
in lib.mkBefore [ localhostHosts stringHosts extraHosts ];
environment.etc =
{ # /etc/services: TCP/UDP port assignments.
@ -199,33 +195,33 @@ in
hosts.source = pkgs.concatText "hosts" cfg.hostFiles;
# /etc/netgroup: Network-wide groups.
netgroup.text = mkDefault "";
netgroup.text = lib.mkDefault "";
# /etc/host.conf: resolver configuration file
"host.conf".text = ''
multi on
'';
} // optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") {
} // lib.optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") {
# /etc/rpc: RPC program numbers.
rpc.source = pkgs.stdenv.cc.libc.out + "/etc/rpc";
};
networking.proxy.envVars =
optionalAttrs (cfg.proxy.default != null) {
lib.optionalAttrs (cfg.proxy.default != null) {
# other options already fallback to proxy.default
no_proxy = "127.0.0.1,localhost";
} // optionalAttrs (cfg.proxy.httpProxy != null) {
} // lib.optionalAttrs (cfg.proxy.httpProxy != null) {
http_proxy = cfg.proxy.httpProxy;
} // optionalAttrs (cfg.proxy.httpsProxy != null) {
} // lib.optionalAttrs (cfg.proxy.httpsProxy != null) {
https_proxy = cfg.proxy.httpsProxy;
} // optionalAttrs (cfg.proxy.rsyncProxy != null) {
} // lib.optionalAttrs (cfg.proxy.rsyncProxy != null) {
rsync_proxy = cfg.proxy.rsyncProxy;
} // optionalAttrs (cfg.proxy.ftpProxy != null) {
} // lib.optionalAttrs (cfg.proxy.ftpProxy != null) {
ftp_proxy = cfg.proxy.ftpProxy;
} // optionalAttrs (cfg.proxy.allProxy != null) {
} // lib.optionalAttrs (cfg.proxy.allProxy != null) {
all_proxy = cfg.proxy.allProxy;
} // optionalAttrs (cfg.proxy.noProxy != null) {
} // lib.optionalAttrs (cfg.proxy.noProxy != null) {
no_proxy = cfg.proxy.noProxy;
};

View File

@ -1,14 +1,10 @@
# This module gets rid of all dependencies on X11 client libraries
# (including fontconfig).
{ config, lib, ... }:
with lib;
{
options = {
environment.noXlibs = mkOption {
type = types.bool;
environment.noXlibs = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Switch off the options in the default configuration that
@ -20,13 +16,13 @@ with lib;
};
};
config = mkIf config.environment.noXlibs {
config = lib.mkIf config.environment.noXlibs {
programs.ssh.setXAuthLocation = false;
security.pam.services.su.forwardXAuth = lib.mkForce false;
fonts.fontconfig.enable = false;
nixpkgs.overlays = singleton (const (super: {
nixpkgs.overlays = lib.singleton (lib.const (super: {
beam = super.beam_nox;
cairo = super.cairo.override { x11Support = false; };
dbus = super.dbus.override { x11Support = false; };
@ -81,7 +77,7 @@ with lib;
];
qemu = super.qemu.override { gtkSupport = false; spiceSupport = false; sdlSupport = false; };
qrencode = super.qrencode.overrideAttrs (_: { doCheck = false; });
qt5 = super.qt5.overrideScope (const (super': {
qt5 = super.qt5.overrideScope (lib.const (super': {
qtbase = super'.qtbase.override { withGtk3 = false; withQttranslation = false; };
}));
stoken = super.stoken.override { withGTK3 = false; };

View File

@ -1,16 +1,12 @@
# Configuration for the Name Service Switch (/etc/nsswitch.conf).
{ config, lib, pkgs, ... }:
with lib;
{
options = {
# NSS modules. Hacky!
# Only works with nscd!
system.nssModules = mkOption {
type = types.listOf types.path;
system.nssModules = lib.mkOption {
type = lib.types.listOf lib.types.path;
internal = true;
default = [ ];
description = ''
@ -21,13 +17,13 @@ with lib;
apply = list:
{
inherit list;
path = makeLibraryPath list;
path = lib.makeLibraryPath list;
};
};
system.nssDatabases = {
passwd = mkOption {
type = types.listOf types.str;
passwd = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
List of passwd entries to configure in {file}`/etc/nsswitch.conf`.
@ -38,8 +34,8 @@ with lib;
default = [ ];
};
group = mkOption {
type = types.listOf types.str;
group = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
List of group entries to configure in {file}`/etc/nsswitch.conf`.
@ -50,8 +46,8 @@ with lib;
default = [ ];
};
shadow = mkOption {
type = types.listOf types.str;
shadow = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
List of shadow entries to configure in {file}`/etc/nsswitch.conf`.
@ -62,8 +58,8 @@ with lib;
default = [ ];
};
sudoers = mkOption {
type = types.listOf types.str;
sudoers = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
List of sudoers entries to configure in {file}`/etc/nsswitch.conf`.
@ -74,8 +70,8 @@ with lib;
default = [ ];
};
hosts = mkOption {
type = types.listOf types.str;
hosts = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
List of hosts entries to configure in {file}`/etc/nsswitch.conf`.
@ -86,8 +82,8 @@ with lib;
default = [ ];
};
services = mkOption {
type = types.listOf types.str;
services = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = ''
List of services entries to configure in {file}`/etc/nsswitch.conf`.
@ -101,7 +97,7 @@ with lib;
};
imports = [
(mkRenamedOptionModule [ "system" "nssHosts" ] [ "system" "nssDatabases" "hosts" ])
(lib.mkRenamedOptionModule [ "system" "nssHosts" ] [ "system" "nssDatabases" "hosts" ])
];
config = {
@ -121,30 +117,30 @@ with lib;
# Name Service Switch configuration file. Required by the C
# library.
environment.etc."nsswitch.conf".text = ''
passwd: ${concatStringsSep " " config.system.nssDatabases.passwd}
group: ${concatStringsSep " " config.system.nssDatabases.group}
shadow: ${concatStringsSep " " config.system.nssDatabases.shadow}
sudoers: ${concatStringsSep " " config.system.nssDatabases.sudoers}
passwd: ${lib.concatStringsSep " " config.system.nssDatabases.passwd}
group: ${lib.concatStringsSep " " config.system.nssDatabases.group}
shadow: ${lib.concatStringsSep " " config.system.nssDatabases.shadow}
sudoers: ${lib.concatStringsSep " " config.system.nssDatabases.sudoers}
hosts: ${concatStringsSep " " config.system.nssDatabases.hosts}
hosts: ${lib.concatStringsSep " " config.system.nssDatabases.hosts}
networks: files
ethers: files
services: ${concatStringsSep " " config.system.nssDatabases.services}
services: ${lib.concatStringsSep " " config.system.nssDatabases.services}
protocols: files
rpc: files
'';
system.nssDatabases = {
passwd = mkBefore [ "files" ];
group = mkBefore [ "files" ];
shadow = mkBefore [ "files" ];
sudoers = mkBefore [ "files" ];
hosts = mkMerge [
(mkOrder 998 [ "files" ])
(mkOrder 1499 [ "dns" ])
passwd = lib.mkBefore [ "files" ];
group = lib.mkBefore [ "files" ];
shadow = lib.mkBefore [ "files" ];
sudoers = lib.mkBefore [ "files" ];
hosts = lib.mkMerge [
(lib.mkOrder 998 [ "files" ])
(lib.mkOrder 1499 [ "dns" ])
];
services = mkBefore [ "files" ];
services = lib.mkBefore [ "files" ];
};
};
}

View File

@ -1,7 +1,4 @@
{ config, lib, ... }:
with lib;
let
cfg = config.powerManagement;
@ -16,8 +13,8 @@ in
powerManagement = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to enable power management. This includes support
@ -25,16 +22,16 @@ in
'';
};
resumeCommands = mkOption {
type = types.lines;
resumeCommands = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Commands executed after the system resumes from suspend-to-RAM.";
};
powerUpCommands = mkOption {
type = types.lines;
powerUpCommands = lib.mkOption {
type = lib.types.lines;
default = "";
example = literalExpression ''
example = lib.literalExpression ''
"''${pkgs.hdparm}/sbin/hdparm -B 255 /dev/sda"
'';
description = ''
@ -44,10 +41,10 @@ in
'';
};
powerDownCommands = mkOption {
type = types.lines;
powerDownCommands = lib.mkOption {
type = lib.types.lines;
default = "";
example = literalExpression ''
example = lib.literalExpression ''
"''${pkgs.hdparm}/sbin/hdparm -B 255 /dev/sda"
'';
description = ''
@ -64,7 +61,7 @@ in
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.targets.post-resume = {
description = "Post-Resume Actions";

View File

@ -1,17 +1,13 @@
# /etc files related to networking, such as /etc/services.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.networking.resolvconf;
resolvconfOptions = cfg.extraOptions
++ optional cfg.dnsSingleRequest "single-request"
++ optional cfg.dnsExtensionMechanism "edns0"
++ optional cfg.useLocalResolver "trust-ad";
++ lib.optional cfg.dnsSingleRequest "single-request"
++ lib.optional cfg.dnsExtensionMechanism "edns0"
++ lib.optional cfg.useLocalResolver "trust-ad";
configText =
''
@ -19,46 +15,46 @@ let
# a collision with an apparently unrelated environment
# variable with the same name exported by dhcpcd.
interface_order='lo lo[0-9]*'
'' + optionalString config.services.nscd.enable ''
'' + lib.optionalString config.services.nscd.enable ''
# Invalidate the nscd cache whenever resolv.conf is
# regenerated.
libc_restart='/run/current-system/systemd/bin/systemctl try-restart --no-block nscd.service 2> /dev/null'
'' + optionalString (length resolvconfOptions > 0) ''
'' + lib.optionalString (lib.length resolvconfOptions > 0) ''
# Options as described in resolv.conf(5)
resolv_conf_options='${concatStringsSep " " resolvconfOptions}'
'' + optionalString cfg.useLocalResolver ''
resolv_conf_options='${lib.concatStringsSep " " resolvconfOptions}'
'' + lib.optionalString cfg.useLocalResolver ''
# This hosts runs a full-blown DNS resolver.
name_servers='127.0.0.1${optionalString config.networking.enableIPv6 " ::1"}'
name_servers='127.0.0.1${lib.optionalString config.networking.enableIPv6 " ::1"}'
'' + cfg.extraConfig;
in
{
imports = [
(mkRenamedOptionModule [ "networking" "dnsSingleRequest" ] [ "networking" "resolvconf" "dnsSingleRequest" ])
(mkRenamedOptionModule [ "networking" "dnsExtensionMechanism" ] [ "networking" "resolvconf" "dnsExtensionMechanism" ])
(mkRenamedOptionModule [ "networking" "extraResolvconfConf" ] [ "networking" "resolvconf" "extraConfig" ])
(mkRenamedOptionModule [ "networking" "resolvconfOptions" ] [ "networking" "resolvconf" "extraOptions" ])
(mkRemovedOptionModule [ "networking" "resolvconf" "useHostResolvConf" ] "This option was never used for anything anyways")
(lib.mkRenamedOptionModule [ "networking" "dnsSingleRequest" ] [ "networking" "resolvconf" "dnsSingleRequest" ])
(lib.mkRenamedOptionModule [ "networking" "dnsExtensionMechanism" ] [ "networking" "resolvconf" "dnsExtensionMechanism" ])
(lib.mkRenamedOptionModule [ "networking" "extraResolvconfConf" ] [ "networking" "resolvconf" "extraConfig" ])
(lib.mkRenamedOptionModule [ "networking" "resolvconfOptions" ] [ "networking" "resolvconf" "extraOptions" ])
(lib.mkRemovedOptionModule [ "networking" "resolvconf" "useHostResolvConf" ] "This option was never used for lib.anything lib.anyways")
];
options = {
networking.resolvconf = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = !(config.environment.etc ? "resolv.conf");
defaultText = literalExpression ''!(config.environment.etc ? "resolv.conf")'';
defaultText = lib.literalExpression ''!(config.environment.etc ? "resolv.conf")'';
description = ''
Whether DNS configuration is managed by resolvconf.
'';
};
package = mkOption {
type = types.package;
package = lib.mkOption {
type = lib.types.package;
default = pkgs.openresolv;
defaultText = literalExpression "pkgs.openresolv";
defaultText = lib.literalExpression "pkgs.openresolv";
description = ''
The package that provides the system-wide resolvconf command. Defaults to `openresolv`
if this module is enabled. Otherwise, can be used by other modules (for example {option}`services.resolved`) to
@ -69,7 +65,7 @@ in
};
dnsSingleRequest = lib.mkOption {
type = types.bool;
type = lib.types.bool;
default = false;
description = ''
Recent versions of glibc will issue both ipv4 (A) and ipv6 (AAAA)
@ -81,8 +77,8 @@ in
'';
};
dnsExtensionMechanism = mkOption {
type = types.bool;
dnsExtensionMechanism = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enable the `edns0` option in {file}`resolv.conf`. With
@ -92,8 +88,8 @@ in
'';
};
extraConfig = mkOption {
type = types.lines;
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
example = "libc=NO";
description = ''
@ -101,8 +97,8 @@ in
'';
};
extraOptions = mkOption {
type = types.listOf types.str;
extraOptions = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = [ "ndots:1" "rotate" ];
description = ''
@ -110,8 +106,8 @@ in
'';
};
useLocalResolver = mkOption {
type = types.bool;
useLocalResolver = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Use local DNS server for resolving.
@ -122,7 +118,7 @@ in
};
config = mkMerge [
config = lib.mkMerge [
{
environment.etc."resolvconf.conf".text =
if !cfg.enable then
@ -135,7 +131,7 @@ in
else configText;
}
(mkIf cfg.enable {
(lib.mkIf cfg.enable {
networking.resolvconf.package = pkgs.openresolv;
environment.systemPackages = [ cfg.package ];

View File

@ -1,9 +1,6 @@
# This module defines a system-wide environment that will be
# initialised by pam_env (that is, not only in shells).
{ config, lib, options, pkgs, ... }:
with lib;
let
cfg = config.environment;
@ -14,7 +11,7 @@ in
options = {
environment.sessionVariables = mkOption {
environment.sessionVariables = lib.mkOption {
default = {};
description = ''
A set of environment variables used in the global environment.
@ -35,8 +32,8 @@ in
inherit (options.environment.variables) type apply;
};
environment.profileRelativeSessionVariables = mkOption {
type = types.attrsOf (types.listOf types.str);
environment.profileRelativeSessionVariables = lib.mkOption {
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
example = { PATH = [ "/bin" ]; MANPATH = [ "/man" "/share/man" ]; };
description = ''
Attribute set of environment variable used in the global
@ -63,8 +60,8 @@ in
config = {
environment.etc."pam/environment".text = let
suffixedVariables =
flip mapAttrs cfg.profileRelativeSessionVariables (envVar: suffixes:
flip concatMap cfg.profiles (profile:
lib.flip lib.mapAttrs cfg.profileRelativeSessionVariables (envVar: suffixes:
lib.flip lib.concatMap cfg.profiles (profile:
map (suffix: "${profile}${suffix}") suffixes
)
);
@ -72,15 +69,15 @@ in
# We're trying to use the same syntax for PAM variables and env variables.
# That means we need to map the env variables that people might use to their
# equivalent PAM variable.
replaceEnvVars = replaceStrings ["$HOME" "$USER"] ["@{HOME}" "@{PAM_USER}"];
replaceEnvVars = lib.replaceStrings ["$HOME" "$USER"] ["@{HOME}" "@{PAM_USER}"];
pamVariable = n: v:
''${n} DEFAULT="${concatStringsSep ":" (map replaceEnvVars (toList v))}"'';
''${n} DEFAULT="${lib.concatStringsSep ":" (map replaceEnvVars (lib.toList v))}"'';
pamVariables =
concatStringsSep "\n"
(mapAttrsToList pamVariable
(zipAttrsWith (n: concatLists)
lib.concatStringsSep "\n"
(lib.mapAttrsToList pamVariable
(lib.zipAttrsWith (n: lib.concatLists)
[
# Make sure security wrappers are prioritized without polluting
# shell environments with an extra entry. Sessions which depend on
@ -89,7 +86,7 @@ in
# environment from a shell.
{ PATH = [ config.security.wrapperDir ]; }
(mapAttrs (n: toList) cfg.sessionVariables)
(lib.mapAttrs (n: lib.toList) cfg.sessionVariables)
suffixedVariables
]));
in ''

View File

@ -1,13 +1,9 @@
# This module defines the packages that appear in
# /run/current-system/sw.
{ config, lib, pkgs, ... }:
with lib;
let
requiredPackages = map (pkg: setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg)
requiredPackages = map (pkg: lib.setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg)
[ pkgs.acl
pkgs.attr
pkgs.bashInteractive # bash with ncurses support
@ -48,9 +44,9 @@ let
];
defaultPackages =
map
(n: let pkg = pkgs.${n}; in setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg)
(n: let pkg = pkgs.${n};in lib.setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg)
defaultPackageNames;
defaultPackagesText = "[ ${concatMapStringsSep " " (n: "pkgs.${n}") defaultPackageNames } ]";
defaultPackagesText = "[ ${lib.concatMapStringsSep " " (n: "pkgs.${n}") defaultPackageNames } ]";
in
@ -59,10 +55,10 @@ in
environment = {
systemPackages = mkOption {
type = types.listOf types.package;
systemPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]";
example = lib.literalExpression "[ pkgs.firefox pkgs.thunderbird ]";
description = ''
The set of packages that appear in
/run/current-system/sw. These packages are
@ -74,10 +70,10 @@ in
'';
};
defaultPackages = mkOption {
type = types.listOf types.package;
defaultPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = defaultPackages;
defaultText = literalMD ''
defaultText = lib.literalMD ''
these packages, with their `meta.priority` numerically increased
(thus lowering their installation priority):
@ -97,8 +93,8 @@ in
'';
};
pathsToLink = mkOption {
type = types.listOf types.str;
pathsToLink = lib.mkOption {
type = lib.types.listOf lib.types.str;
# Note: We need `/lib' to be among `pathsToLink' for NSS modules
# to work.
default = [];
@ -106,8 +102,8 @@ in
description = "List of directories to be symlinked in {file}`/run/current-system/sw`.";
};
extraOutputsToInstall = mkOption {
type = types.listOf types.str;
extraOutputsToInstall = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "dev" "info" ];
description = ''
@ -119,8 +115,8 @@ in
'';
};
extraSetup = mkOption {
type = types.lines;
extraSetup = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Shell fragments to be run after the system environment has been created. This should only be used for things that need to modify the internals of the environment, e.g. generating MIME caches. The environment being built can be accessed at $out.";
};
@ -129,7 +125,7 @@ in
system = {
path = mkOption {
path = lib.mkOption {
internal = true;
description = ''
The packages you want in the boot environment.

View File

@ -1,23 +1,20 @@
# This module manages the terminfo database
# and its integration in the system.
{ config, lib, pkgs, ... }:
with lib;
{
options = with lib; {
environment.enableAllTerminfo = mkOption {
environment.enableAllTerminfo = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
Whether to install all terminfo outputs
'';
};
security.sudo.keepTerminfo = mkOption {
security.sudo.keepTerminfo = lib.mkOption {
default = true;
type = types.bool;
type = lib.types.bool;
description = ''
Whether to preserve the `TERMINFO` and `TERMINFO_DIRS`
environment variables, for `root` and the `wheel` group.
@ -28,10 +25,10 @@ with lib;
config = {
# can be generated with:
# attrNames (filterAttrs
# (_: drv: (builtins.tryEval (isDerivation drv && drv ? terminfo)).value)
# lib.attrNames (lib.filterAttrs
# (_: drv: (builtins.tryEval (lib.isDerivation drv && drv ? terminfo)).value)
# pkgs)
environment.systemPackages = mkIf config.environment.enableAllTerminfo (map (x: x.terminfo) (with pkgs.pkgsBuildBuild; [
environment.systemPackages = lib.mkIf config.environment.enableAllTerminfo (map (x: x.terminfo) (with pkgs.pkgsBuildBuild; [
alacritty
contour
foot
@ -65,7 +62,7 @@ with lib;
export TERM=$TERM
'';
security.sudo.extraConfig = mkIf config.security.sudo.keepTerminfo ''
security.sudo.extraConfig = lib.mkIf config.security.sudo.keepTerminfo ''
# Keep terminfo database for root and %wheel.
Defaults:root,%wheel env_keep+=TERMINFO_DIRS

View File

@ -1,7 +1,4 @@
{ config, lib, ... }:
with lib;
# unixODBC drivers (this solution is not perfect.. Because the user has to
# ask the admin to add a driver.. but it's simple and works
@ -16,10 +13,10 @@ in {
###### interface
options = {
environment.unixODBCDrivers = mkOption {
type = types.listOf types.package;
environment.unixODBCDrivers = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
example = literalExpression "with pkgs.unixODBCDrivers; [ sqlite psql ]";
example = lib.literalExpression "with pkgs.unixODBCDrivers; [ sqlite psql ]";
description = ''
Specifies Unix ODBC drivers to be registered in
{file}`/etc/odbcinst.ini`. You may also want to
@ -31,8 +28,8 @@ in {
###### implementation
config = mkIf (config.environment.unixODBCDrivers != []) {
environment.etc."odbcinst.ini".text = concatMapStringsSep "\n" iniDescription config.environment.unixODBCDrivers;
config = lib.mkIf (config.environment.unixODBCDrivers != []) {
environment.etc."odbcinst.ini".text = lib.concatMapStringsSep "\n" iniDescription config.environment.unixODBCDrivers;
};
}

View File

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }:
with lib;
let
vteInitSnippet = ''
@ -15,14 +12,14 @@ in
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
options = {
programs.bash.vteIntegration = mkOption {
programs.bash.vteIntegration = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
Whether to enable Bash integration for VTE terminals.
This allows it to preserve the current directory of the shell
@ -30,9 +27,9 @@ in
'';
};
programs.zsh.vteIntegration = mkOption {
programs.zsh.vteIntegration = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
Whether to enable Zsh integration for VTE terminals.
This allows it to preserve the current directory of the shell
@ -42,12 +39,12 @@ in
};
config = mkMerge [
(mkIf config.programs.bash.vteIntegration {
programs.bash.interactiveShellInit = mkBefore vteInitSnippet;
config = lib.mkMerge [
(lib.mkIf config.programs.bash.vteIntegration {
programs.bash.interactiveShellInit = lib.mkBefore vteInitSnippet;
})
(mkIf config.programs.zsh.vteIntegration {
(lib.mkIf config.programs.zsh.vteIntegration {
programs.zsh.interactiveShellInit = vteInitSnippet;
})
];

View File

@ -1,14 +1,12 @@
{ config, lib, ... }:
with lib;
{
meta = {
maintainers = teams.freedesktop.members;
maintainers = lib.teams.freedesktop.members;
};
options = {
xdg.autostart.enable = mkOption {
type = types.bool;
xdg.autostart.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to install files to support the
@ -17,7 +15,7 @@ with lib;
};
};
config = mkIf config.xdg.autostart.enable {
config = lib.mkIf config.xdg.autostart.enable {
environment.pathsToLink = [
"/etc/xdg/autostart"
];

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }:
with lib;
{
meta = {
maintainers = teams.freedesktop.members;
maintainers = lib.teams.freedesktop.members;
};
options = {
xdg.icons.enable = mkOption {
type = types.bool;
xdg.icons.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to install files to support the
@ -17,7 +15,7 @@ with lib;
};
};
config = mkIf config.xdg.icons.enable {
config = lib.mkIf config.xdg.icons.enable {
environment.pathsToLink = [
"/share/icons"
"/share/pixmaps"

View File

@ -1,14 +1,12 @@
{ config, lib, ... }:
with lib;
{
meta = {
maintainers = teams.freedesktop.members;
maintainers = lib.teams.freedesktop.members;
};
options = {
xdg.menus.enable = mkOption {
type = types.bool;
xdg.menus.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to install files to support the
@ -17,7 +15,7 @@ with lib;
};
};
config = mkIf config.xdg.menus.enable {
config = lib.mkIf config.xdg.menus.enable {
environment.pathsToLink = [
"/share/applications"
"/share/desktop-directories"

View File

@ -1,22 +1,19 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.xdg.mime;
associationOptions = with types; attrsOf (
coercedTo (either (listOf str) str) (x: concatStringsSep ";" (toList x)) str
associationOptions = with lib.types; attrsOf (
coercedTo (either (listOf str) str) (x: lib.concatStringsSep ";" (lib.toList x)) str
);
in
{
meta = {
maintainers = teams.freedesktop.members ++ (with maintainers; [ figsoda ]);
maintainers = lib.teams.freedesktop.members ++ (with lib.maintainers; [ figsoda ]);
};
options = {
xdg.mime.enable = mkOption {
type = types.bool;
xdg.mime.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to install files to support the
@ -25,7 +22,7 @@ in
'';
};
xdg.mime.addedAssociations = mkOption {
xdg.mime.addedAssociations = lib.mkOption {
type = associationOptions;
default = {};
example = {
@ -39,7 +36,7 @@ in
'';
};
xdg.mime.defaultApplications = mkOption {
xdg.mime.defaultApplications = lib.mkOption {
type = associationOptions;
default = {};
example = {
@ -53,7 +50,7 @@ in
'';
};
xdg.mime.removedAssociations = mkOption {
xdg.mime.removedAssociations = lib.mkOption {
type = associationOptions;
default = {};
example = {
@ -68,13 +65,13 @@ in
};
};
config = mkIf cfg.enable {
environment.etc."xdg/mimeapps.list" = mkIf (
config = lib.mkIf cfg.enable {
environment.etc."xdg/mimeapps.list" = lib.mkIf (
cfg.addedAssociations != {}
|| cfg.defaultApplications != {}
|| cfg.removedAssociations != {}
) {
text = generators.toINI { } {
text = lib.generators.toINI { } {
"Added Associations" = cfg.addedAssociations;
"Default Applications" = cfg.defaultApplications;
"Removed Associations" = cfg.removedAssociations;

View File

@ -1,18 +1,15 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.xdg.portal.lxqt;
in
{
meta = {
maintainers = teams.lxqt.members;
maintainers = lib.teams.lxqt.members;
};
options.xdg.portal.lxqt = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
the desktop portal for the LXQt desktop environment.
This will add the `lxqt.xdg-desktop-portal-lxqt`
@ -20,10 +17,10 @@ in
{option}`xdg.portal.extraPortals` option
'';
styles = mkOption {
type = types.listOf types.package;
styles = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
example = literalExpression ''[
example = lib.literalExpression ''[
pkgs.libsForQt5.qtstyleplugin-kvantum
pkgs.breeze-qt5
pkgs.qtcurve
@ -36,7 +33,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
xdg.portal = {
enable = true;
extraPortals = [

View File

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.xdg.portal.wlr;
package = pkgs.xdg-desktop-portal-wlr;
@ -10,11 +7,11 @@ let
in
{
meta = {
maintainers = with maintainers; [ minijackson ];
maintainers = with lib.maintainers; [ minijackson ];
};
options.xdg.portal.wlr = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
desktop portal for wlroots-based desktops.
This will add the `xdg-desktop-portal-wlr` package into
@ -22,7 +19,7 @@ in
configuration file
'';
settings = mkOption {
settings = lib.mkOption {
description = ''
Configuration for `xdg-desktop-portal-wlr`.
@ -30,14 +27,14 @@ in
values.
'';
type = types.submodule {
type = lib.types.submodule {
freeformType = settingsFormat.type;
};
default = { };
# Example taken from the manpage
example = literalExpression ''
example = lib.literalExpression ''
{
screencast = {
output_name = "HDMI-A-1";
@ -52,7 +49,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
xdg.portal = {
enable = true;
extraPortals = [ package ];

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }:
with lib;
{
meta = {
maintainers = teams.freedesktop.members;
maintainers = lib.teams.freedesktop.members;
};
options = {
xdg.sounds.enable = mkOption {
type = types.bool;
xdg.sounds.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether to install files to support the
@ -17,7 +15,7 @@ with lib;
};
};
config = mkIf config.xdg.sounds.enable {
config = lib.mkIf config.xdg.sounds.enable {
environment.systemPackages = [
pkgs.sound-theme-freedesktop
];

View File

@ -1,15 +1,13 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.acpilight;
in
{
options = {
hardware.acpilight = {
enable = mkOption {
enable = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
Enable acpilight.
This will allow brightness control via xbacklight from users in the video group
@ -18,7 +16,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ acpilight ];
services.udev.packages = with pkgs; [ acpilight ];
};

View File

@ -1,33 +1,30 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware;
in {
imports = [
(mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(lib.mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ])
(lib.mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(lib.mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(lib.mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
(lib.mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ])
];
###### interface
options = {
hardware.enableAllFirmware = mkEnableOption "all firmware regardless of license";
hardware.enableAllFirmware = lib.mkEnableOption "all firmware regardless of license";
hardware.enableRedistributableFirmware = mkEnableOption "firmware with a license allowing redistribution" // {
hardware.enableRedistributableFirmware = lib.mkEnableOption "firmware with a license allowing redistribution" // {
default = config.hardware.enableAllFirmware;
defaultText = lib.literalExpression "config.hardware.enableAllFirmware";
};
hardware.wirelessRegulatoryDatabase = mkEnableOption "loading the wireless regulatory database at boot" // {
hardware.wirelessRegulatoryDatabase = lib.mkEnableOption "loading the wireless regulatory database at boot" // {
default = cfg.enableRedistributableFirmware || cfg.enableAllFirmware;
defaultText = literalMD "Enabled if proprietary firmware is allowed via {option}`enableRedistributableFirmware` or {option}`enableAllFirmware`.";
defaultText = lib.literalMD "Enabled if proprietary firmware is allowed via {option}`enableRedistributableFirmware` or {option}`enableAllFirmware`.";
};
};
@ -35,8 +32,8 @@ in {
###### implementation
config = mkMerge [
(mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) {
config = lib.mkMerge [
(lib.mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) {
hardware.firmware = with pkgs; [
linux-firmware
intel2200BGFirmware
@ -47,9 +44,9 @@ in {
alsa-firmware
sof-firmware
libreelec-dvb-firmware
] ++ optional pkgs.stdenv.hostPlatform.isAarch raspberrypiWirelessFirmware;
] ++ lib.optional pkgs.stdenv.hostPlatform.isAarch raspberrypiWirelessFirmware;
})
(mkIf cfg.enableAllFirmware {
(lib.mkIf cfg.enableAllFirmware {
assertions = [{
assertion = !cfg.enableAllFirmware || pkgs.config.allowUnfree;
message = ''
@ -63,12 +60,12 @@ in {
b43Firmware_5_1_138
b43Firmware_6_30_163_46
xow_dongle-firmware
] ++ optionals pkgs.stdenv.hostPlatform.isx86 [
] ++ lib.optionals pkgs.stdenv.hostPlatform.isx86 [
facetimehd-calibration
facetimehd-firmware
];
})
(mkIf cfg.wirelessRegulatoryDatabase {
(lib.mkIf cfg.wirelessRegulatoryDatabase {
hardware.firmware = [ pkgs.wireless-regdb ];
})
];

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.bladeRF;
@ -9,8 +6,8 @@ in
{
options.hardware.bladeRF = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enables udev rules for BladeRF devices. By default grants access
@ -21,7 +18,7 @@ in
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
services.udev.packages = [ pkgs.libbladeRF ];
users.groups.bladerf = {};
};

View File

@ -1,20 +1,18 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.brillo;
in
{
options = {
hardware.brillo = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
brillo in userspace.
This will allow brightness control from users in the video group
'';
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
services.udev.packages = [ pkgs.brillo ];
environment.systemPackages = [ pkgs.brillo ];
};

View File

@ -1,22 +1,19 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.ckb-next;
in
{
imports = [
(mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ])
(mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ])
(lib.mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ])
(lib.mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ])
];
options.hardware.ckb-next = {
enable = mkEnableOption "the Corsair keyboard/mouse driver";
enable = lib.mkEnableOption "the Corsair keyboard/mouse driver";
gid = mkOption {
type = types.nullOr types.int;
gid = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
example = 100;
description = ''
@ -24,17 +21,17 @@ in
'';
};
package = mkPackageOption pkgs "ckb-next" { };
package = lib.mkPackageOption pkgs "ckb-next" { };
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
systemd.services.ckb-next = {
description = "Corsair Keyboards and Mice Daemon";
wantedBy = ["multi-user.target"];
serviceConfig = {
ExecStart = "${cfg.package}/bin/ckb-next-daemon ${optionalString (cfg.gid != null) "--gid=${builtins.toString cfg.gid}"}";
ExecStart = "${cfg.package}/bin/ckb-next-daemon ${lib.optionalString (cfg.gid != null) "--gid=${builtins.toString cfg.gid}"}";
Restart = "on-failure";
};
};

View File

@ -1,27 +1,24 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.corectrl;
in
{
options.programs.corectrl = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
CoreCtrl, a tool to overclock amd graphics cards and processors.
Add your user to the corectrl group to run corectrl without needing to enter your password
'';
package = mkPackageOption pkgs "corectrl" {
package = lib.mkPackageOption pkgs "corectrl" {
extraDescription = "Useful for overriding the configuration options used for the package.";
};
gpuOverclock = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
GPU overclocking
'';
ppfeaturemask = mkOption {
type = types.str;
ppfeaturemask = lib.mkOption {
type = lib.types.str;
default = "0xfffd7fff";
example = "0xffffffff";
description = ''
@ -34,7 +31,7 @@ in
};
};
config = mkIf cfg.enable (lib.mkMerge [
config = lib.mkIf cfg.enable (lib.mkMerge [
{
environment.systemPackages = [ cfg.package ];

View File

@ -1,21 +1,18 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.deviceTree;
overlayType = types.submodule {
overlayType = lib.types.submodule {
options = {
name = mkOption {
type = types.str;
name = lib.mkOption {
type = lib.types.str;
description = ''
Name of this overlay
'';
};
filter = mkOption {
type = types.nullOr types.str;
filter = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "*rpi*.dtb";
description = ''
@ -23,18 +20,18 @@ let
'';
};
dtsFile = mkOption {
type = types.nullOr types.path;
dtsFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
description = ''
Path to .dts overlay file, overlay is applied to
each .dtb file matching "compatible" of the overlay.
'';
default = null;
example = literalExpression "./dts/overlays.dts";
example = lib.literalExpression "./dts/overlays.dts";
};
dtsText = mkOption {
type = types.nullOr types.str;
dtsText = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
Literal DTS contents, overlay is applied to
@ -55,8 +52,8 @@ let
'';
};
dtboFile = mkOption {
type = types.nullOr types.path;
dtboFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Path to .dtbo compiled overlay file.
@ -79,9 +76,9 @@ let
# Fill in `dtboFile` for each overlay if not set already.
# Existence of one of these is guarded by assertion below
withDTBOs = xs: flip map xs (o: o // { dtboFile =
withDTBOs = xs: lib.flip map xs (o: o // { dtboFile =
let
includePaths = ["${getDev cfg.kernelPackage}/lib/modules/${cfg.kernelPackage.modDirVersion}/source/scripts/dtc/include-prefixes"] ++ cfg.dtboBuildExtraIncludePaths;
includePaths = ["${lib.getDev cfg.kernelPackage}/lib/modules/${cfg.kernelPackage.modDirVersion}/source/scripts/dtc/include-prefixes"] ++ cfg.dtboBuildExtraIncludePaths;
extraPreprocessorFlags = cfg.dtboBuildExtraPreprocessorFlags;
in
if o.dtboFile == null then
@ -97,67 +94,67 @@ let
in
{
imports = [
(mkRemovedOptionModule [ "hardware" "deviceTree" "base" ] "Use hardware.deviceTree.kernelPackage instead")
(lib.mkRemovedOptionModule [ "hardware" "deviceTree" "base" ] "Use hardware.deviceTree.kernelPackage instead")
];
options = {
hardware.deviceTree = {
enable = mkOption {
enable = lib.mkOption {
default = pkgs.stdenv.hostPlatform.linux-kernel.DTB or false;
type = types.bool;
type = lib.types.bool;
description = ''
Build device tree files. These are used to describe the
non-discoverable hardware of a system.
'';
};
kernelPackage = mkOption {
kernelPackage = lib.mkOption {
default = config.boot.kernelPackages.kernel;
defaultText = literalExpression "config.boot.kernelPackages.kernel";
example = literalExpression "pkgs.linux_latest";
type = types.path;
defaultText = lib.literalExpression "config.boot.kernelPackages.kernel";
example = lib.literalExpression "pkgs.linux_latest";
type = lib.types.path;
description = ''
Kernel package where device tree include directory is from. Also used as default source of dtb package to apply overlays to
'';
};
dtboBuildExtraPreprocessorFlags = mkOption {
dtboBuildExtraPreprocessorFlags = lib.mkOption {
default = [];
example = literalExpression "[ \"-DMY_DTB_DEFINE\" ]";
type = types.listOf types.str;
example = lib.literalExpression "[ \"-DMY_DTB_DEFINE\" ]";
type = lib.types.listOf lib.types.str;
description = ''
Additional flags to pass to the preprocessor during dtbo compilations
'';
};
dtboBuildExtraIncludePaths = mkOption {
dtboBuildExtraIncludePaths = lib.mkOption {
default = [];
example = literalExpression ''
example = lib.literalExpression ''
[
./my_custom_include_dir_1
./custom_include_dir_2
]
'';
type = types.listOf types.path;
type = lib.types.listOf lib.types.path;
description = ''
Additional include paths that will be passed to the preprocessor when creating the final .dts to compile into .dtbo
'';
};
dtbSource = mkOption {
dtbSource = lib.mkOption {
default = "${cfg.kernelPackage}/dtbs";
defaultText = literalExpression "\${cfg.kernelPackage}/dtbs";
type = types.path;
defaultText = lib.literalExpression "\${cfg.kernelPackage}/dtbs";
type = lib.types.path;
description = ''
Path to dtb directory that overlays and other processing will be applied to. Uses
device trees bundled with the Linux kernel by default.
'';
};
name = mkOption {
name = lib.mkOption {
default = null;
example = "some-dtb.dtb";
type = types.nullOr types.str;
type = lib.types.nullOr lib.types.str;
description = ''
The name of an explicit dtb to be loaded, relative to the dtb base.
Useful in extlinux scenarios if the bootloader doesn't pick the
@ -165,8 +162,8 @@ in
'';
};
filter = mkOption {
type = types.nullOr types.str;
filter = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "*rpi*.dtb";
description = ''
@ -174,9 +171,9 @@ in
'';
};
overlays = mkOption {
overlays = lib.mkOption {
default = [];
example = literalExpression ''
example = lib.literalExpression ''
[
{ name = "pps"; dtsFile = ./dts/pps.dts; }
{ name = "spi";
@ -185,7 +182,7 @@ in
{ name = "precompiled"; dtboFile = ./dtbos/example.dtbo; }
]
'';
type = types.listOf (types.coercedTo types.path (path: {
type = lib.types.listOf (lib.types.coercedTo lib.types.path (path: {
name = baseNameOf path;
filter = null;
dtboFile = path;
@ -195,9 +192,9 @@ in
'';
};
package = mkOption {
package = lib.mkOption {
default = null;
type = types.nullOr types.path;
type = lib.types.nullOr lib.types.path;
internal = true;
description = ''
A path containing the result of applying `overlays` to `kernelPackage`.
@ -206,7 +203,7 @@ in
};
};
config = mkIf (cfg.enable) {
config = lib.mkIf (cfg.enable) {
assertions = let
invalidOverlay = o: (o.dtsFile == null) && (o.dtsText == null) && (o.dtboFile == null);

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.flipperzero;
@ -9,9 +6,9 @@ let
in
{
options.hardware.flipperzero.enable = mkEnableOption "udev rules and software for Flipper Zero devices";
options.hardware.flipperzero.enable = lib.mkEnableOption "udev rules and software for Flipper Zero devices";
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.qFlipper ];
services.udev.packages = [ pkgs.qFlipper ];
};

View File

@ -1,16 +1,13 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.gkraken;
in
{
options.hardware.gkraken = {
enable = mkEnableOption "gkraken's udev rules for NZXT AIO liquid coolers";
enable = lib.mkEnableOption "gkraken's udev rules for NZXT AIO liquid coolers";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
services.udev.packages = with pkgs; [
gkraken
];

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
# gnupg's manual describes how to setup ccid udev rules:
# https://www.gnupg.org/howtos/card-howto/en/ch02s03.html
@ -28,10 +26,10 @@ let
cfg = config.hardware.gpgSmartcards;
in {
options.hardware.gpgSmartcards = {
enable = mkEnableOption "udev rules for gnupg smart cards";
enable = lib.mkEnableOption "udev rules for gnupg smart cards";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
services.udev.packages = [ scdaemonUdevRulesPkg ];
};
}

View File

@ -1,21 +1,18 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.i2c;
in
{
options.hardware.i2c = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
i2c devices support. By default access is granted to users in the "i2c"
group (will be created if non-existent) and any user with a seat, meaning
logged on the computer locally
'';
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "i2c";
description = ''
Grant access to i2c devices (/dev/i2c-*) to users in this group.
@ -23,11 +20,11 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
boot.kernelModules = [ "i2c-dev" ];
users.groups = mkIf (cfg.group == "i2c") {
users.groups = lib.mkIf (cfg.group == "i2c") {
i2c = { };
};
@ -42,6 +39,6 @@ in
};
meta.maintainers = [ maintainers.rnhmjoj ];
meta.maintainers = [ lib.maintainers.rnhmjoj ];
}

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.infiniband;
@ -31,9 +28,9 @@ in
{
options.hardware.infiniband = {
enable = mkEnableOption "Infiniband support";
guids = mkOption {
type = with types; listOf str;
enable = lib.mkEnableOption "Infiniband support";
guids = lib.mkOption {
type = with lib.types; listOf str;
default = [];
example = [ "0xe8ebd30000eee2e1" ];
description = ''
@ -42,7 +39,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
boot.initrd.kernelModules = [
"mlx5_core" "mlx5_ib" "ib_cm"
"rdma_cm" "rdma_ucm" "rpcrdma"

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.security.polkit;
@ -12,14 +9,14 @@ in
options = {
security.polkit.enable = mkEnableOption "polkit";
security.polkit.enable = lib.mkEnableOption "polkit";
security.polkit.package = mkPackageOption pkgs "polkit" { };
security.polkit.package = lib.mkPackageOption pkgs "polkit" { };
security.polkit.debug = mkEnableOption "debug logs from polkit. This is required in order to see log messages from rule definitions";
security.polkit.debug = lib.mkEnableOption "debug logs from polkit. This is required in order to see log messages from rule definitions";
security.polkit.extraConfig = mkOption {
type = types.lines;
security.polkit.extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
example =
''
@ -41,8 +38,8 @@ in
'';
};
security.polkit.adminIdentities = mkOption {
type = types.listOf types.str;
security.polkit.adminIdentities = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "unix-group:wheel" ];
example = [ "unix-user:alice" "unix-group:admin" ];
description =
@ -57,7 +54,7 @@ in
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package.bin cfg.package.out ];
@ -65,7 +62,7 @@ in
systemd.services.polkit.serviceConfig.ExecStart = [
""
"${cfg.package.out}/lib/polkit-1/polkitd ${optionalString (!cfg.debug) "--no-debug"}"
"${cfg.package.out}/lib/polkit-1/polkitd ${lib.optionalString (!cfg.debug) "--no-debug"}"
];
systemd.services.polkit.restartTriggers = [ config.system.path ];
@ -78,7 +75,7 @@ in
environment.etc."polkit-1/rules.d/10-nixos.rules".text =
''
polkit.addAdminRule(function(action, subject) {
return [${concatStringsSep ", " (map (i: "\"${i}\"") cfg.adminIdentities)}];
return [${lib.concatStringsSep ", " (map (i: "\"${i}\"") cfg.adminIdentities)}];
});
${cfg.extraConfig}

View File

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.salt.master;
@ -20,16 +17,16 @@ in
{
options = {
services.salt.master = {
enable = mkEnableOption "Salt configuration management system master service";
configuration = mkOption {
type = types.attrs;
enable = lib.mkEnableOption "Salt configuration management system master service";
configuration = lib.mkOption {
type = lib.types.attrs;
default = {};
description = "Salt master configuration as Nix attribute set.";
};
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment = {
# Set this up in /etc/salt/master so `salt`, `salt-key`, etc. work.
# The alternatives are

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.rabbitmq;
@ -16,7 +13,7 @@ in
{
imports = [
(mkRemovedOptionModule [ "services" "rabbitmq" "cookie" ] ''
(lib.mkRemovedOptionModule [ "services" "rabbitmq" "cookie" ] ''
This option wrote the Erlang cookie to the store, while it should be kept secret.
Please remove it from your NixOS configuration and deploy a cookie securely instead.
The renamed `unsafeCookie` must ONLY be used in isolated non-production environments such as NixOS VM tests.
@ -26,8 +23,8 @@ in
###### interface
options = {
services.rabbitmq = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable the RabbitMQ server, an Advanced Message
@ -35,9 +32,9 @@ in
'';
};
package = mkPackageOption pkgs "rabbitmq-server" { };
package = lib.mkPackageOption pkgs "rabbitmq-server" { };
listenAddress = mkOption {
listenAddress = lib.mkOption {
default = "127.0.0.1";
example = "";
description = ''
@ -52,28 +49,28 @@ in
configItems."listeners.tcp.1" and it's left for backwards
compatibility with previous version of this module.
'';
type = types.str;
type = lib.types.str;
};
port = mkOption {
port = lib.mkOption {
default = 5672;
description = ''
Port on which RabbitMQ will listen for AMQP connections.
'';
type = types.port;
type = lib.types.port;
};
dataDir = mkOption {
type = types.path;
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/rabbitmq";
description = ''
Data directory for rabbitmq.
'';
};
unsafeCookie = mkOption {
unsafeCookie = lib.mkOption {
default = "";
type = types.str;
type = lib.types.str;
description = ''
Erlang cookie is a string of arbitrary length which must
be the same for several nodes to be allowed to communicate.
@ -86,10 +83,10 @@ in
'';
};
configItems = mkOption {
configItems = lib.mkOption {
default = { };
type = types.attrsOf types.str;
example = literalExpression ''
type = lib.types.attrsOf lib.types.str;
example = lib.literalExpression ''
{
"auth_backends.1.authn" = "rabbit_auth_backend_ldap";
"auth_backends.1.authz" = "rabbit_auth_backend_internal";
@ -112,9 +109,9 @@ in
'';
};
config = mkOption {
config = lib.mkOption {
default = "";
type = types.str;
type = lib.types.str;
description = ''
Verbatim advanced configuration file contents using the Erlang syntax.
This is also known as the `advanced.config` file or the old config format.
@ -130,23 +127,23 @@ in
'';
};
plugins = mkOption {
plugins = lib.mkOption {
default = [ ];
type = types.listOf types.str;
type = lib.types.listOf lib.types.str;
description = "The names of plugins to enable";
};
pluginDirs = mkOption {
pluginDirs = lib.mkOption {
default = [ ];
type = types.listOf types.path;
type = lib.types.listOf lib.types.path;
description = "The list of directories containing external plugins";
};
managementPlugin = {
enable = mkEnableOption "the management plugin";
port = mkOption {
enable = lib.mkEnableOption "the management plugin";
port = lib.mkOption {
default = 15672;
type = types.port;
type = lib.types.port;
description = ''
On which port to run the management plugin
'';
@ -157,7 +154,7 @@ in
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
# This is needed so we will have 'rabbitmqctl' in our PATH
environment.systemPackages = [ cfg.package ];
@ -175,13 +172,13 @@ in
users.groups.rabbitmq.gid = config.ids.gids.rabbitmq;
services.rabbitmq.configItems = {
"listeners.tcp.1" = mkDefault "${cfg.listenAddress}:${toString cfg.port}";
} // optionalAttrs cfg.managementPlugin.enable {
"listeners.tcp.1" = lib.mkDefault "${cfg.listenAddress}:${toString cfg.port}";
} // lib.optionalAttrs cfg.managementPlugin.enable {
"management.tcp.port" = toString cfg.managementPlugin.port;
"management.tcp.ip" = cfg.listenAddress;
};
services.rabbitmq.plugins = optional cfg.managementPlugin.enable "rabbitmq_management";
services.rabbitmq.plugins = lib.optional cfg.managementPlugin.enable "rabbitmq_management";
systemd.services.rabbitmq = {
description = "RabbitMQ Server";
@ -200,11 +197,11 @@ in
RABBITMQ_LOGS = "-";
SYS_PREFIX = "";
RABBITMQ_CONFIG_FILE = config_file;
RABBITMQ_PLUGINS_DIR = concatStringsSep ":" cfg.pluginDirs;
RABBITMQ_PLUGINS_DIR = lib.concatStringsSep ":" cfg.pluginDirs;
RABBITMQ_ENABLED_PLUGINS_FILE = pkgs.writeText "enabled_plugins" ''
[ ${concatStringsSep "," cfg.plugins} ].
[ ${lib.concatStringsSep "," cfg.plugins} ].
'';
} // optionalAttrs (cfg.config != "") { RABBITMQ_ADVANCED_CONFIG_FILE = advanced_config_file; };
} // lib.optionalAttrs (cfg.config != "") { RABBITMQ_ADVANCED_CONFIG_FILE = advanced_config_file; };
serviceConfig = {
ExecStart = "${cfg.package}/sbin/rabbitmq-server";
@ -223,7 +220,7 @@ in
};
preStart = ''
${optionalString (cfg.unsafeCookie != "") ''
${lib.optionalString (cfg.unsafeCookie != "") ''
install -m 600 <(echo -n ${cfg.unsafeCookie}) ${cfg.dataDir}/.erlang.cookie
''}
'';

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
top = config.services.kubernetes;
cfg = top.flannel;
@ -12,28 +9,28 @@ in
{
###### interface
options.services.kubernetes.flannel = {
enable = mkEnableOption "flannel networking";
enable = lib.mkEnableOption "flannel networking";
openFirewallPorts = mkOption {
openFirewallPorts = lib.mkOption {
description = ''
Whether to open the Flannel UDP ports in the firewall on all interfaces.'';
type = types.bool;
type = lib.types.bool;
default = true;
};
};
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
services.flannel = {
enable = mkDefault true;
network = mkDefault top.clusterCidr;
enable = lib.mkDefault true;
network = lib.mkDefault top.clusterCidr;
inherit storageBackend;
nodeName = config.services.kubernetes.kubelet.hostname;
};
services.kubernetes.kubelet = {
cni.config = mkDefault [{
cni.config = lib.mkDefault [{
name = "mynet";
type = "flannel";
cniVersion = "0.3.1";
@ -45,7 +42,7 @@ in
};
networking = {
firewall.allowedUDPPorts = mkIf cfg.openFirewallPorts [
firewall.allowedUDPPorts = lib.mkIf cfg.openFirewallPorts [
8285 # flannel udp
8472 # flannel vxlan
];
@ -61,7 +58,7 @@ in
};
# give flannel some kubernetes rbac permissions if applicable
services.kubernetes.addonManager.bootstrapAddons = mkIf ((storageBackend == "kubernetes") && (elem "RBAC" top.apiserver.authorizationMode)) {
services.kubernetes.addonManager.bootstrapAddons = lib.mkIf ((storageBackend == "kubernetes") && (lib.elem "RBAC" top.apiserver.authorizationMode)) {
flannel-cr = {
apiVersion = "rbac.authorization.k8s.io/v1";

View File

@ -1,38 +1,37 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.jenkins;
jenkinsUrl = "http://${cfg.listenAddress}:${toString cfg.port}${cfg.prefix}";
in {
options = {
services.jenkins = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable the jenkins continuous integration server.
'';
};
user = mkOption {
user = lib.mkOption {
default = "jenkins";
type = types.str;
type = lib.types.str;
description = ''
User the jenkins server should execute under.
'';
};
group = mkOption {
group = lib.mkOption {
default = "jenkins";
type = types.str;
type = lib.types.str;
description = ''
If the default user "jenkins" is configured then this is the primary
group of that user.
'';
};
extraGroups = mkOption {
type = types.listOf types.str;
extraGroups = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "wheel" "dialout" ];
description = ''
@ -40,38 +39,38 @@ in {
'';
};
home = mkOption {
home = lib.mkOption {
default = "/var/lib/jenkins";
type = types.path;
type = lib.types.path;
description = ''
The path to use as JENKINS_HOME. If the default user "jenkins" is configured then
this is the home of the "jenkins" user.
'';
};
listenAddress = mkOption {
listenAddress = lib.mkOption {
default = "0.0.0.0";
example = "localhost";
type = types.str;
type = lib.types.str;
description = ''
Specifies the bind address on which the jenkins HTTP interface listens.
The default is the wildcard address.
'';
};
port = mkOption {
port = lib.mkOption {
default = 8080;
type = types.port;
type = lib.types.port;
description = ''
Specifies port number on which the jenkins HTTP interface listens.
The default is 8080.
'';
};
prefix = mkOption {
prefix = lib.mkOption {
default = "";
example = "/jenkins";
type = types.str;
type = lib.types.str;
description = ''
Specifies a urlPrefix to use with jenkins.
If the example /jenkins is given, the jenkins server will be
@ -79,20 +78,20 @@ in {
'';
};
package = mkPackageOption pkgs "jenkins" { };
package = lib.mkPackageOption pkgs "jenkins" { };
packages = mkOption {
packages = lib.mkOption {
default = [ pkgs.stdenv pkgs.git pkgs.jdk17 config.programs.ssh.package pkgs.nix ];
defaultText = literalExpression "[ pkgs.stdenv pkgs.git pkgs.jdk17 config.programs.ssh.package pkgs.nix ]";
type = types.listOf types.package;
defaultText = lib.literalExpression "[ pkgs.stdenv pkgs.git pkgs.jdk17 config.programs.ssh.package pkgs.nix ]";
type = lib.types.listOf lib.types.package;
description = ''
Packages to add to PATH for the jenkins process.
'';
};
environment = mkOption {
environment = lib.mkOption {
default = { };
type = with types; attrsOf str;
type = with lib.types; attrsOf str;
description = ''
Additional environment variables to be passed to the jenkins process.
As a base environment, jenkins receives NIX_PATH from
@ -104,9 +103,9 @@ in {
'';
};
plugins = mkOption {
plugins = lib.mkOption {
default = null;
type = types.nullOr (types.attrsOf types.package);
type = lib.types.nullOr (lib.types.attrsOf lib.types.package);
description = ''
A set of plugins to activate. Note that this will completely
remove and replace any previously installed plugins. If you
@ -115,13 +114,13 @@ in {
`null`. You can generate this set with a
tool such as `jenkinsPlugins2nix`.
'';
example = literalExpression ''
example = lib.literalExpression ''
import path/to/jenkinsPlugins2nix-generated-plugins.nix { inherit (pkgs) fetchurl stdenv; }
'';
};
extraOptions = mkOption {
type = types.listOf types.str;
extraOptions = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "--debug=9" ];
description = ''
@ -129,8 +128,8 @@ in {
'';
};
extraJavaOptions = mkOption {
type = types.listOf types.str;
extraJavaOptions = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "-Xmx80m" ];
description = ''
@ -138,8 +137,8 @@ in {
'';
};
withCLI = mkOption {
type = types.bool;
withCLI = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to make the CLI available.
@ -152,25 +151,25 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment = {
# server references the dejavu fonts
systemPackages = [
pkgs.dejavu_fonts
] ++ optional cfg.withCLI cfg.package;
] ++ lib.optional cfg.withCLI cfg.package;
variables = {}
// optionalAttrs cfg.withCLI {
// lib.optionalAttrs cfg.withCLI {
# Make it more convenient to use the `jenkins-cli`.
JENKINS_URL = jenkinsUrl;
};
};
users.groups = optionalAttrs (cfg.group == "jenkins") {
users.groups = lib.optionalAttrs (cfg.group == "jenkins") {
jenkins.gid = config.ids.gids.jenkins;
};
users.users = optionalAttrs (cfg.user == "jenkins") {
users.users = lib.optionalAttrs (cfg.user == "jenkins") {
jenkins = {
description = "jenkins user";
createHome = true;
@ -205,14 +204,14 @@ in {
preStart =
let replacePlugins =
optionalString (cfg.plugins != null) (
let pluginCmds = lib.attrsets.mapAttrsToList
lib.optionalString (cfg.plugins != null) (
let pluginCmds = lib.attrsets.lib.mapAttrsToList
(n: v: "cp ${v} ${cfg.home}/plugins/${n}.jpi")
cfg.plugins;
in ''
rm -r ${cfg.home}/plugins || true
mkdir -p ${cfg.home}/plugins
${lib.strings.concatStringsSep "\n" pluginCmds}
${lib.strings.lib.concatStringsSep "\n" pluginCmds}
'');
in ''
rm -rf ${cfg.home}/war
@ -221,11 +220,11 @@ in {
# For reference: https://wiki.jenkins.io/display/JENKINS/JenkinsLinuxStartupScript
script = ''
${pkgs.jdk17}/bin/java ${concatStringsSep " " cfg.extraJavaOptions} -jar ${cfg.package}/webapps/jenkins.war --httpListenAddress=${cfg.listenAddress} \
${pkgs.jdk17}/bin/java ${lib.concatStringsSep " " cfg.extraJavaOptions} -jar ${cfg.package}/webapps/jenkins.war --httpListenAddress=${cfg.listenAddress} \
--httpPort=${toString cfg.port} \
--prefix=${cfg.prefix} \
-Djava.awt.headless=true \
${concatStringsSep " " cfg.extraOptions}
${lib.concatStringsSep " " cfg.extraOptions}
'';
postStart = ''
@ -236,7 +235,7 @@ in {
serviceConfig = {
User = cfg.user;
StateDirectory = mkIf (hasPrefix "/var/lib/jenkins" cfg.home) "jenkins";
StateDirectory = lib.mkIf (lib.hasPrefix "/var/lib/jenkins" cfg.home) "jenkins";
# For (possible) socket use
RuntimeDirectory = "jenkins";
};

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
jenkinsCfg = config.services.jenkins;
cfg = config.services.jenkins.jobBuilder;
@ -9,7 +6,7 @@ let
in {
options = {
services.jenkins.jobBuilder = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
the Jenkins Job Builder (JJB) service. It
allows defining jobs for Jenkins in a declarative manner.
@ -24,17 +21,17 @@ in {
<https://jenkins-job-builder.readthedocs.io/>
'';
accessUser = mkOption {
accessUser = lib.mkOption {
default = "admin";
type = types.str;
type = lib.types.str;
description = ''
User id in Jenkins used to reload config.
'';
};
accessToken = mkOption {
accessToken = lib.mkOption {
default = "";
type = types.str;
type = lib.types.str;
description = ''
User token in Jenkins used to reload config.
WARNING: This token will be world readable in the Nix store. To keep
@ -42,10 +39,10 @@ in {
'';
};
accessTokenFile = mkOption {
accessTokenFile = lib.mkOption {
default = "${config.services.jenkins.home}/secrets/initialAdminPassword";
defaultText = literalExpression ''"''${config.services.jenkins.home}/secrets/initialAdminPassword"'';
type = types.str;
defaultText = lib.literalExpression ''"''${config.services.jenkins.home}/secrets/initialAdminPassword"'';
type = lib.types.str;
example = "/run/keys/jenkins-job-builder-access-token";
description = ''
File containing the API token for the {option}`accessUser`
@ -53,9 +50,9 @@ in {
'';
};
yamlJobs = mkOption {
yamlJobs = lib.mkOption {
default = "";
type = types.lines;
type = lib.types.lines;
example = ''
- job:
name: jenkins-job-test-1
@ -67,10 +64,10 @@ in {
'';
};
jsonJobs = mkOption {
jsonJobs = lib.mkOption {
default = [ ];
type = types.listOf types.str;
example = literalExpression ''
type = lib.types.listOf lib.types.str;
example = lib.literalExpression ''
[
'''
[ { "job":
@ -87,10 +84,10 @@ in {
'';
};
nixJobs = mkOption {
nixJobs = lib.mkOption {
default = [ ];
type = types.listOf types.attrs;
example = literalExpression ''
type = lib.types.listOf lib.types.attrs;
example = lib.literalExpression ''
[ { job =
{ name = "jenkins-job-test-3";
builders = [
@ -110,7 +107,7 @@ in {
};
};
config = mkIf (jenkinsCfg.enable && cfg.enable) {
config = lib.mkIf (jenkinsCfg.enable && cfg.enable) {
assertions = [
{ assertion =
if cfg.accessUser != ""
@ -213,7 +210,7 @@ in {
# Create / update jobs
mkdir -p ${jobBuilderOutputDir}
for inputFile in ${yamlJobsFile} ${concatStringsSep " " jsonJobsFiles}; do
for inputFile in ${yamlJobsFile} ${lib.concatStringsSep " " jsonJobsFiles}; do
HOME="${jenkinsCfg.home}" "${pkgs.jenkins-job-builder}/bin/jenkins-jobs" --ignore-cache test --config-xml -o "${jobBuilderOutputDir}" "$inputFile"
done
@ -237,7 +234,7 @@ in {
jobdir="${jenkinsCfg.home}/$jenkinsjobname"
rm -rf "$jobdir"
done
'' + (optionalString (cfg.accessUser != "") reloadScript);
'' + (lib.optionalString (cfg.accessUser != "") reloadScript);
serviceConfig = {
Type = "oneshot";
User = jenkinsCfg.user;

View File

@ -1,7 +1,4 @@
{ config, options, lib, pkgs, ... }:
with lib;
let
cfg = config.services.couchdb;
opt = options.services.couchdb;
@ -11,7 +8,7 @@ let
database_dir = ${cfg.databaseDir}
uri_file = ${cfg.uriFile}
view_index_dir = ${cfg.viewIndexDir}
'' + (optionalString (cfg.adminPass != null) ''
'' + (lib.optionalString (cfg.adminPass != null) ''
[admins]
${cfg.adminUser} = ${cfg.adminPass}
'' + ''
@ -34,12 +31,12 @@ in {
services.couchdb = {
enable = mkEnableOption "CouchDB Server";
enable = lib.mkEnableOption "CouchDB Server";
package = mkPackageOption pkgs "couchdb3" { };
package = lib.mkPackageOption pkgs "couchdb3" { };
adminUser = mkOption {
type = types.str;
adminUser = lib.mkOption {
type = lib.types.str;
default = "admin";
description = ''
Couchdb (i.e. fauxton) account with permission for all dbs and
@ -47,8 +44,8 @@ in {
'';
};
adminPass = mkOption {
type = types.nullOr types.str;
adminPass = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
Couchdb (i.e. fauxton) account with permission for all dbs and
@ -56,16 +53,16 @@ in {
'';
};
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "couchdb";
description = ''
User account under which couchdb runs.
'';
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "couchdb";
description = ''
Group account under which couchdb runs.
@ -74,8 +71,8 @@ in {
# couchdb options: https://docs.couchdb.org/en/latest/config/index.html
databaseDir = mkOption {
type = types.path;
databaseDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/couchdb";
description = ''
Specifies location of CouchDB database files (*.couch named). This
@ -84,8 +81,8 @@ in {
'';
};
uriFile = mkOption {
type = types.path;
uriFile = lib.mkOption {
type = lib.types.path;
default = "/run/couchdb/couchdb.uri";
description = ''
This file contains the full URI that can be used to access this
@ -96,8 +93,8 @@ in {
'';
};
viewIndexDir = mkOption {
type = types.path;
viewIndexDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/couchdb";
description = ''
Specifies location of CouchDB view index files. This location should
@ -106,49 +103,49 @@ in {
'';
};
bindAddress = mkOption {
type = types.str;
bindAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = ''
Defines the IP address by which CouchDB will be accessible.
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 5984;
description = ''
Defined the port number to listen.
'';
};
logFile = mkOption {
type = types.path;
logFile = lib.mkOption {
type = lib.types.path;
default = "/var/log/couchdb.log";
description = ''
Specifies the location of file for logging output.
'';
};
extraConfig = mkOption {
type = types.lines;
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Extra configuration. Overrides any other configuration.
'';
};
argsFile = mkOption {
type = types.path;
argsFile = lib.mkOption {
type = lib.types.path;
default = "${cfg.package}/etc/vm.args";
defaultText = literalExpression ''"config.${opt.package}/etc/vm.args"'';
defaultText = lib.literalExpression ''"config.${opt.package}/etc/vm.args"'';
description = ''
vm.args configuration. Overrides Couchdb's Erlang VM parameters file.
'';
};
configFile = mkOption {
type = types.path;
configFile = lib.mkOption {
type = lib.types.path;
description = ''
Configuration file for persisting runtime changes. File
needs to be readable and writable from couchdb user/group.
@ -161,11 +158,11 @@ in {
###### implementation
config = mkIf config.services.couchdb.enable {
config = lib.mkIf config.services.couchdb.enable {
environment.systemPackages = [ cfg.package ];
services.couchdb.configFile = mkDefault "/var/lib/couchdb/local.ini";
services.couchdb.configFile = lib.mkDefault "/var/lib/couchdb/local.ini";
systemd.tmpfiles.rules = [
"d '${dirOf cfg.uriFile}' - ${cfg.user} ${cfg.group} - -"

View File

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.dgraph;
settingsFormat = pkgs.formats.json {};
@ -53,11 +50,11 @@ in
{
options = {
services.dgraph = {
enable = mkEnableOption "Dgraph native GraphQL database with a graph backend";
enable = lib.mkEnableOption "Dgraph native GraphQL database with a graph backend";
package = lib.mkPackageOption pkgs "dgraph" { };
settings = mkOption {
settings = lib.mkOption {
type = settingsFormat.type;
default = {};
description = ''
@ -66,15 +63,15 @@ in
};
alpha = {
host = mkOption {
type = types.str;
host = lib.mkOption {
type = lib.types.str;
default = "localhost";
description = ''
The host which dgraph alpha will be run on.
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 7080;
description = ''
The port which to run dgraph alpha on.
@ -84,15 +81,15 @@ in
};
zero = {
host = mkOption {
type = types.str;
host = lib.mkOption {
type = lib.types.str;
default = "localhost";
description = ''
The host which dgraph zero will be run on.
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 5080;
description = ''
The port which to run dgraph zero on.
@ -103,9 +100,9 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
services.dgraph.settings = {
badger.compression = mkDefault "zstd:3";
badger.compression = lib.mkDefault "zstd:3";
};
systemd.services.dgraph-zero = {

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.dragonflydb;
dragonflydb = pkgs.dragonflydb;
@ -25,22 +22,22 @@ in
options = {
services.dragonflydb = {
enable = mkEnableOption "DragonflyDB";
enable = lib.mkEnableOption "DragonflyDB";
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "dragonfly";
description = "The user to run DragonflyDB as";
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 6379;
description = "The TCP port to accept connections.";
};
bind = mkOption {
type = with types; nullOr str;
bind = lib.mkOption {
type = with lib.types; nullOr str;
default = "127.0.0.1";
description = ''
The IP interface to bind to.
@ -48,15 +45,15 @@ in
'';
};
requirePass = mkOption {
type = with types; nullOr str;
requirePass = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
description = "Password for database";
example = "letmein!";
};
maxMemory = mkOption {
type = with types; nullOr ints.unsigned;
maxMemory = lib.mkOption {
type = with lib.types; nullOr ints.unsigned;
default = null;
description = ''
The maximum amount of memory to use for storage (in bytes).
@ -64,8 +61,8 @@ in
'';
};
memcachePort = mkOption {
type = with types; nullOr port;
memcachePort = lib.mkOption {
type = with lib.types; nullOr port;
default = null;
description = ''
To enable memcached compatible API on this port.
@ -73,8 +70,8 @@ in
'';
};
keysOutputLimit = mkOption {
type = types.ints.unsigned;
keysOutputLimit = lib.mkOption {
type = lib.types.ints.unsigned;
default = 8192;
description = ''
Maximum number of returned keys in keys command.
@ -83,14 +80,14 @@ in
'';
};
dbNum = mkOption {
type = with types; nullOr ints.unsigned;
dbNum = lib.mkOption {
type = with lib.types; nullOr ints.unsigned;
default = null;
description = "Maximum number of supported databases for `select`";
};
cacheMode = mkOption {
type = with types; nullOr bool;
cacheMode = lib.mkOption {
type = with lib.types; nullOr bool;
default = null;
description = ''
Once this mode is on, Dragonfly will evict items least likely to be stumbled
@ -102,14 +99,14 @@ in
###### implementation
config = mkIf config.services.dragonflydb.enable {
config = lib.mkIf config.services.dragonflydb.enable {
users.users = optionalAttrs (cfg.user == "dragonfly") {
users.users = lib.optionalAttrs (cfg.user == "dragonfly") {
dragonfly.description = "DragonflyDB server user";
dragonfly.isSystemUser = true;
dragonfly.group = "dragonfly";
};
users.groups = optionalAttrs (cfg.user == "dragonfly") { dragonfly = { }; };
users.groups = lib.optionalAttrs (cfg.user == "dragonfly") { dragonfly = { }; };
environment.systemPackages = [ dragonflydb ];
@ -120,7 +117,7 @@ in
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${dragonflydb}/bin/dragonfly --alsologtostderr ${builtins.concatStringsSep " " (attrsets.mapAttrsToList (n: v: "--${n} ${strings.escapeShellArg v}") settings)}";
ExecStart = "${dragonflydb}/bin/dragonfly --alsologtostderr ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "--${n} ${lib.escapeShellArg v}") settings)}";
User = cfg.user;

View File

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.ferretdb;
in
@ -11,11 +8,11 @@ in
options = {
services.ferretdb = {
enable = mkEnableOption "FerretDB, an Open Source MongoDB alternative";
enable = lib.mkEnableOption "FerretDB, an Open Source MongoDB alternative";
package = mkOption {
type = types.package;
example = literalExpression "pkgs.ferretdb";
package = lib.mkOption {
type = lib.types.package;
example = lib.literalExpression "pkgs.ferretdb";
default = pkgs.ferretdb;
defaultText = "pkgs.ferretdb";
description = "FerretDB package to use.";
@ -37,7 +34,7 @@ in
};
};
config = mkIf cfg.enable
config = lib.mkIf cfg.enable
{
services.ferretdb.settings = {
@ -76,4 +73,3 @@ in
};
};
}

View File

@ -18,9 +18,6 @@
# however there are no strong reasons to prefer this or the other one AFAIK
# Eg superserver is said to be most efficiently using resources according to
# https://www.firebirdsql.org/manual/qsg25-classic-or-super.html
with lib;
let
cfg = config.services.firebird;
@ -40,34 +37,34 @@ in
services.firebird = {
enable = mkEnableOption "the Firebird super server";
enable = lib.mkEnableOption "the Firebird super server";
package = mkPackageOption pkgs "firebird" {
package = lib.mkPackageOption pkgs "firebird" {
example = "firebird_3";
extraDescription = ''
For SuperServer use override: `pkgs.firebird_3.override { superServer = true; };`
'';
};
port = mkOption {
port = lib.mkOption {
default = 3050;
type = types.port;
type = lib.types.port;
description = ''
Port Firebird uses.
'';
};
user = mkOption {
user = lib.mkOption {
default = "firebird";
type = types.str;
type = lib.types.str;
description = ''
User account under which firebird runs.
'';
};
baseDir = mkOption {
baseDir = lib.mkOption {
default = "/var/lib/firebird";
type = types.str;
type = lib.types.str;
description = ''
Location containing data/ and system/ directories.
data/ stores the databases, system/ stores the password database security2.fdb.
@ -81,7 +78,7 @@ in
###### implementation
config = mkIf config.services.firebird.enable {
config = lib.mkIf config.services.firebird.enable {
environment.systemPackages = [cfg.package];

View File

@ -1,7 +1,4 @@
{ config, options, lib, pkgs, ... }:
with lib;
let
cfg = config.services.hbase-standalone;
opt = options.services.hbase-standalone;
@ -33,7 +30,7 @@ let
in {
imports = [
(mkRenamedOptionModule [ "services" "hbase" ] [ "services" "hbase-standalone" ])
(lib.mkRenamedOptionModule [ "services" "hbase" ] [ "services" "hbase-standalone" ])
];
###### interface
@ -41,31 +38,31 @@ in {
options = {
services.hbase-standalone = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
HBase master in standalone mode with embedded regionserver and zookeper.
Do not use this configuration for production nor for evaluating HBase performance
'';
package = mkPackageOption pkgs "hbase" { };
package = lib.mkPackageOption pkgs "hbase" { };
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "hbase";
description = ''
User account under which HBase runs.
'';
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "hbase";
description = ''
Group account under which HBase runs.
'';
};
dataDir = mkOption {
type = types.path;
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/hbase";
description = ''
Specifies location of HBase database files. This location should be
@ -74,21 +71,21 @@ in {
'';
};
logDir = mkOption {
type = types.path;
logDir = lib.mkOption {
type = lib.types.path;
default = "/var/log/hbase";
description = ''
Specifies the location of HBase log files.
'';
};
settings = mkOption {
settings = lib.mkOption {
type = with lib.types; attrsOf (oneOf [ str int bool ]);
default = {
"hbase.rootdir" = "file://${cfg.dataDir}/hbase";
"hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper";
};
defaultText = literalExpression ''
defaultText = lib.literalExpression ''
{
"hbase.rootdir" = "file://''${config.${opt.dataDir}}/hbase";
"hbase.zookeeper.property.dataDir" = "''${config.${opt.dataDir}}/zookeeper";
@ -104,7 +101,7 @@ in {
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"

View File

@ -1,11 +1,8 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.influxdb;
configOptions = recursiveUpdate {
configOptions = lib.recursiveUpdate {
meta = {
bind-address = ":8088";
commit-timeout = "50ms";
@ -110,36 +107,36 @@ in
services.influxdb = {
enable = mkOption {
enable = lib.mkOption {
default = false;
description = "Whether to enable the influxdb server";
type = types.bool;
type = lib.types.bool;
};
package = mkPackageOption pkgs "influxdb" { };
package = lib.mkPackageOption pkgs "influxdb" { };
user = mkOption {
user = lib.mkOption {
default = "influxdb";
description = "User account under which influxdb runs";
type = types.str;
type = lib.types.str;
};
group = mkOption {
group = lib.mkOption {
default = "influxdb";
description = "Group under which influxdb runs";
type = types.str;
type = lib.types.str;
};
dataDir = mkOption {
dataDir = lib.mkOption {
default = "/var/db/influxdb";
description = "Data directory for influxd data files.";
type = types.path;
type = lib.types.path;
};
extraConfig = mkOption {
extraConfig = lib.mkOption {
default = {};
description = "Extra configuration options for influxdb";
type = types.attrs;
type = lib.types.attrs;
};
};
};
@ -147,7 +144,7 @@ in
###### implementation
config = mkIf config.services.influxdb.enable {
config = lib.mkIf config.services.influxdb.enable {
systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -"
@ -166,16 +163,16 @@ in
postStart =
let
scheme = if configOptions.http.https-enabled then "-k https" else "http";
bindAddr = (ba: if hasPrefix ":" ba then "127.0.0.1${ba}" else "${ba}")(toString configOptions.http.bind-address);
bindAddr = (ba: if lib.hasPrefix ":" ba then "127.0.0.1${ba}" else "${ba}")(toString configOptions.http.bind-address);
in
mkBefore ''
lib.mkBefore ''
until ${pkgs.curl.bin}/bin/curl -s -o /dev/null ${scheme}://${bindAddr}/ping; do
sleep 1;
done
'';
};
users.users = optionalAttrs (cfg.user == "influxdb") {
users.users = lib.optionalAttrs (cfg.user == "influxdb") {
influxdb = {
uid = config.ids.uids.influxdb;
group = "influxdb";
@ -183,7 +180,7 @@ in
};
};
users.groups = optionalAttrs (cfg.group == "influxdb") {
users.groups = lib.optionalAttrs (cfg.group == "influxdb") {
influxdb.gid = config.ids.gids.influxdb;
};
};

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.openldap;
openldap = cfg.package;
@ -23,22 +21,22 @@ let
merge = lib.mergeEqualOption;
};
# We don't coerce to lists of single values, as some values must be unique
in types.either singleLdapValueType (types.listOf singleLdapValueType);
in lib.types.either singleLdapValueType (lib.types.listOf singleLdapValueType);
ldapAttrsType =
let
options = {
attrs = mkOption {
type = types.attrsOf ldapValueType;
attrs = lib.mkOption {
type = lib.types.attrsOf ldapValueType;
default = {};
description = "Attributes of the parent entry.";
};
children = mkOption {
children = lib.mkOption {
# Hide the child attributes, to avoid infinite recursion in e.g. documentation
# Actual Nix evaluation is lazy, so this is not an issue there
type = let
hiddenOptions = lib.mapAttrs (name: attr: attr // { visible = false; }) options;
in types.attrsOf (types.submodule { options = hiddenOptions; });
in lib.types.attrsOf (lib.types.submodule { options = hiddenOptions; });
default = {};
description = "Child entries of the current entry, with recursively the same structure.";
example = lib.literalExpression ''
@ -56,15 +54,15 @@ let
}
'';
};
includes = mkOption {
type = types.listOf types.path;
includes = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [];
description = ''
LDIF files to include after the parent's attributes but before its children.
'';
};
};
in types.submodule { inherit options; };
in lib.types.submodule { inherit options; };
valueToLdif = attr: values: let
listValues = if lib.isList values then values else lib.singleton values;
@ -85,13 +83,13 @@ let
in {
options = {
services.openldap = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable the ldap server.";
};
package = mkPackageOption pkgs "openldap" {
package = lib.mkPackageOption pkgs "openldap" {
extraDescription = ''
This can be used to, for example, set an OpenLDAP package
with custom overrides to enable modules or other
@ -99,26 +97,26 @@ in {
'';
};
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "openldap";
description = "User account under which slapd runs.";
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "openldap";
description = "Group account under which slapd runs.";
};
urlList = mkOption {
type = types.listOf types.str;
urlList = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "ldap:///" ];
description = "URL list slapd should listen on.";
example = [ "ldaps:///" ];
};
settings = mkOption {
settings = lib.mkOption {
type = ldapAttrsType;
description = "Configuration for OpenLDAP, in OLC format";
example = lib.literalExpression ''
@ -165,8 +163,8 @@ in {
};
# This option overrides settings
configDir = mkOption {
type = types.nullOr types.path;
configDir = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Use this config directory instead of generating one from the
@ -175,8 +173,8 @@ in {
example = "/var/lib/openldap/slapd.d";
};
mutableConfig = mkOption {
type = types.bool;
mutableConfig = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to allow writable on-line configuration. If
@ -186,8 +184,8 @@ in {
'';
};
declarativeContents = mkOption {
type = with types; attrsOf lines;
declarativeContents = lib.mkOption {
type = with lib.types; attrsOf lines;
default = {};
description = ''
Declarative contents for the LDAP database, in LDIF format by suffix.
@ -225,8 +223,8 @@ in {
meta.maintainers = with lib.maintainers; [ kwohlfahrt ];
config = let
dbSettings = mapAttrs' (name: { attrs, ... }: nameValuePair attrs.olcSuffix attrs)
(filterAttrs (name: { attrs, ... }: (hasPrefix "olcDatabase=" name) && attrs ? olcSuffix) cfg.settings.children);
dbSettings = lib.mapAttrs' (name: { attrs, ... }: lib.nameValuePair attrs.olcSuffix attrs)
(lib.filterAttrs (name: { attrs, ... }: (lib.hasPrefix "olcDatabase=" name) && attrs ? olcSuffix) cfg.settings.children);
settingsFile = pkgs.writeText "config.ldif" (lib.concatStringsSep "\n" (attrsToLdif "cn=config" cfg.settings));
writeConfig = pkgs.writeShellScript "openldap-config" ''
set -euo pipefail
@ -241,32 +239,32 @@ in {
chmod -R ${if cfg.mutableConfig then "u+rw" else "u+r-w"} ${configDir}
'';
contentsFiles = mapAttrs (dn: ldif: pkgs.writeText "${dn}.ldif" ldif) cfg.declarativeContents;
contentsFiles = lib.mapAttrs (dn: ldif: pkgs.writeText "${dn}.ldif" ldif) cfg.declarativeContents;
writeContents = pkgs.writeShellScript "openldap-load" ''
set -euo pipefail
rm -rf $2/*
${openldap}/bin/slapadd -F ${configDir} -b $1 -l $3
'';
in mkIf cfg.enable {
in lib.mkIf cfg.enable {
assertions = [{
assertion = (cfg.declarativeContents != {}) -> cfg.configDir == null;
message = ''
Declarative DB contents (${attrNames cfg.declarativeContents}) are not
Declarative DB contents (${lib.attrNames cfg.declarativeContents}) are not
supported with user-managed configuration.
'';
}] ++ (map (dn: {
assertion = (getAttr dn dbSettings) ? "olcDbDirectory";
assertion = (lib.getAttr dn dbSettings) ? "olcDbDirectory";
# olcDbDirectory is necessary to prepopulate database using `slapadd`.
message = ''
Declarative DB ${dn} does not exist in `services.openldap.settings`, or does not have
`olcDbDirectory` configured.
'';
}) (attrNames cfg.declarativeContents)) ++ (mapAttrsToList (dn: { olcDbDirectory ? null, ... }: {
}) (lib.attrNames cfg.declarativeContents)) ++ (lib.mapAttrsToList (dn: { olcDbDirectory ? null, ... }: {
# For forward compatibility with `DynamicUser`, and to avoid accidentally clobbering
# directories with `declarativeContents`.
assertion = (olcDbDirectory != null) ->
((hasPrefix "/var/lib/openldap/" olcDbDirectory) && (olcDbDirectory != "/var/lib/openldap/"));
((lib.hasPrefix "/var/lib/openldap/" olcDbDirectory) && (olcDbDirectory != "/var/lib/openldap/"));
message = ''
Database ${dn} has `olcDbDirectory` (${olcDbDirectory}) that is not a subdirectory of
`/var/lib/openldap/`.
@ -303,8 +301,8 @@ in {
"!${pkgs.coreutils}/bin/mkdir -p ${configDir}"
"+${pkgs.coreutils}/bin/chown $USER ${configDir}"
] ++ (lib.optional (cfg.configDir == null) writeConfig)
++ (mapAttrsToList (dn: content: lib.escapeShellArgs [
writeContents dn (getAttr dn dbSettings).olcDbDirectory content
++ (lib.mapAttrsToList (dn: content: lib.escapeShellArgs [
writeContents dn (lib.getAttr dn dbSettings).olcDbDirectory content
]) contentsFiles)
++ [ "${openldap}/bin/slaptest -u -F ${configDir}" ];
ExecStart = lib.escapeShellArgs ([
@ -317,7 +315,7 @@ in {
NotifyAccess = "all";
RuntimeDirectory = "openldap";
StateDirectory = ["openldap"]
++ (map ({olcDbDirectory, ... }: removePrefix "/var/lib/" olcDbDirectory) (attrValues dbSettings));
++ (map ({olcDbDirectory, ... }: lib.removePrefix "/var/lib/" olcDbDirectory) (lib.attrValues dbSettings));
StateDirectoryMode = "700";
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.opentsdb;
@ -15,36 +12,36 @@ in {
services.opentsdb = {
enable = mkEnableOption "OpenTSDB";
enable = lib.mkEnableOption "OpenTSDB";
package = mkPackageOption pkgs "opentsdb" { };
package = lib.mkPackageOption pkgs "opentsdb" { };
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "opentsdb";
description = ''
User account under which OpenTSDB runs.
'';
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "opentsdb";
description = ''
Group account under which OpenTSDB runs.
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 4242;
description = ''
Which port OpenTSDB listens on.
'';
};
config = mkOption {
type = types.lines;
config = lib.mkOption {
type = lib.types.lines;
default = ''
tsd.core.auto_create_metrics = true
tsd.http.request.enable_chunked = true
@ -60,7 +57,7 @@ in {
###### implementation
config = mkIf config.services.opentsdb.enable {
config = lib.mkIf config.services.opentsdb.enable {
systemd.services.opentsdb = {
description = "OpenTSDB Server";

View File

@ -1,7 +1,4 @@
{ lib, pkgs, config, ... } :
with lib;
let
cfg = config.services.pgmanage;
@ -16,7 +13,7 @@ let
super_only = ${builtins.toJSON cfg.superOnly}
${optionalString (cfg.loginGroup != null) "login_group = ${cfg.loginGroup}"}
${lib.optionalString (cfg.loginGroup != null) "login_group = ${cfg.loginGroup}"}
login_timeout = ${toString cfg.loginTimeout}
@ -24,7 +21,7 @@ let
sql_root = ${cfg.sqlRoot}
${optionalString (cfg.tls != null) ''
${lib.optionalString (cfg.tls != null) ''
tls_cert = ${cfg.tls.cert}
tls_key = ${cfg.tls.key}
''}
@ -35,8 +32,8 @@ let
pgmanageConnectionsFile = pkgs.writeTextFile {
name = "pgmanage-connections.conf";
text = concatStringsSep "\n"
(mapAttrsToList (name : conn : "${name}: ${conn}") cfg.connections);
text = lib.concatStringsSep "\n"
(lib.mapAttrsToList (name : conn : "${name}: ${conn}") cfg.connections);
};
pgmanage = "pgmanage";
@ -44,12 +41,12 @@ let
in {
options.services.pgmanage = {
enable = mkEnableOption "PostgreSQL Administration for the web";
enable = lib.mkEnableOption "PostgreSQL Administration for the web";
package = mkPackageOption pkgs "pgmanage" { };
package = lib.mkPackageOption pkgs "pgmanage" { };
connections = mkOption {
type = types.attrsOf types.str;
connections = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = {};
example = {
nuc-server = "hostaddr=192.168.0.100 port=5432 dbname=postgres";
@ -68,8 +65,8 @@ in {
'';
};
allowCustomConnections = mkOption {
type = types.bool;
allowCustomConnections = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
This tells pgmanage whether or not to allow anyone to use a custom
@ -77,16 +74,16 @@ in {
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 8080;
description = ''
This tells pgmanage what port to listen on for browser requests.
'';
};
localOnly = mkOption {
type = types.bool;
localOnly = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
This tells pgmanage whether or not to set the listening socket to local
@ -94,8 +91,8 @@ in {
'';
};
superOnly = mkOption {
type = types.bool;
superOnly = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
This tells pgmanage whether or not to only allow super users to
@ -106,8 +103,8 @@ in {
'';
};
loginGroup = mkOption {
type = types.nullOr types.str;
loginGroup = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
This tells pgmanage to only allow users in a certain PostgreSQL group to
@ -116,8 +113,8 @@ in {
'';
};
loginTimeout = mkOption {
type = types.int;
loginTimeout = lib.mkOption {
type = lib.types.int;
default = 3600;
description = ''
Number of seconds of inactivity before user is automatically logged
@ -125,8 +122,8 @@ in {
'';
};
sqlRoot = mkOption {
type = types.str;
sqlRoot = lib.mkOption {
type = lib.types.str;
default = "/var/lib/pgmanage";
description = ''
This tells pgmanage where to put the SQL file history. All tabs are saved
@ -135,15 +132,15 @@ in {
'';
};
tls = mkOption {
type = types.nullOr (types.submodule {
tls = lib.mkOption {
type = lib.types.nullOr (lib.types.submodule {
options = {
cert = mkOption {
type = types.str;
cert = lib.mkOption {
type = lib.types.str;
description = "TLS certificate";
};
key = mkOption {
type = types.str;
key = lib.mkOption {
type = lib.types.str;
description = "TLS key";
};
};
@ -162,8 +159,8 @@ in {
'';
};
logLevel = mkOption {
type = types.enum ["error" "warn" "notice" "info"];
logLevel = lib.mkOption {
type = lib.types.enum ["error" "warn" "notice" "info"];
default = "error";
description = ''
Verbosity of logs
@ -171,7 +168,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.services.pgmanage = {
description = "pgmanage - PostgreSQL Administration for the web";
wants = [ "postgresql.service" ];
@ -181,7 +178,7 @@ in {
User = pgmanage;
Group = pgmanage;
ExecStart = "${cfg.package}/sbin/pgmanage -c ${confFile}" +
optionalString cfg.localOnly " --local-only=true";
lib.optionalString cfg.localOnly " --local-only=true";
};
};
users = {

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.rethinkdb;
rethinkdb = cfg.package;
@ -15,41 +12,41 @@ in
services.rethinkdb = {
enable = mkEnableOption "RethinkDB server";
enable = lib.mkEnableOption "RethinkDB server";
#package = mkOption {
#package = lib.mkOption {
# default = pkgs.rethinkdb;
# description = "Which RethinkDB derivation to use.";
#};
user = mkOption {
user = lib.mkOption {
default = "rethinkdb";
description = "User account under which RethinkDB runs.";
};
group = mkOption {
group = lib.mkOption {
default = "rethinkdb";
description = "Group which rethinkdb user belongs to.";
};
dbpath = mkOption {
dbpath = lib.mkOption {
default = "/var/db/rethinkdb";
description = "Location where RethinkDB stores its data, 1 data directory per instance.";
};
pidpath = mkOption {
pidpath = lib.mkOption {
default = "/run/rethinkdb";
description = "Location where each instance's pid file is located.";
};
#cfgpath = mkOption {
#cfgpath = lib.mkOption {
# default = "/etc/rethinkdb/instances.d";
# description = "Location where RethinkDB stores it config files, 1 config file per instance.";
#};
# TODO: currently not used by our implementation.
#instances = mkOption {
# type = types.attrsOf types.str;
#instances = lib.mkOption {
# type = lib.types.attrsOf lib.types.str;
# default = {};
# description = "List of named RethinkDB instances in our cluster.";
#};
@ -59,7 +56,7 @@ in
};
###### implementation
config = mkIf config.services.rethinkdb.enable {
config = lib.mkIf config.services.rethinkdb.enable {
environment.systemPackages = [ rethinkdb ];
@ -93,13 +90,13 @@ in
'';
};
users.users.rethinkdb = mkIf (cfg.user == "rethinkdb")
users.users.rethinkdb = lib.mkIf (cfg.user == "rethinkdb")
{ name = "rethinkdb";
description = "RethinkDB server user";
isSystemUser = true;
};
users.groups = optionalAttrs (cfg.group == "rethinkdb") (singleton
users.groups = lib.optionalAttrs (cfg.group == "rethinkdb") (lib.singleton
{ name = "rethinkdb";
});

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.surrealdb;
@ -8,12 +6,12 @@ in {
options = {
services.surrealdb = {
enable = mkEnableOption "SurrealDB, a scalable, distributed, collaborative, document-graph database, for the realtime web";
enable = lib.mkEnableOption "SurrealDB, a scalable, distributed, collaborative, document-graph database, for the realtime web";
package = mkPackageOption pkgs "surrealdb" { };
package = lib.mkPackageOption pkgs "surrealdb" { };
dbPath = mkOption {
type = types.str;
dbPath = lib.mkOption {
type = lib.types.str;
description = ''
The path that surrealdb will write data to. Use null for in-memory.
Can be one of "memory", "file://:path", "tikv://:addr".
@ -22,8 +20,8 @@ in {
example = "memory";
};
host = mkOption {
type = types.str;
host = lib.mkOption {
type = lib.types.str;
description = ''
The host that surrealdb will connect to.
'';
@ -31,8 +29,8 @@ in {
example = "127.0.0.1";
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
description = ''
The port that surrealdb will connect to.
'';
@ -40,8 +38,8 @@ in {
example = 8000;
};
extraFlags = mkOption {
type = types.listOf types.str;
extraFlags = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = [ "--allow-all" "--auth" "--user root" "--pass root" ];
description = ''
@ -52,7 +50,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
# Used to connect to the running service
environment.systemPackages = [ cfg.package ] ;
@ -63,7 +61,7 @@ in {
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/surreal start --bind ${cfg.host}:${toString cfg.port} ${escapeShellArgs cfg.extraFlags} -- ${cfg.dbPath}";
ExecStart = "${cfg.package}/bin/surreal start --bind ${cfg.host}:${toString cfg.port} ${lib.escapeShellArgs cfg.extraFlags} -- ${cfg.dbPath}";
DynamicUser = true;
Restart = "on-failure";
StateDirectory = "surrealdb";

View File

@ -1,20 +1,17 @@
# blueman service
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.blueman;
in {
###### interface
options = {
services.blueman = {
enable = mkEnableOption "blueman, a bluetooth manager";
enable = lib.mkEnableOption "blueman, a bluetooth manager";
};
};
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.blueman ];

View File

@ -1,13 +1,10 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.cpupower-gui;
in {
options = {
services.cpupower-gui = {
enable = mkOption {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
@ -20,7 +17,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.cpupower-gui ];
services.dbus.packages = [ pkgs.cpupower-gui ];
systemd.user = {

View File

@ -1,11 +1,8 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.deepin.members;
maintainers = lib.teams.deepin.members;
};
###### interface
@ -14,7 +11,7 @@ with lib;
services.deepin.app-services = {
enable = mkEnableOption "service collection of DDE applications, including dconfig-center";
enable = lib.mkEnableOption "service collection of DDE applications, including dconfig-center";
};
@ -23,7 +20,7 @@ with lib;
###### implementation
config = mkIf config.services.deepin.app-services.enable {
config = lib.mkIf config.services.deepin.app-services.enable {
users.groups.dde-dconfig-daemon = { };
users.users.dde-dconfig-daemon = {

View File

@ -1,11 +1,8 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.deepin.members;
maintainers = lib.teams.deepin.members;
};
###### interface
@ -14,7 +11,7 @@ with lib;
services.deepin.dde-api = {
enable = mkEnableOption ''
enable = lib.mkEnableOption ''
the DDE API, which provides some dbus interfaces that is used for screen zone detecting,
thumbnail generating, and sound playing in Deepin Desktop Environment
'';
@ -26,7 +23,7 @@ with lib;
###### implementation
config = mkIf config.services.deepin.dde-api.enable {
config = lib.mkIf config.services.deepin.dde-api.enable {
environment.systemPackages = [ pkgs.deepin.dde-api ];

View File

@ -1,14 +1,11 @@
# dleyna-renderer service.
{ config, lib, pkgs, ... }:
with lib;
{
###### interface
options = {
services.dleyna-renderer = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable dleyna-renderer service, a DBus service
@ -20,7 +17,7 @@ with lib;
###### implementation
config = mkIf config.services.dleyna-renderer.enable {
config = lib.mkIf config.services.dleyna-renderer.enable {
environment.systemPackages = [ pkgs.dleyna-renderer ];
services.dbus.packages = [ pkgs.dleyna-renderer ];

View File

@ -1,14 +1,11 @@
# dleyna-server service.
{ config, lib, pkgs, ... }:
with lib;
{
###### interface
options = {
services.dleyna-server = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable dleyna-server service, a DBus service
@ -20,7 +17,7 @@ with lib;
###### implementation
config = mkIf config.services.dleyna-server.enable {
config = lib.mkIf config.services.dleyna-server.enable {
environment.systemPackages = [ pkgs.dleyna-server ];
services.dbus.packages = [ pkgs.dleyna-server ];

View File

@ -1,8 +1,5 @@
# flatpak service.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.flatpak;
in {
@ -14,15 +11,15 @@ in {
###### interface
options = {
services.flatpak = {
enable = mkEnableOption "flatpak";
enable = lib.mkEnableOption "flatpak";
package = mkPackageOption pkgs "flatpak" { };
package = lib.mkPackageOption pkgs "flatpak" { };
};
};
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
assertions = [
{ assertion = (config.xdg.portal.enable == true);

View File

@ -1,15 +1,11 @@
# Accounts-SSO gSignOn daemon
{ config, lib, pkgs, ... }:
with lib;
let
package = pkgs.gsignond.override { plugins = config.services.gsignond.plugins; };
in
{
meta.maintainers = teams.pantheon.members;
meta.maintainers = lib.teams.pantheon.members;
###### interface
@ -17,8 +13,8 @@ in
services.gsignond = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable gSignOn daemon, a DBus service
@ -26,8 +22,8 @@ in
'';
};
plugins = mkOption {
type = types.listOf types.package;
plugins = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [];
description = ''
What plugins to use with the gSignOn daemon.
@ -37,7 +33,7 @@ in
};
###### implementation
config = mkIf config.services.gsignond.enable {
config = lib.mkIf config.services.gsignond.enable {
environment.etc."gsignond.conf".source = "${package}/etc/gsignond.conf";
services.dbus.packages = [ package ];
};

View File

@ -1,19 +1,16 @@
# neard service.
{ config, lib, pkgs, ... }:
with lib;
{
###### interface
options = {
services.neard = {
enable = mkEnableOption "neard, an NFC daemon";
enable = lib.mkEnableOption "neard, an NFC daemon";
};
};
###### implementation
config = mkIf config.services.neard.enable {
config = lib.mkIf config.services.neard.enable {
environment.systemPackages = [ pkgs.neard ];
services.dbus.packages = [ pkgs.neard ];

View File

@ -1,19 +1,16 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.psd;
in {
options.services.psd = with types; {
enable = mkOption {
options.services.psd = with lib.types; {
enable = lib.mkOption {
type = bool;
default = false;
description = ''
Whether to enable the Profile Sync daemon.
'';
};
resyncTimer = mkOption {
resyncTimer = lib.mkOption {
type = str;
default = "1h";
example = "1h 30min";
@ -27,7 +24,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd = {
user = {
services = {

View File

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }:
with lib;
{
###### interface
@ -10,7 +7,7 @@ with lib;
services.system-config-printer = {
enable = mkEnableOption "system-config-printer, a service for CUPS administration used by printing interfaces";
enable = lib.mkEnableOption "system-config-printer, a service for CUPS administration used by printing interfaces";
};
@ -19,7 +16,7 @@ with lib;
###### implementation
config = mkIf config.services.system-config-printer.enable {
config = lib.mkIf config.services.system-config-printer.enable {
services.dbus.packages = [
pkgs.system-config-printer

View File

@ -1,13 +1,9 @@
# Telepathy daemon.
{ config, lib, pkgs, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,8 +12,8 @@ with lib;
services.telepathy = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable Telepathy service, a communications framework
@ -32,7 +28,7 @@ with lib;
###### implementation
config = mkIf config.services.telepathy.enable {
config = lib.mkIf config.services.telepathy.enable {
environment.systemPackages = [ pkgs.telepathy-mission-control ];

View File

@ -1,9 +1,5 @@
# Tumbler
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.tumbler;
@ -13,13 +9,13 @@ in
{
imports = [
(mkRemovedOptionModule
(lib.mkRemovedOptionModule
[ "services" "tumbler" "package" ]
"")
];
meta = with lib; {
maintainers = with maintainers; [ ] ++ teams.pantheon.members;
maintainers = with lib.maintainers; [ ] ++ lib.teams.pantheon.members;
};
###### interface
@ -28,7 +24,7 @@ in
services.tumbler = {
enable = mkEnableOption "Tumbler, A D-Bus thumbnailer service";
enable = lib.mkEnableOption "Tumbler, A D-Bus thumbnailer service";
};
@ -37,7 +33,7 @@ in
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs.xfce; [
tumbler

View File

@ -1,17 +1,14 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.distccd;
in
{
options = {
services.distccd = {
enable = mkEnableOption "distccd, a distributed C/C++ compiler";
enable = lib.mkEnableOption "distccd, a distributed C/C++ compiler";
allowedClients = mkOption {
type = types.listOf types.str;
allowedClients = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "127.0.0.1" ];
example = [ "127.0.0.1" "192.168.0.0/24" "10.0.0.0/24" ];
description = ''
@ -23,16 +20,16 @@ in
'';
};
jobTimeout = mkOption {
type = types.nullOr types.int;
jobTimeout = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
Maximum duration, in seconds, of a single compilation request.
'';
};
logLevel = mkOption {
type = types.nullOr (types.enum [ "critical" "error" "warning" "notice" "info" "debug" ]);
logLevel = lib.mkOption {
type = lib.types.nullOr (lib.types.enum [ "critical" "error" "warning" "notice" "info" "debug" ]);
default = "warning";
description = ''
Set the minimum severity of error that will be included in the log
@ -41,35 +38,35 @@ in
'';
};
maxJobs = mkOption {
type = types.nullOr types.int;
maxJobs = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
Maximum number of tasks distccd should execute at any time.
Maximum number of tasks distccd should execute at lib.any time.
'';
};
nice = mkOption {
type = types.nullOr types.int;
nice = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
Niceness of the compilation tasks.
'';
};
openFirewall = mkOption {
type = types.bool;
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Opens the specified TCP port for distcc.
'';
};
package = mkPackageOption pkgs "distcc" { };
package = lib.mkPackageOption pkgs "distcc" { };
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 3632;
description = ''
The TCP port which distccd will listen on.
@ -77,9 +74,9 @@ in
};
stats = {
enable = mkEnableOption "statistics reporting via HTTP server";
port = mkOption {
type = types.port;
enable = lib.mkEnableOption "statistics reporting via HTTP server";
port = lib.mkOption {
type = lib.types.port;
default = 3633;
description = ''
The TCP port which the distccd statistics HTTP server will listen
@ -88,8 +85,8 @@ in
};
};
zeroconf = mkOption {
type = types.bool;
zeroconf = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to register via mDNS/DNS-SD
@ -98,10 +95,10 @@ in
};
};
config = mkIf cfg.enable {
networking.firewall = mkIf cfg.openFirewall {
config = lib.mkIf cfg.enable {
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.port ]
++ optionals cfg.stats.enable [ cfg.stats.port ];
++ lib.optionals cfg.stats.enable [ cfg.stats.port ];
};
systemd.services.distccd = {
@ -124,14 +121,14 @@ in
--daemon \
--enable-tcp-insecure \
--port ${toString cfg.port} \
${optionalString (cfg.jobTimeout != null) "--job-lifetime ${toString cfg.jobTimeout}"} \
${optionalString (cfg.logLevel != null) "--log-level ${cfg.logLevel}"} \
${optionalString (cfg.maxJobs != null) "--jobs ${toString cfg.maxJobs}"} \
${optionalString (cfg.nice != null) "--nice ${toString cfg.nice}"} \
${optionalString cfg.stats.enable "--stats"} \
${optionalString cfg.stats.enable "--stats-port ${toString cfg.stats.port}"} \
${optionalString cfg.zeroconf "--zeroconf"} \
${concatMapStrings (c: "--allow ${c} ") cfg.allowedClients}
${lib.optionalString (cfg.jobTimeout != null) "--job-lifetime ${toString cfg.jobTimeout}"} \
${lib.optionalString (cfg.logLevel != null) "--log-level ${cfg.logLevel}"} \
${lib.optionalString (cfg.maxJobs != null) "--jobs ${toString cfg.maxJobs}"} \
${lib.optionalString (cfg.nice != null) "--nice ${toString cfg.nice}"} \
${lib.optionalString cfg.stats.enable "--stats"} \
${lib.optionalString cfg.stats.enable "--stats-port ${toString cfg.stats.port}"} \
${lib.optionalString cfg.zeroconf "--zeroconf"} \
${lib.concatMapStrings (c: "--allow ${c} ") cfg.allowedClients}
'';
};
};

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.hoogle;
@ -14,21 +11,21 @@ let
in {
options.services.hoogle = {
enable = mkEnableOption "Haskell documentation server";
enable = lib.mkEnableOption "Haskell documentation server";
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 8080;
description = ''
Port number Hoogle will be listening to.
'';
};
packages = mkOption {
type = types.functionTo (types.listOf types.package);
packages = lib.mkOption {
type = lib.types.functionTo (lib.types.listOf lib.types.package);
default = hp: [];
defaultText = literalExpression "hp: []";
example = literalExpression "hp: with hp; [ text lens ]";
defaultText = lib.literalExpression "hp: []";
example = lib.literalExpression "hp: with hp; [ text lens ]";
description = ''
The Haskell packages to generate documentation for.
@ -38,27 +35,27 @@ in {
'';
};
haskellPackages = mkOption {
haskellPackages = lib.mkOption {
description = "Which haskell package set to use.";
type = types.attrs;
type = lib.types.attrs;
default = pkgs.haskellPackages;
defaultText = literalExpression "pkgs.haskellPackages";
defaultText = lib.literalExpression "pkgs.haskellPackages";
};
home = mkOption {
type = types.str;
home = lib.mkOption {
type = lib.types.str;
description = "Url for hoogle logo";
default = "https://hoogle.haskell.org";
};
host = mkOption {
type = types.str;
host = lib.mkOption {
type = lib.types.str;
description = "Set the host to bind on.";
default = "127.0.0.1";
};
extraOptions = mkOption {
type = types.listOf types.str;
extraOptions = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = [ "--no-security-headers" ];
description = ''
@ -68,7 +65,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.services.hoogle = {
description = "Haskell documentation server";
@ -78,7 +75,7 @@ in {
Restart = "always";
ExecStart = ''
${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home} --host ${cfg.host} \
${concatStringsSep " " cfg.extraOptions}
${lib.concatStringsSep " " cfg.extraOptions}
'';
DynamicUser = true;

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.jupyter;
@ -21,13 +18,13 @@ let
'';
in {
meta.maintainers = with maintainers; [ aborsu ];
meta.maintainers = with lib.maintainers; [ aborsu ];
options.services.jupyter = {
enable = mkEnableOption "Jupyter development server";
enable = lib.mkEnableOption "Jupyter development server";
ip = mkOption {
type = types.str;
ip = lib.mkOption {
type = lib.types.str;
default = "localhost";
description = ''
IP address Jupyter will be listening on.
@ -37,10 +34,10 @@ in {
# NOTE: We don't use top-level jupyter because we don't
# want to pass in JUPYTER_PATH but use .environment instead,
# saving a rebuild.
package = mkPackageOption pkgs [ "python3" "pkgs" "notebook" ] { };
package = lib.mkPackageOption pkgs [ "python3" "pkgs" "notebook" ] { };
command = mkOption {
type = types.str;
command = lib.mkOption {
type = lib.types.str;
default = "jupyter-notebook";
example = "jupyter-lab";
description = ''
@ -49,24 +46,24 @@ in {
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 8888;
description = ''
Port number Jupyter will be listening on.
'';
};
notebookDir = mkOption {
type = types.str;
notebookDir = lib.mkOption {
type = lib.types.str;
default = "~/";
description = ''
Root directory for notebooks.
'';
};
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "jupyter";
description = ''
Name of the user used to run the jupyter service.
@ -76,8 +73,8 @@ in {
example = "aborsu";
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "jupyter";
description = ''
Name of the group used to run the jupyter service.
@ -86,8 +83,8 @@ in {
example = "users";
};
password = mkOption {
type = types.str;
password = lib.mkOption {
type = lib.types.str;
description = ''
Password to use with notebook.
Can be generated using:
@ -102,21 +99,21 @@ in {
example = "'sha1:1b961dc713fb:88483270a63e57d18d43cf337e629539de1436ba'";
};
notebookConfig = mkOption {
type = types.lines;
notebookConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Raw jupyter config.
'';
};
kernels = mkOption {
type = types.nullOr (types.attrsOf(types.submodule (import ./kernel-options.nix {
kernels = lib.mkOption {
type = lib.types.nullOr (lib.types.attrsOf(lib.types.submodule (import ./kernel-options.nix {
inherit lib pkgs;
})));
default = null;
example = literalExpression ''
example = lib.literalExpression ''
{
python3 = let
env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
@ -153,8 +150,8 @@ in {
};
};
config = mkMerge [
(mkIf cfg.enable {
config = lib.mkMerge [
(lib.mkIf cfg.enable {
systemd.services.jupyter = {
description = "Jupyter development server";
@ -183,10 +180,10 @@ in {
};
};
})
(mkIf (cfg.enable && (cfg.group == "jupyter")) {
(lib.mkIf (cfg.enable && (cfg.group == "jupyter")) {
users.groups.jupyter = {};
})
(mkIf (cfg.enable && (cfg.user == "jupyter")) {
(lib.mkIf (cfg.enable && (cfg.user == "jupyter")) {
users.extraUsers.jupyter = {
extraGroups = [ cfg.group ];
home = "/var/lib/jupyter";

View File

@ -1,17 +1,14 @@
# Options that can be used for creating a jupyter kernel.
{ lib, pkgs }:
with lib;
{
freeformType = (pkgs.formats.json { }).type;
options = {
displayName = mkOption {
type = types.str;
displayName = lib.mkOption {
type = lib.types.str;
default = "";
example = literalExpression ''
example = lib.literalExpression ''
"Python 3"
"Python 3 for Data Science"
'';
@ -20,8 +17,8 @@ with lib;
'';
};
argv = mkOption {
type = types.listOf types.str;
argv = lib.mkOption {
type = lib.types.listOf lib.types.str;
example = [
"{customEnv.interpreter}"
"-m"
@ -34,16 +31,16 @@ with lib;
'';
};
language = mkOption {
type = types.str;
language = lib.mkOption {
type = lib.types.str;
example = "python";
description = ''
Language of the environment. Typically the name of the binary.
'';
};
env = mkOption {
type = types.attrsOf types.str;
env = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = { };
example = { OMP_NUM_THREADS = "1"; };
description = ''
@ -51,27 +48,27 @@ with lib;
'';
};
logo32 = mkOption {
type = types.nullOr types.path;
logo32 = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
example = literalExpression ''"''${env.sitePackages}/ipykernel/resources/logo-32x32.png"'';
example = lib.literalExpression ''"''${env.sitePackages}/ipykernel/resources/logo-32x32.png"'';
description = ''
Path to 32x32 logo png.
'';
};
logo64 = mkOption {
type = types.nullOr types.path;
logo64 = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
example = literalExpression ''"''${env.sitePackages}/ipykernel/resources/logo-64x64.png"'';
example = lib.literalExpression ''"''${env.sitePackages}/ipykernel/resources/logo-64x64.png"'';
description = ''
Path to 64x64 logo png.
'';
};
extraPaths = mkOption {
type = types.attrsOf types.path;
extraPaths = lib.mkOption {
type = lib.types.attrsOf lib.types.path;
default = { };
example = literalExpression ''"{ examples = ''${env.sitePack}/IRkernel/kernelspec/kernel.js"; }'';
example = lib.literalExpression ''"{ examples = ''${env.sitePack}/IRkernel/kernelspec/kernel.js"; }'';
description = ''
Extra paths to link in kernel directory
'';

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.jupyterhub;
@ -27,13 +24,13 @@ let
${cfg.extraConfig}
'';
in {
meta.maintainers = with maintainers; [ costrouc ];
meta.maintainers = with lib.maintainers; [ costrouc ];
options.services.jupyterhub = {
enable = mkEnableOption "Jupyterhub development server";
enable = lib.mkEnableOption "Jupyterhub development server";
authentication = mkOption {
type = types.str;
authentication = lib.mkOption {
type = lib.types.str;
default = "jupyterhub.auth.PAMAuthenticator";
description = ''
Jupyterhub authentication to use
@ -43,8 +40,8 @@ in {
'';
};
spawner = mkOption {
type = types.str;
spawner = lib.mkOption {
type = lib.types.str;
default = "systemdspawner.SystemdSpawner";
description = ''
Jupyterhub spawner to use
@ -54,8 +51,8 @@ in {
'';
};
extraConfig = mkOption {
type = types.lines;
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Extra contents appended to the jupyterhub configuration
@ -72,13 +69,13 @@ in {
'';
};
jupyterhubEnv = mkOption {
type = types.package;
jupyterhubEnv = lib.mkOption {
type = lib.types.package;
default = pkgs.python3.withPackages (p: with p; [
jupyterhub
jupyterhub-systemdspawner
]);
defaultText = literalExpression ''
defaultText = lib.literalExpression ''
pkgs.python3.withPackages (p: with p; [
jupyterhub
jupyterhub-systemdspawner
@ -94,13 +91,13 @@ in {
'';
};
jupyterlabEnv = mkOption {
type = types.package;
jupyterlabEnv = lib.mkOption {
type = lib.types.package;
default = pkgs.python3.withPackages (p: with p; [
jupyterhub
jupyterlab
]);
defaultText = literalExpression ''
defaultText = lib.literalExpression ''
pkgs.python3.withPackages (p: with p; [
jupyterhub
jupyterlab
@ -117,13 +114,13 @@ in {
'';
};
kernels = mkOption {
type = types.nullOr (types.attrsOf(types.submodule (import ../jupyter/kernel-options.nix {
kernels = lib.mkOption {
type = lib.types.nullOr (lib.types.attrsOf(lib.types.submodule (import ../jupyter/kernel-options.nix {
inherit lib pkgs;
})));
default = null;
example = literalExpression ''
example = lib.literalExpression ''
{
python3 = let
env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
@ -156,24 +153,24 @@ in {
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 8000;
description = ''
Port number Jupyterhub will be listening on
'';
};
host = mkOption {
type = types.str;
host = lib.mkOption {
type = lib.types.str;
default = "0.0.0.0";
description = ''
Bind IP JupyterHub will be listening on
'';
};
stateDirectory = mkOption {
type = types.str;
stateDirectory = lib.mkOption {
type = lib.types.str;
default = "jupyterhub";
description = ''
Directory for jupyterhub state (token + database)
@ -181,8 +178,8 @@ in {
};
};
config = mkMerge [
(mkIf cfg.enable {
config = lib.mkMerge [
(lib.mkIf cfg.enable {
systemd.services.jupyterhub = {
description = "Jupyterhub development server";

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.livebook;
in
@ -10,12 +8,12 @@ in
# either has access to all the data or none at all), the decision
# was made to run this as a user service. If that changes in the
# future, this can be changed to a system service.
enableUserService = mkEnableOption "a user service for Livebook";
enableUserService = lib.mkEnableOption "a user service for Livebook";
package = mkPackageOption pkgs "livebook" { };
package = lib.mkPackageOption pkgs "livebook" { };
environment = mkOption {
type = with types; attrsOf (nullOr (oneOf [ bool int str ]));
environment = lib.mkOption {
type = with lib.types; attrsOf (nullOr (oneOf [ bool int str ]));
default = { };
description = ''
Environment variables to set.
@ -37,15 +35,15 @@ in
variables specified in this option.
'';
example = literalExpression ''
example = lib.literalExpression ''
{
LIVEBOOK_PORT = 8080;
}
'';
};
environmentFile = mkOption {
type = with types; nullOr types.path;
environmentFile = lib.mkOption {
type = with lib.types; nullOr lib.types.path;
default = null;
description = ''
Additional dnvironment file as defined in {manpage}`systemd.exec(5)`.
@ -72,17 +70,17 @@ in
example = "/var/lib/livebook.env";
};
extraPackages = mkOption {
type = with types; listOf package;
extraPackages = lib.mkOption {
type = with lib.types; listOf package;
default = [ ];
description = ''
Extra packages to make available to the Livebook service.
'';
example = literalExpression "with pkgs; [ gcc gnumake ]";
example = lib.literalExpression "with pkgs; [ gcc gnumake ]";
};
};
config = mkIf cfg.enableUserService {
config = lib.mkIf cfg.enableUserService {
systemd.user.services.livebook = {
serviceConfig = {
Restart = "always";
@ -97,8 +95,8 @@ in
# stuck running a `cat /dev/urandom | tr | fold` pipeline.
IgnoreSIGPIPE = false;
};
environment = mapAttrs (name: value:
if isBool value then boolToString value else toString value)
environment = lib.mapAttrs (name: value:
if lib.isBool value then lib.boolToString value else toString value)
cfg.environment;
path = [ pkgs.bash ] ++ cfg.extraPackages;
wantedBy = [ "default.target" ];

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.rstudio-server;
@ -18,41 +15,41 @@ let
in
{
meta.maintainers = with maintainers; [ jbedo cfhammill ];
meta.maintainers = with lib.maintainers; [ jbedo cfhammill ];
options.services.rstudio-server = {
enable = mkEnableOption "RStudio server";
enable = lib.mkEnableOption "RStudio server";
serverWorkingDir = mkOption {
type = types.str;
serverWorkingDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/rstudio-server";
description = ''
Default working directory for server (server-working-dir in rserver.conf).
'';
};
listenAddr = mkOption {
type = types.str;
listenAddr = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = ''
Address to listen on (www-address in rserver.conf).
'';
};
package = mkPackageOption pkgs "rstudio-server" {
package = lib.mkPackageOption pkgs "rstudio-server" {
example = "rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; }";
};
rserverExtraConfig = mkOption {
type = types.str;
rserverExtraConfig = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Extra contents for rserver.conf.
'';
};
rsessionExtraConfig = mkOption {
type = types.str;
rsessionExtraConfig = lib.mkOption {
type = lib.types.str;
default = "";
description = ''
Extra contents for resssion.conf.
@ -61,7 +58,7 @@ in
};
config = mkIf cfg.enable
config = lib.mkIf cfg.enable
{
systemd.services.rstudio-server = {
description = "Rstudio server";

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.greetd;
tty = "tty${toString cfg.vt}";
@ -8,13 +6,13 @@ let
in
{
options.services.greetd = {
enable = mkEnableOption "greetd, a minimal and flexible login manager daemon";
enable = lib.mkEnableOption "greetd, a minimal and flexible login manager daemon";
package = mkPackageOption pkgs [ "greetd" "greetd" ] { };
package = lib.mkPackageOption pkgs [ "greetd" "greetd" ] { };
settings = mkOption {
settings = lib.mkOption {
type = settingsFormat.type;
example = literalExpression ''
example = lib.literalExpression ''
{
default_session = {
command = "''${pkgs.greetd.greetd}/bin/agreety --cmd sway";
@ -27,8 +25,8 @@ in
'';
};
greeterManagesPlymouth = mkOption {
type = types.bool;
greeterManagesPlymouth = lib.mkOption {
type = lib.types.bool;
internal = true;
default = false;
description = ''
@ -38,18 +36,18 @@ in
'';
};
vt = mkOption {
type = types.int;
vt = lib.mkOption {
type = lib.types.int;
default = 1;
description = ''
The virtual console (tty) that greetd should use. This option also disables getty on that tty.
'';
};
restart = mkOption {
type = types.bool;
restart = lib.mkOption {
type = lib.types.bool;
default = !(cfg.settings ? initial_session);
defaultText = literalExpression "!(config.services.greetd.settings ? initial_session)";
defaultText = lib.literalExpression "!(config.services.greetd.settings ? initial_session)";
description = ''
Whether to restart greetd when it terminates (e.g. on failure).
This is usually desirable so a user can always log in, but should be disabled when using 'settings.initial_session' (autologin),
@ -57,15 +55,15 @@ in
'';
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
services.greetd.settings.terminal.vt = mkDefault cfg.vt;
services.greetd.settings.default_session.user = mkDefault "greeter";
services.greetd.settings.terminal.vt = lib.mkDefault cfg.vt;
services.greetd.settings.default_session.user = lib.mkDefault "greeter";
security.pam.services.greetd = {
allowNullPassword = true;
startSession = true;
enableGnomeKeyring = mkDefault config.services.gnome.gnome-keyring.enable;
enableGnomeKeyring = lib.mkDefault config.services.gnome.gnome-keyring.enable;
};
# This prevents nixos-rebuild from killing greetd by activating getty again
@ -95,7 +93,7 @@ in
serviceConfig = {
ExecStart = "${pkgs.greetd.greetd}/bin/greetd --config ${settingsFormat.generate "greetd.toml" cfg.settings}";
Restart = mkIf cfg.restart "on-success";
Restart = lib.mkIf cfg.restart "on-success";
# Defaults from greetd upstream configuration
IgnoreSIGPIPE = false;
@ -128,5 +126,5 @@ in
users.groups.greeter = { };
};
meta.maintainers = with maintainers; [ queezle ];
meta.maintainers = with lib.maintainers; [ queezle ];
}

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.emacs;
@ -18,8 +15,8 @@ in
{
options.services.emacs = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable a user service for the Emacs daemon. Use `emacsclient` to connect to the
@ -28,8 +25,8 @@ in
'';
};
install = mkOption {
type = types.bool;
install = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to install a user service for the Emacs daemon. Once
@ -43,10 +40,10 @@ in
};
package = mkPackageOption pkgs "emacs" { };
package = lib.mkPackageOption pkgs "emacs" { };
defaultEditor = mkOption {
type = types.bool;
defaultEditor = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
When enabled, configures emacsclient to be the default editor
@ -54,17 +51,17 @@ in
'';
};
startWithGraphical = mkOption {
type = types.bool;
startWithGraphical = lib.mkOption {
type = lib.types.bool;
default = config.services.xserver.enable;
defaultText = literalExpression "config.services.xserver.enable";
defaultText = lib.literalExpression "config.services.xserver.enable";
description = ''
Start emacs with the graphical session instead of any session. Without this, emacs clients will not be able to create frames in the graphical session.
'';
};
};
config = mkIf (cfg.enable || cfg.install) {
config = lib.mkIf (cfg.enable || cfg.install) {
systemd.user.services.emacs = {
description = "Emacs: the extensible, self-documenting text editor";
@ -75,16 +72,16 @@ in
Restart = "always";
};
unitConfig = optionalAttrs cfg.startWithGraphical {
unitConfig = lib.optionalAttrs cfg.startWithGraphical {
After = "graphical-session.target";
};
} // optionalAttrs cfg.enable {
} // lib.optionalAttrs cfg.enable {
wantedBy = if cfg.startWithGraphical then [ "graphical-session.target" ] else [ "default.target" ];
};
environment.systemPackages = [ cfg.package editorScript ];
environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "emacseditor");
environment.variables.EDITOR = lib.mkIf cfg.defaultEditor (lib.mkOverride 900 "emacseditor");
};
meta.doc = ./emacs.md;

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
pkg = pkgs.haste-server;
cfg = config.services.haste-server;
@ -10,10 +7,10 @@ let
in
{
options.services.haste-server = {
enable = mkEnableOption "haste-server";
openFirewall = mkEnableOption "firewall passthrough for haste-server";
enable = lib.mkEnableOption "haste-server";
openFirewall = lib.mkEnableOption "firewall passthrough for haste-server";
settings = mkOption {
settings = lib.mkOption {
description = ''
Configuration for haste-server.
For documentation see [project readme](https://github.com/toptal/haste-server#settings)
@ -22,21 +19,21 @@ in
};
};
config = mkIf (cfg.enable) {
networking.firewall.allowedTCPPorts = mkIf (cfg.openFirewall) [ cfg.settings.port ];
config = lib.mkIf (cfg.enable) {
networking.firewall.allowedTCPPorts = lib.mkIf (cfg.openFirewall) [ cfg.settings.port ];
services.haste-server = {
settings = {
host = mkDefault "::";
port = mkDefault 7777;
host = lib.mkDefault "::";
port = lib.mkDefault 7777;
keyLength = mkDefault 10;
maxLength = mkDefault 400000;
keyLength = lib.mkDefault 10;
maxLength = lib.mkDefault 400000;
staticMaxAge = mkDefault 86400;
recompressStaticAssets = mkDefault false;
staticMaxAge = lib.mkDefault 86400;
recompressStaticAssets = lib.mkDefault false;
logging = mkDefault [
logging = lib.mkDefault [
{
level = "verbose";
type = "Console";
@ -44,25 +41,25 @@ in
}
];
keyGenerator = mkDefault {
keyGenerator = lib.mkDefault {
type = "phonetic";
};
rateLimits = {
categories = {
normal = {
totalRequests = mkDefault 500;
every = mkDefault 60000;
totalRequests = lib.mkDefault 500;
every = lib.mkDefault 60000;
};
};
};
storage = mkDefault {
storage = lib.mkDefault {
type = "file";
};
documents = {
about = mkDefault "${pkg}/share/haste-server/about.md";
about = lib.mkDefault "${pkg}/share/haste-server/about.md";
};
};
};

View File

@ -1,33 +1,30 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.infinoted;
in {
options.services.infinoted = {
enable = mkEnableOption "infinoted";
enable = lib.mkEnableOption "infinoted";
package = mkPackageOption pkgs "libinfinity" { };
package = lib.mkPackageOption pkgs "libinfinity" { };
keyFile = mkOption {
type = types.nullOr types.path;
keyFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Private key to use for TLS
'';
};
certificateFile = mkOption {
type = types.nullOr types.path;
certificateFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Server certificate to use for TLS
'';
};
certificateChain = mkOption {
type = types.nullOr types.path;
certificateChain = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Chain of CA-certificates to which our `certificateFile` is relative.
@ -35,48 +32,48 @@ in {
'';
};
securityPolicy = mkOption {
type = types.enum ["no-tls" "allow-tls" "require-tls"];
securityPolicy = lib.mkOption {
type = lib.types.enum ["no-tls" "allow-tls" "require-tls"];
default = "require-tls";
description = ''
How strictly to enforce clients connection with TLS.
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 6523;
description = ''
Port to listen on
'';
};
rootDirectory = mkOption {
type = types.path;
rootDirectory = lib.mkOption {
type = lib.types.path;
default = "/var/lib/infinoted/documents/";
description = ''
Root of the directory structure to serve
'';
};
plugins = mkOption {
type = types.listOf types.str;
plugins = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "note-text" "note-chat" "logging" "autosave" ];
description = ''
Plugins to enable
'';
};
passwordFile = mkOption {
type = types.nullOr types.path;
passwordFile = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
File to read server-wide password from
'';
};
extraConfig = mkOption {
type = types.lines;
extraConfig = lib.mkOption {
type = lib.types.lines;
default = ''
[autosave]
interval=10
@ -86,16 +83,16 @@ in {
'';
};
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "infinoted";
description = ''
What to call the dedicated user under which infinoted is run
'';
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "infinoted";
description = ''
What to call the primary group of the dedicated user under which infinoted is run
@ -103,15 +100,15 @@ in {
};
};
config = mkIf (cfg.enable) {
users.users = optionalAttrs (cfg.user == "infinoted")
config = lib.mkIf (cfg.enable) {
users.users = lib.optionalAttrs (cfg.user == "infinoted")
{ infinoted = {
description = "Infinoted user";
group = cfg.group;
isSystemUser = true;
};
};
users.groups = optionalAttrs (cfg.group == "infinoted")
users.groups = lib.optionalAttrs (cfg.group == "infinoted")
{ infinoted = { };
};
@ -134,14 +131,14 @@ in {
install -o ${cfg.user} -g ${cfg.group} -m 0600 /dev/null /var/lib/infinoted/infinoted.conf
cat >>/var/lib/infinoted/infinoted.conf <<EOF
[infinoted]
${optionalString (cfg.keyFile != null) "key-file=${cfg.keyFile}"}
${optionalString (cfg.certificateFile != null) "certificate-file=${cfg.certificateFile}"}
${optionalString (cfg.certificateChain != null) "certificate-chain=${cfg.certificateChain}"}
${lib.optionalString (cfg.keyFile != null) "key-file=${cfg.keyFile}"}
${lib.optionalString (cfg.certificateFile != null) "certificate-file=${cfg.certificateFile}"}
${lib.optionalString (cfg.certificateChain != null) "certificate-chain=${cfg.certificateChain}"}
port=${toString cfg.port}
security-policy=${cfg.securityPolicy}
root-directory=${cfg.rootDirectory}
plugins=${concatStringsSep ";" cfg.plugins}
${optionalString (cfg.passwordFile != null) "password=$(head -n 1 ${cfg.passwordFile})"}
plugins=${lib.concatStringsSep ";" cfg.plugins}
${lib.optionalString (cfg.passwordFile != null) "password=$(head -n 1 ${cfg.passwordFile})"}
${cfg.extraConfig}
EOF

View File

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.odoo;
format = pkgs.formats.ini {};
@ -9,35 +6,35 @@ in
{
options = {
services.odoo = {
enable = mkEnableOption "odoo, an open source ERP and CRM system";
enable = lib.mkEnableOption "odoo, an open source ERP and CRM system";
package = mkPackageOption pkgs "odoo" { };
package = lib.mkPackageOption pkgs "odoo" { };
addons = mkOption {
type = with types; listOf package;
addons = lib.mkOption {
type = with lib.types; listOf package;
default = [];
example = literalExpression "[ pkgs.odoo_enterprise ]";
example = lib.literalExpression "[ pkgs.odoo_enterprise ]";
description = "Odoo addons.";
};
autoInit = mkEnableOption "automatically initialize the DB";
autoInit = lib.mkEnableOption "automatically initialize the DB";
autoInitExtraFlags = mkOption {
type = with types; listOf str;
autoInitExtraFlags = lib.mkOption {
type = with lib.types; listOf str;
default = [ ];
example = literalExpression /*nix*/ ''
example = lib.literalExpression /*nix*/ ''
[ "--without-demo=all" ]
'';
description = "Extra flags passed to odoo when run for the first time by autoInit";
};
settings = mkOption {
settings = lib.mkOption {
type = format.type;
default = {};
description = ''
Odoo configuration settings. For more details see <https://www.odoo.com/documentation/15.0/administration/install/deploy.html>
'';
example = literalExpression ''
example = lib.literalExpression ''
options = {
db_user = "odoo";
db_password="odoo";
@ -45,18 +42,18 @@ in
'';
};
domain = mkOption {
type = with types; nullOr str;
domain = lib.mkOption {
type = with lib.types; nullOr str;
description = "Domain to host Odoo with nginx";
default = null;
};
};
};
config = mkIf (cfg.enable) (let
config = lib.mkIf (cfg.enable) (let
cfgFile = format.generate "odoo.cfg" cfg.settings;
in {
services.nginx = mkIf (cfg.domain != null) {
services.nginx = lib.mkIf (cfg.domain != null) {
upstreams = {
odoo.servers = {
"127.0.0.1:8069" = {};
@ -98,7 +95,7 @@ in
data_dir = "/var/lib/private/odoo/data";
proxy_mode = cfg.domain != null;
} // (lib.optionalAttrs (cfg.addons != []) {
addons_path = concatMapStringsSep "," escapeShellArg cfg.addons;
addons_path = lib.concatMapStringsSep "," lib.escapeShellArg cfg.addons;
});
users.users.odoo = {
@ -137,7 +134,7 @@ in
echo "pre-start: auto-init"
INITIALIZED="${cfg.settings.options.data_dir}/.odoo.initialized"
if [ ! -e "$INITIALIZED" ]; then
${cfg.package}/bin/odoo --init=INIT --database=odoo --db_user=odoo --stop-after-init ${concatStringsSep " " cfg.autoInitExtraFlags}
${cfg.package}/bin/odoo --init=INIT --database=odoo --db_user=odoo --stop-after-init ${lib.concatStringsSep " " cfg.autoInitExtraFlags}
touch "$INITIALIZED"
fi
'')

View File

@ -1,21 +1,18 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.crossfire-server;
serverPort = 13327;
in {
options.services.crossfire-server = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
If enabled, the Crossfire game server will be started at boot.
'';
};
package = mkPackageOption pkgs "crossfire-server" {
package = lib.mkPackageOption pkgs "crossfire-server" {
extraDescription = ''
::: {.note}
This will also be used for map/arch data, if you don't change {option}`dataDir`
@ -23,10 +20,10 @@ in {
'';
};
dataDir = mkOption {
type = types.str;
dataDir = lib.mkOption {
type = lib.types.str;
default = "${cfg.package}/share/crossfire";
defaultText = literalExpression ''"''${config.services.crossfire.package}/share/crossfire"'';
defaultText = lib.literalExpression ''"''${config.services.crossfire.package}/share/crossfire"'';
description = ''
Where to load readonly data from -- maps, archetypes, treasure tables,
and the like. If you plan to edit the data on the live server (rather
@ -36,8 +33,8 @@ in {
'';
};
stateDir = mkOption {
type = types.str;
stateDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/crossfire";
description = ''
Where to store runtime data (save files, persistent items, etc).
@ -49,16 +46,16 @@ in {
'';
};
openFirewall = mkOption {
type = types.bool;
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to open ports in the firewall for the server.
'';
};
configFiles = mkOption {
type = types.attrsOf types.str;
configFiles = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
description = ''
Text to append to the corresponding configuration files. Note that the
files given in the example are *not* the complete set of files available
@ -70,7 +67,7 @@ in {
overwrite the example files that come with the server, rather than being
appended to them as the other configuration files are.
'';
example = literalExpression ''
example = lib.literalExpression ''
{
dm_file = '''
admin:secret_password:localhost
@ -101,7 +98,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.users.crossfire = {
description = "Crossfire server daemon user";
home = cfg.stateDir;
@ -120,8 +117,8 @@ in {
(name: value: lib.attrsets.nameValuePair "crossfire/${name}" {
mode = "0644";
text =
(optionalString (!elem name ["motd" "news" "rules"])
(fileContents "${cfg.package}/etc/crossfire/${name}"))
(lib.optionalString (!lib.elem name ["motd" "news" "rules"])
(lib.fileContents "${cfg.package}/etc/crossfire/${name}"))
+ "\n${value}";
}) ({
ban_file = "";
@ -129,9 +126,9 @@ in {
exp_table = "";
forbid = "";
metaserver2 = "";
motd = fileContents "${cfg.package}/etc/crossfire/motd";
news = fileContents "${cfg.package}/etc/crossfire/news";
rules = fileContents "${cfg.package}/etc/crossfire/rules";
motd = lib.fileContents "${cfg.package}/etc/crossfire/motd";
news = lib.fileContents "${cfg.package}/etc/crossfire/news";
rules = lib.fileContents "${cfg.package}/etc/crossfire/rules";
settings = "";
stat_bonus = "";
} // cfg.configFiles);
@ -141,7 +138,7 @@ in {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = mkMerge [
serviceConfig = lib.mkMerge [
{
ExecStart = "${cfg.package}/bin/crossfire-server -conf /etc/crossfire -local '${cfg.stateDir}' -data '${cfg.dataDir}'";
Restart = "always";
@ -149,7 +146,7 @@ in {
Group = "crossfire";
WorkingDirectory = cfg.stateDir;
}
(mkIf (cfg.stateDir == "/var/lib/crossfire") {
(lib.mkIf (cfg.stateDir == "/var/lib/crossfire") {
StateDirectory = "crossfire";
})
];
@ -170,7 +167,7 @@ in {
'';
};
networking.firewall = mkIf cfg.openFirewall {
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ serverPort ];
};
};

View File

@ -1,21 +1,18 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.deliantra-server;
serverPort = 13327;
in {
options.services.deliantra-server = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
If enabled, the Deliantra game server will be started at boot.
'';
};
package = mkPackageOption pkgs "deliantra-server" {
package = lib.mkPackageOption pkgs "deliantra-server" {
extraDescription = ''
::: {.note}
This will also be used for map/arch data, if you don't change {option}`dataDir`
@ -23,10 +20,10 @@ in {
'';
};
dataDir = mkOption {
type = types.str;
dataDir = lib.mkOption {
type = lib.types.str;
default = "${pkgs.deliantra-data}";
defaultText = literalExpression ''"''${pkgs.deliantra-data}"'';
defaultText = lib.literalExpression ''"''${pkgs.deliantra-data}"'';
description = ''
Where to store readonly data (maps, archetypes, sprites, etc).
Note that if you plan to use the live map editor (rather than editing
@ -36,8 +33,8 @@ in {
'';
};
stateDir = mkOption {
type = types.str;
stateDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/deliantra";
description = ''
Where to store runtime data (save files, persistent items, etc).
@ -49,16 +46,16 @@ in {
'';
};
openFirewall = mkOption {
type = types.bool;
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to open ports in the firewall for the server.
'';
};
configFiles = mkOption {
type = types.attrsOf types.str;
configFiles = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
description = ''
Contents of the server configuration files. These will be appended to
the example configurations the server comes with and overwrite any
@ -67,7 +64,7 @@ in {
The example here is not comprehensive. See the files in
/etc/deliantra-server after enabling this module for full documentation.
'';
example = literalExpression ''
example = lib.literalExpression ''
{
dm_file = '''
admin:secret_password:localhost
@ -92,7 +89,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.users.deliantra = {
description = "Deliantra server daemon user";
home = cfg.stateDir;
@ -113,8 +110,8 @@ in {
text =
# Deliantra doesn't come with a motd file, but respects it if present
# in /etc.
(optionalString (name != "motd")
(fileContents "${cfg.package}/etc/deliantra-server/${name}"))
(lib.optionalString (name != "motd")
(lib.fileContents "${cfg.package}/etc/deliantra-server/${name}"))
+ "\n${value}";
}) ({
motd = "";
@ -134,7 +131,7 @@ in {
DELIANTRA_CONFDIR="/etc/deliantra-server";
};
serviceConfig = mkMerge [
serviceConfig = lib.mkMerge [
{
ExecStart = "${cfg.package}/bin/deliantra-server";
Restart = "always";
@ -142,7 +139,7 @@ in {
Group = "deliantra";
WorkingDirectory = cfg.stateDir;
}
(mkIf (cfg.stateDir == "/var/lib/deliantra") {
(lib.mkIf (cfg.stateDir == "/var/lib/deliantra") {
StateDirectory = "deliantra";
})
];
@ -163,7 +160,7 @@ in {
'';
};
networking.firewall = mkIf cfg.openFirewall {
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ serverPort ];
};
};

View File

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.freeciv;
inherit (config.users) groups;
@ -16,31 +15,31 @@ let
generate = name: value:
let mkParam = k: v:
if v == null then []
else if isBool v then optional v ("--"+k)
else if lib.isBool v then lib.optional v ("--"+k)
else [("--"+k) v];
mkParams = k: v: map (mkParam k) (if isList v then v else [v]);
in escapeShellArgs (concatLists (concatLists (mapAttrsToList mkParams value)));
mkParams = k: v: map (mkParam k) (if lib.isList v then v else [v]);
in lib.escapeShellArgs (lib.concatLists (lib.concatLists (lib.mapAttrsToList mkParams value)));
};
in
{
options = {
services.freeciv = {
enable = mkEnableOption ''freeciv'';
settings = mkOption {
enable = lib.mkEnableOption ''freeciv'';
settings = lib.mkOption {
description = ''
Parameters of freeciv-server.
'';
default = {};
type = types.submodule {
type = lib.types.submodule {
freeformType = argsFormat.type;
options.Announce = mkOption {
type = types.enum ["IPv4" "IPv6" "none"];
options.Announce = lib.mkOption {
type = lib.types.enum ["IPv4" "IPv6" "none"];
default = "none";
description = "Announce game in LAN using given protocol.";
};
options.auth = mkEnableOption "server authentication";
options.Database = mkOption {
type = types.nullOr types.str;
options.auth = lib.mkEnableOption "server authentication";
options.Database = lib.mkOption {
type = lib.types.nullOr lib.types.str;
apply = pkgs.writeText "auth.conf";
default = ''
[fcdb]
@ -49,34 +48,34 @@ in
'';
description = "Enable database connection with given configuration.";
};
options.debug = mkOption {
type = types.ints.between 0 3;
options.debug = lib.mkOption {
type = lib.types.ints.between 0 3;
default = 0;
description = "Set debug log level.";
};
options.exit-on-end = mkEnableOption "exit instead of restarting when a game ends";
options.Guests = mkEnableOption "guests to login if auth is enabled";
options.Newusers = mkEnableOption "new users to login if auth is enabled";
options.port = mkOption {
type = types.port;
options.exit-on-end = lib.mkEnableOption "exit instead of restarting when a game ends";
options.Guests = lib.mkEnableOption "guests to login if auth is enabled";
options.Newusers = lib.mkEnableOption "new users to login if auth is enabled";
options.port = lib.mkOption {
type = lib.types.port;
default = 5556;
description = "Listen for clients on given port";
};
options.quitidle = mkOption {
type = types.nullOr types.int;
options.quitidle = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = "Quit if no players for given time in seconds.";
};
options.read = mkOption {
type = types.lines;
options.read = lib.mkOption {
type = lib.types.lines;
apply = v: pkgs.writeTextDir "read.serv" v + "/read";
default = ''
/fcdb lua sqlite_createdb()
'';
description = "Startup script.";
};
options.saves = mkOption {
type = types.nullOr types.str;
options.saves = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = "/var/lib/freeciv/saves/";
description = ''
Save games to given directory,
@ -86,10 +85,10 @@ in
};
};
};
openFirewall = mkEnableOption "opening the firewall for the port listening for clients";
openFirewall = lib.mkEnableOption "opening the firewall for the port listening for clients";
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.groups.freeciv = {};
# Use with:
# journalctl -u freeciv.service -f -o cat &
@ -119,8 +118,8 @@ in
set -eux
savedir=$(date +%Y-%m-%d_%H-%M-%S)
'' + "${pkgs.freeciv}/bin/freeciv-server"
+ " " + optionalString (cfg.settings.saves != null)
(concatStringsSep " " [ "--saves" "${escapeShellArg cfg.settings.saves}/$savedir" ])
+ " " + lib.optionalString (cfg.settings.saves != null)
(lib.concatStringsSep " " [ "--saves" "${lib.escapeShellArg cfg.settings.saves}/$savedir" ])
+ " " + argsFormat.generate "freeciv-server" (cfg.settings // { saves = null; }));
DynamicUser = true;
# Create rootDir in the host's mount namespace.
@ -152,7 +151,7 @@ in
NoNewPrivileges = true;
PrivateDevices = true;
PrivateMounts = true;
PrivateNetwork = mkDefault false;
PrivateNetwork = lib.mkDefault false;
PrivateTmp = true;
PrivateUsers = true;
ProtectClock = true;
@ -180,7 +179,7 @@ in
SystemCallErrorNumber = "EPERM";
};
};
networking.firewall = mkIf cfg.openFirewall
networking.firewall = lib.mkIf cfg.openFirewall
{ allowedTCPPorts = [ cfg.settings.port ]; };
};
meta.maintainers = with lib.maintainers; [ julm ];

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.minecraft-server;
@ -13,13 +10,13 @@ let
whitelistFile = pkgs.writeText "whitelist.json"
(builtins.toJSON
(mapAttrsToList (n: v: { name = n; uuid = v; }) cfg.whitelist));
(lib.mapAttrsToList (n: v: { name = n; uuid = v; }) cfg.whitelist));
cfgToString = v: if builtins.isBool v then boolToString v else toString v;
cfgToString = v: if builtins.isBool v then lib.boolToString v else toString v;
serverPropertiesFile = pkgs.writeText "server.properties" (''
# server.properties managed by NixOS configuration
'' + concatStringsSep "\n" (mapAttrsToList
'' + lib.concatStringsSep "\n" (lib.mapAttrsToList
(n: v: "${n}=${cfgToString v}") cfg.serverProperties));
stopScript = pkgs.writeShellScript "minecraft-server-stop" ''
@ -51,8 +48,8 @@ in {
options = {
services.minecraft-server = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
If enabled, start a Minecraft Server. The server
@ -61,8 +58,8 @@ in {
'';
};
declarative = mkOption {
type = types.bool;
declarative = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to use a declarative Minecraft server configuration.
@ -73,8 +70,8 @@ in {
'';
};
eula = mkOption {
type = types.bool;
eula = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether you agree to
@ -84,29 +81,29 @@ in {
'';
};
dataDir = mkOption {
type = types.path;
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/minecraft";
description = ''
Directory to store Minecraft database and other state/data files.
'';
};
openFirewall = mkOption {
type = types.bool;
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to open ports in the firewall for the server.
'';
};
whitelist = mkOption {
whitelist = lib.mkOption {
type = let
minecraftUUID = types.strMatching
minecraftUUID = lib.types.strMatching
"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" // {
description = "Minecraft UUID";
};
in types.attrsOf minecraftUUID;
in lib.types.attrsOf minecraftUUID;
default = {};
description = ''
Whitelisted players, only has an effect when
@ -118,7 +115,7 @@ in {
You can use <https://mcuuid.net/> to get a
Minecraft UUID for a username.
'';
example = literalExpression ''
example = lib.literalExpression ''
{
username1 = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
username2 = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy";
@ -126,10 +123,10 @@ in {
'';
};
serverProperties = mkOption {
type = with types; attrsOf (oneOf [ bool int str ]);
serverProperties = lib.mkOption {
type = with lib.types; attrsOf (oneOf [ bool int str ]);
default = {};
example = literalExpression ''
example = lib.literalExpression ''
{
server-port = 43000;
difficulty = 3;
@ -150,12 +147,12 @@ in {
'';
};
package = mkPackageOption pkgs "minecraft-server" {
package = lib.mkPackageOption pkgs "minecraft-server" {
example = "minecraft-server_1_12_2";
};
jvmOpts = mkOption {
type = types.separatedString " ";
jvmOpts = lib.mkOption {
type = lib.types.separatedString " ";
default = "-Xmx2048M -Xms2048M";
# Example options from https://minecraft.gamepedia.com/Tutorials/Server_startup_script
example = "-Xms4092M -Xmx4092M -XX:+UseG1GC -XX:+CMSIncrementalPacing "
@ -166,7 +163,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.users.minecraft = {
description = "Minecraft server service user";
@ -259,11 +256,11 @@ in {
'');
};
networking.firewall = mkIf cfg.openFirewall (if cfg.declarative then {
networking.firewall = lib.mkIf cfg.openFirewall (if cfg.declarative then {
allowedUDPPorts = [ serverPort ];
allowedTCPPorts = [ serverPort ]
++ optional (queryPort != null) queryPort
++ optional (rconPort != null) rconPort;
++ lib.optional (queryPort != null) queryPort
++ lib.optional (rconPort != null) rconPort;
} else {
allowedUDPPorts = [ defaultServerPort ];
allowedTCPPorts = [ defaultServerPort ];

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
CONTAINS_NEWLINE_RE = ".*\n.*";
# The following values are reserved as complete option values:
@ -53,14 +50,14 @@ in
{
options = {
services.minetest-server = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "If enabled, starts a Minetest Server.";
};
gameId = mkOption {
type = types.nullOr types.str;
gameId = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
Id of the game to use. To list available games run
@ -70,8 +67,8 @@ in
'';
};
world = mkOption {
type = types.nullOr types.path;
world = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Name of the world to use. To list available worlds run
@ -81,8 +78,8 @@ in
'';
};
configPath = mkOption {
type = types.nullOr types.path;
configPath = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Path to the config to use.
@ -92,8 +89,8 @@ in
'';
};
config = mkOption {
type = types.attrsOf types.anything;
config = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = {};
description = ''
Settings to add to the minetest config file.
@ -102,8 +99,8 @@ in
'';
};
logPath = mkOption {
type = types.nullOr types.path;
logPath = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
Path to logfile for logging.
@ -113,8 +110,8 @@ in
'';
};
port = mkOption {
type = types.nullOr types.int;
port = lib.mkOption {
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
Port number to bind to.
@ -123,8 +120,8 @@ in
'';
};
extraArgs = mkOption {
type = types.listOf types.str;
extraArgs = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = ''
Additional command line flags to pass to the minetest executable.
@ -133,7 +130,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.users.minetest = {
description = "Minetest Server Service user";
home = "/var/lib/minetest";

View File

@ -1,13 +1,10 @@
{ config, lib, options, pkgs, ... }:
with lib;
let
cfg = config.services.terraria;
opt = options.services.terraria;
worldSizeMap = { small = 1; medium = 2; large = 3; };
valFlag = name: val: optionalString (val != null) "-${name} \"${escape ["\\" "\""] (toString val)}\"";
boolFlag = name: val: optionalString val "-${name}";
valFlag = name: val: lib.optionalString (val != null) "-${name} \"${lib.escape ["\\" "\""] (toString val)}\"";
boolFlag = name: val: lib.optionalString val "-${name}";
flags = [
(valFlag "port" cfg.port)
(valFlag "maxPlayers" cfg.maxPlayers)
@ -46,8 +43,8 @@ in
{
options = {
services.terraria = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
If enabled, starts a Terraria server. The server can be connected to via `tmux -S ''${config.${opt.dataDir}}/terraria.sock attach`
@ -55,40 +52,40 @@ in
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 7777;
description = ''
Specifies the port to listen on.
'';
};
maxPlayers = mkOption {
type = types.ints.u8;
maxPlayers = lib.mkOption {
type = lib.types.ints.u8;
default = 255;
description = ''
Sets the max number of players (between 1 and 255).
'';
};
password = mkOption {
type = types.nullOr types.str;
password = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
Sets the server password. Leave `null` for no password.
'';
};
messageOfTheDay = mkOption {
type = types.nullOr types.str;
messageOfTheDay = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
Set the server message of the day text.
'';
};
worldPath = mkOption {
type = types.nullOr types.path;
worldPath = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
The path to the world file (`.wld`) which should be loaded.
@ -97,8 +94,8 @@ in
'';
};
autoCreatedWorldSize = mkOption {
type = types.enum [ "small" "medium" "large" ];
autoCreatedWorldSize = lib.mkOption {
type = lib.types.enum [ "small" "medium" "large" ];
default = "medium";
description = ''
Specifies the size of the auto-created world if `worldPath` does not
@ -106,34 +103,34 @@ in
'';
};
banListPath = mkOption {
type = types.nullOr types.path;
banListPath = lib.mkOption {
type = lib.types.nullOr lib.types.path;
default = null;
description = ''
The path to the ban list.
'';
};
secure = mkOption {
type = types.bool;
secure = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Adds additional cheat protection to the server.";
};
noUPnP = mkOption {
type = types.bool;
noUPnP = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Disables automatic Universal Plug and Play.";
};
openFirewall = mkOption {
type = types.bool;
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to open ports in the firewall";
};
dataDir = mkOption {
type = types.str;
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/terraria";
example = "/srv/terraria";
description = "Path to variable state data directory for terraria.";
@ -141,7 +138,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.users.terraria = {
description = "Terraria server service user";
group = "terraria";
@ -165,12 +162,12 @@ in
Type = "forking";
GuessMainPID = true;
UMask = 007;
ExecStart = "${tmuxCmd} new -d ${pkgs.terraria-server}/bin/TerrariaServer ${concatStringsSep " " flags}";
ExecStart = "${tmuxCmd} new -d ${pkgs.terraria-server}/bin/TerrariaServer ${lib.concatStringsSep " " flags}";
ExecStop = "${stopScript} $MAINPID";
};
};
networking.firewall = mkIf cfg.openFirewall {
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.port ];
allowedUDPPorts = [ cfg.port ];
};

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.acpid;
@ -34,7 +31,7 @@ let
echo "event=${handler.event}" > $fn
echo "action=${pkgs.writeShellScriptBin "${name}.sh" handler.action }/bin/${name}.sh '%e'" >> $fn
'';
in concatStringsSep "\n" (mapAttrsToList f (canonicalHandlers // cfg.handlers))
in lib.concatStringsSep "\n" (lib.mapAttrsToList f (canonicalHandlers // cfg.handlers))
}
'';
@ -48,25 +45,25 @@ in
services.acpid = {
enable = mkEnableOption "the ACPI daemon";
enable = lib.mkEnableOption "the ACPI daemon";
logEvents = mkOption {
type = types.bool;
logEvents = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Log all event activity.";
};
handlers = mkOption {
type = types.attrsOf (types.submodule {
handlers = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options = {
event = mkOption {
type = types.str;
example = literalExpression ''"button/power.*" "button/lid.*" "ac_adapter.*" "button/mute.*" "button/volumedown.*" "cd/play.*" "cd/next.*"'';
event = lib.mkOption {
type = lib.types.str;
example = lib.literalExpression ''"button/power.*" "button/lid.*" "ac_adapter.*" "button/mute.*" "button/volumedown.*" "cd/play.*" "cd/next.*"'';
description = "Event type.";
};
action = mkOption {
type = types.lines;
action = lib.mkOption {
type = lib.types.lines;
description = "Shell commands to execute when the event is triggered.";
};
};
@ -101,20 +98,20 @@ in
};
};
powerEventCommands = mkOption {
type = types.lines;
powerEventCommands = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Shell commands to execute on a button/power.* event.";
};
lidEventCommands = mkOption {
type = types.lines;
lidEventCommands = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Shell commands to execute on a button/lid.* event.";
};
acEventCommands = mkOption {
type = types.lines;
acEventCommands = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Shell commands to execute on an ac_adapter.* event.";
};
@ -126,7 +123,7 @@ in
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.services.acpid = {
description = "ACPI Daemon";
@ -135,12 +132,12 @@ in
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = escapeShellArgs
ExecStart = lib.escapeShellArgs
([ "${pkgs.acpid}/bin/acpid"
"--foreground"
"--netlink"
"--confdir" "${acpiConfDir}"
] ++ optional cfg.logEvents "--logevents"
] ++ lib.optional cfg.logEvents "--logevents"
);
};
unitConfig = {

View File

@ -1,5 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.auto-cpufreq;
cfgFilename = "auto-cpufreq.conf";
@ -9,9 +8,9 @@ let
in {
options = {
services.auto-cpufreq = {
enable = mkEnableOption "auto-cpufreq daemon";
enable = lib.mkEnableOption "auto-cpufreq daemon";
settings = mkOption {
settings = lib.mkOption {
description = ''
Configuration for `auto-cpufreq`.
@ -19,12 +18,12 @@ in {
'';
default = {};
type = types.submodule { freeformType = format.type; };
type = lib.types.submodule { freeformType = format.type; };
};
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.auto-cpufreq ];
systemd = {

View File

@ -1,15 +1,12 @@
{ config, lib, pkgs, ...}:
with lib;
let
cfg = config.services.hardware.bolt;
in
{
options = {
services.hardware.bolt = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable Bolt, a userspace daemon to enable
@ -19,11 +16,11 @@ in
'';
};
package = mkPackageOption pkgs "bolt" { };
package = lib.mkPackageOption pkgs "bolt" { };
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ];
systemd.packages = [ cfg.package ];

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.brltty;
@ -22,15 +19,15 @@ in {
options = {
services.brltty.enable = mkOption {
type = types.bool;
services.brltty.enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable the BRLTTY daemon.";
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.users.brltty = {
description = "BRLTTY daemon user";
group = "brltty";

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.fancontrol;
configFile = pkgs.writeText "fancontrol.conf" cfg.config;
@ -9,10 +6,10 @@ let
in
{
options.hardware.fancontrol = {
enable = mkEnableOption "software fan control (requires fancontrol.config)";
enable = lib.mkEnableOption "software fan control (requires fancontrol.config)";
config = mkOption {
type = types.lines;
config = lib.mkOption {
type = lib.types.lines;
description = "Required fancontrol configuration file content. See {manpage}`pwmconfig(8)` from the lm_sensors package.";
example = ''
# Configuration file generated by pwmconfig
@ -29,7 +26,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.services.fancontrol = {
documentation = [ "man:fancontrol(8)" ];
@ -51,5 +48,5 @@ in
};
meta.maintainers = [ maintainers.evils ];
meta.maintainers = [ lib.maintainers.evils ];
}

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, utils, ... }:
with lib;
let
cfg = config.services.freefall;
@ -10,18 +7,18 @@ in {
options.services.freefall = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to protect HP/Dell laptop hard drives (not SSDs) in free fall.
'';
};
package = mkPackageOption pkgs "freefall" { };
package = lib.mkPackageOption pkgs "freefall" { };
devices = mkOption {
type = types.listOf types.str;
devices = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "/dev/sda" ];
description = ''
Device paths to all internal spinning hard drives.
@ -35,7 +32,7 @@ in {
mkService = dev:
assert dev != "";
let dev' = utils.escapeSystemdPath dev; in
nameValuePair "freefall-${dev'}" {
lib.nameValuePair "freefall-${dev'}" {
description = "Free-fall protection for ${dev}";
after = [ "${dev'}.device" ];
wantedBy = [ "${dev'}.device" ];
@ -46,7 +43,7 @@ in {
};
};
in mkIf cfg.enable {
in lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];

View File

@ -1,15 +1,11 @@
# fwupd daemon.
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.fwupd;
format = pkgs.formats.ini {
listToValue = l: lib.concatStringsSep ";" (map (s: generators.mkValueStringDefault {} s) l);
mkKeyValue = generators.mkKeyValueDefault {} "=";
listToValue = l: lib.concatStringsSep ";" (map (s: lib.generators.mkValueStringDefault {} s) l);
mkKeyValue = lib.generators.mkKeyValueDefault {} "=";
};
customEtc = {
@ -26,13 +22,13 @@ let
originalEtc =
let
mkEtcFile = n: nameValuePair n { source = "${cfg.package}/etc/${n}"; };
in listToAttrs (map mkEtcFile cfg.package.filesInstalledToEtc);
mkEtcFile = n: lib.nameValuePair n { source = "${cfg.package}/etc/${n}"; };
in lib.listToAttrs (map mkEtcFile cfg.package.filesInstalledToEtc);
extraTrustedKeys =
let
mkName = p: "pki/fwupd/${baseNameOf (toString p)}";
mkEtcFile = p: nameValuePair (mkName p) { source = p; };
in listToAttrs (map mkEtcFile cfg.extraTrustedKeys);
mkEtcFile = p: lib.nameValuePair (mkName p) { source = p; };
in lib.listToAttrs (map mkEtcFile cfg.extraTrustedKeys);
enableRemote = base: remote: {
"fwupd/remotes.d/${remote}.conf" = {
@ -42,7 +38,7 @@ let
'';
};
};
remotes = (foldl'
remotes = (lib.foldl'
(configFiles: remote: configFiles // (enableRemote cfg.package remote))
{}
cfg.extraRemotes
@ -61,8 +57,8 @@ in {
###### interface
options = {
services.fwupd = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable fwupd, a DBus service that allows
@ -70,17 +66,17 @@ in {
'';
};
extraTrustedKeys = mkOption {
type = types.listOf types.path;
extraTrustedKeys = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [];
example = literalExpression "[ /etc/nixos/fwupd/myfirmware.pem ]";
example = lib.literalExpression "[ /etc/nixos/fwupd/myfirmware.pem ]";
description = ''
Installing a public key allows firmware signed with a matching private key to be recognized as trusted, which may require less authentication to install than for untrusted files. By default trusted firmware can be upgraded (but not downgraded) without the user or administrator password. Only very few keys are installed by default.
'';
};
extraRemotes = mkOption {
type = with types; listOf str;
extraRemotes = lib.mkOption {
type = with lib.types; listOf str;
default = [];
example = [ "lvfs-testing" ];
description = ''
@ -88,14 +84,14 @@ in {
'';
};
package = mkPackageOption pkgs "fwupd" { };
package = lib.mkPackageOption pkgs "fwupd" { };
daemonSettings = mkOption {
type = types.submodule {
daemonSettings = lib.mkOption {
type = lib.types.submodule {
freeformType = format.type.nestedTypes.elemType;
options = {
DisabledDevices = mkOption {
type = types.listOf types.str;
DisabledDevices = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = [ "2082b5e0-7a64-478a-b1b2-e3404fab6dad" ];
description = ''
@ -103,8 +99,8 @@ in {
'';
};
DisabledPlugins = mkOption {
type = types.listOf types.str;
DisabledPlugins = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
example = [ "udev" ];
description = ''
@ -112,8 +108,8 @@ in {
'';
};
EspLocation = mkOption {
type = types.path;
EspLocation = lib.mkOption {
type = lib.types.path;
default = config.boot.loader.efi.efiSysMountPoint;
defaultText = lib.literalExpression "config.boot.loader.efi.efiSysMountPoint";
description = ''
@ -122,9 +118,9 @@ in {
'';
};
TestDevices = mkOption {
TestDevices = lib.mkOption {
internal = true;
type = types.bool;
type = lib.types.bool;
default = false;
description = ''
Create virtual test devices and remote for validating daemon flows.
@ -139,8 +135,8 @@ in {
'';
};
uefiCapsuleSettings = mkOption {
type = types.submodule {
uefiCapsuleSettings = lib.mkOption {
type = lib.types.submodule {
freeformType = format.type.nestedTypes.elemType;
};
default = {};
@ -152,15 +148,15 @@ in {
};
imports = [
(mkRenamedOptionModule [ "services" "fwupd" "blacklistDevices"] [ "services" "fwupd" "daemonSettings" "DisabledDevices" ])
(mkRenamedOptionModule [ "services" "fwupd" "blacklistPlugins"] [ "services" "fwupd" "daemonSettings" "DisabledPlugins" ])
(mkRenamedOptionModule [ "services" "fwupd" "disabledDevices" ] [ "services" "fwupd" "daemonSettings" "DisabledDevices" ])
(mkRenamedOptionModule [ "services" "fwupd" "disabledPlugins" ] [ "services" "fwupd" "daemonSettings" "DisabledPlugins" ])
(mkRemovedOptionModule [ "services" "fwupd" "enableTestRemote" ] "This option was removed after being removed upstream. It only provided a method for testing fwupd functionality, and should not have been exposed for use outside of nix tests.")
(lib.mkRenamedOptionModule [ "services" "fwupd" "blacklistDevices"] [ "services" "fwupd" "daemonSettings" "DisabledDevices" ])
(lib.mkRenamedOptionModule [ "services" "fwupd" "blacklistPlugins"] [ "services" "fwupd" "daemonSettings" "DisabledPlugins" ])
(lib.mkRenamedOptionModule [ "services" "fwupd" "disabledDevices" ] [ "services" "fwupd" "daemonSettings" "DisabledDevices" ])
(lib.mkRenamedOptionModule [ "services" "fwupd" "disabledPlugins" ] [ "services" "fwupd" "daemonSettings" "DisabledPlugins" ])
(lib.mkRemovedOptionModule [ "services" "fwupd" "enableTestRemote" ] "This option was removed after being removed upstream. It only provided a method for testing fwupd functionality, and should not have been exposed for use outside of nix tests.")
];
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
# Disable test related plug-ins implicitly so that users do not have to care about them.
services.fwupd.daemonSettings = {
EspLocation = config.boot.loader.efi.efiSysMountPoint;

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.illum;
in {
@ -10,9 +7,9 @@ in {
services.illum = {
enable = mkOption {
enable = lib.mkOption {
default = false;
type = types.bool;
type = lib.types.bool;
description = ''
Enable illum, a daemon for controlling screen brightness with brightness buttons.
'';
@ -22,7 +19,7 @@ in {
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.services.illum = {
description = "Backlight Adjustment Service";

View File

@ -1,29 +1,26 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.interception-tools;
in {
options.services.interception-tools = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable the interception tools service.";
};
plugins = mkOption {
type = types.listOf types.package;
plugins = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ pkgs.interception-tools-plugins.caps2esc ];
defaultText = literalExpression "[ pkgs.interception-tools-plugins.caps2esc ]";
defaultText = lib.literalExpression "[ pkgs.interception-tools-plugins.caps2esc ]";
description = ''
A list of interception tools plugins that will be made available to use
inside the udevmon configuration.
'';
};
udevmonConfig = mkOption {
type = types.either types.str types.path;
udevmonConfig = lib.mkOption {
type = lib.types.either lib.types.str lib.types.path;
default = ''
- JOB: "intercept -g $DEVNODE | caps2esc | uinput -d $DEVNODE"
DEVICE:
@ -43,7 +40,7 @@ in {
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.services.interception-tools = {
description = "Interception tools";
path = [ pkgs.bash pkgs.interception-tools ] ++ cfg.plugins;

View File

@ -1,17 +1,14 @@
#
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.irqbalance;
in
{
options.services.irqbalance.enable = mkEnableOption "irqbalance daemon";
options.services.irqbalance.enable = lib.mkEnableOption "irqbalance daemon";
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.irqbalance ];

View File

@ -1,19 +1,15 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.joycond;
in
with lib;
{
options.services.joycond = {
enable = mkEnableOption "support for Nintendo Pro Controllers and Joycons";
enable = lib.mkEnableOption "support for Nintendo Pro Controllers and Joycons";
package = mkPackageOption pkgs "joycond" { };
package = lib.mkPackageOption pkgs "joycond" { };
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ];

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, utils, ... }:
with lib;
let
cfg = config.services.kanata;
@ -9,8 +6,8 @@ let
keyboard = { name, config, ... }: {
options = {
devices = mkOption {
type = types.listOf types.str;
devices = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "/dev/input/by-id/usb-0000_0000-event-kbd" ];
description = ''
@ -20,8 +17,8 @@ let
input devices are keyboards and intercept them all.
'';
};
config = mkOption {
type = types.lines;
config = lib.mkOption {
type = lib.types.lines;
example = ''
(defsrc
caps)
@ -36,8 +33,8 @@ let
${upstreamDoc}
'';
};
extraDefCfg = mkOption {
type = types.lines;
extraDefCfg = lib.mkOption {
type = lib.types.lines;
default = "";
example = "danger-enable-cmd yes";
description = ''
@ -48,8 +45,8 @@ let
${upstreamDoc}
'';
};
configFile = mkOption {
type = types.path;
configFile = lib.mkOption {
type = lib.types.path;
default = mkConfig name config;
defaultText =
"A config file generated by values from other kanata module options.";
@ -63,13 +60,13 @@ let
overrides all other kanata module options. ${upstreamDoc}
'';
};
extraArgs = mkOption {
type = types.listOf types.str;
extraArgs = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Extra command line arguments passed to kanata.";
};
port = mkOption {
type = types.nullOr types.port;
port = lib.mkOption {
type = lib.types.nullOr lib.types.port;
default = null;
example = 6666;
description = ''
@ -83,12 +80,12 @@ let
mkDevices = devices:
let
devicesString = pipe devices [
devicesString = lib.pipe devices [
(map (device: "\"" + device + "\""))
(concatStringsSep " ")
(lib.concatStringsSep " ")
];
in
optionalString ((length devices) > 0) "linux-dev (${devicesString})";
lib.optionalString ((lib.length devices) > 0) "linux-dev (${devicesString})";
mkConfig = name: keyboard: pkgs.writeTextFile {
name = "${mkName name}-config.kdb";
@ -105,20 +102,20 @@ let
# at build time. I think this is a good balance between module
# complexity and functionality.
checkPhase = ''
${getExe cfg.package} --cfg "$target" --check --debug
${lib.getExe cfg.package} --cfg "$target" --check --debug
'';
};
mkService = name: keyboard: nameValuePair (mkName name) {
mkService = name: keyboard: lib.nameValuePair (mkName name) {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "notify";
ExecStart = ''
${getExe cfg.package} \
${lib.getExe cfg.package} \
--cfg ${keyboard.configFile} \
--symlink-path ''${RUNTIME_DIRECTORY}/${name} \
${optionalString (keyboard.port != null) "--port ${toString keyboard.port}"} \
${utils.escapeSystemdExecArgs keyboard.extraArgs}
${lib.optionalString (keyboard.port != null) "--port ${toString keyboard.port}"} \
${utils.lib.escapeSystemdExecArgs keyboard.extraArgs}
'';
DynamicUser = true;
@ -135,7 +132,7 @@ let
];
CapabilityBoundingSet = [ "" ];
DevicePolicy = "closed";
IPAddressAllow = optional (keyboard.port != null) "localhost";
IPAddressAllow = lib.optional (keyboard.port != null) "localhost";
IPAddressDeny = [ "any" ];
LockPersonality = true;
MemoryDenyWriteExecute = true;
@ -150,7 +147,7 @@ let
ProtectKernelModules = true;
ProtectKernelTunables = true;
ProtectProc = "invisible";
RestrictAddressFamilies = [ "AF_UNIX" ] ++ optional (keyboard.port != null) "AF_INET";
RestrictAddressFamilies = [ "AF_UNIX" ] ++ lib.optional (keyboard.port != null) "AF_INET";
RestrictNamespaces = true;
RestrictRealtime = true;
SystemCallArchitectures = [ "native" ];
@ -165,8 +162,8 @@ let
in
{
options.services.kanata = {
enable = mkEnableOption "kanata, a tool to improve keyboard comfort and usability with advanced customization";
package = mkPackageOption pkgs "kanata" {
enable = lib.mkEnableOption "kanata, a tool to improve keyboard comfort and usability with advanced customization";
package = lib.mkPackageOption pkgs "kanata" {
example = [ "kanata-with-cmd" ];
extraDescription = ''
::: {.note}
@ -175,26 +172,26 @@ in
:::
'';
};
keyboards = mkOption {
type = types.attrsOf (types.submodule keyboard);
keyboards = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule keyboard);
default = { };
description = "Keyboard configurations.";
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
warnings =
let
keyboardsWithEmptyDevices = filterAttrs (name: keyboard: keyboard.devices == [ ]) cfg.keyboards;
existEmptyDevices = length (attrNames keyboardsWithEmptyDevices) > 0;
moreThanOneKeyboard = length (attrNames cfg.keyboards) > 1;
keyboardsWithEmptyDevices = lib.filterAttrs (name: keyboard: keyboard.devices == [ ]) cfg.keyboards;
existEmptyDevices = lib.length (lib.attrNames keyboardsWithEmptyDevices) > 0;
moreThanOneKeyboard = lib.length (lib.attrNames cfg.keyboards) > 1;
in
optional (existEmptyDevices && moreThanOneKeyboard) "One device can only be intercepted by one kanata instance. Setting services.kanata.keyboards.${head (attrNames keyboardsWithEmptyDevices)}.devices = [ ] and using more than one services.kanata.keyboards may cause a race condition.";
lib.optional (existEmptyDevices && moreThanOneKeyboard) "One device can only be intercepted by one kanata instance. Setting services.kanata.keyboards.${lib.head (lib.attrNames keyboardsWithEmptyDevices)}.devices = [ ] and using more than one services.kanata.keyboards may cause a race condition.";
hardware.uinput.enable = true;
systemd.services = mapAttrs' mkService cfg.keyboards;
systemd.services = lib.mapAttrs' mkService cfg.keyboards;
};
meta.maintainers = with maintainers; [ linj ];
meta.maintainers = with lib.maintainers; [ linj ];
}

View File

@ -1,12 +1,11 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.keyd;
keyboardOptions = { ... }: {
options = {
ids = mkOption {
type = types.listOf types.str;
ids = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "*" ];
example = [ "*" "-0123:0456" ];
description = ''
@ -14,7 +13,7 @@ let
'';
};
settings = mkOption {
settings = lib.mkOption {
type = (pkgs.formats.ini { }).type;
default = { };
example = {
@ -37,8 +36,8 @@ let
'';
};
extraConfig = mkOption {
type = types.lines;
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
example = ''
[control+shift]
@ -55,19 +54,19 @@ let
in
{
imports = [
(mkRemovedOptionModule [ "services" "keyd" "ids" ]
(lib.mkRemovedOptionModule [ "services" "keyd" "ids" ]
''Use keyboards.<filename>.ids instead. If you don't need a multi-file configuration, just add keyboards.default before the ids. See https://github.com/NixOS/nixpkgs/pull/243271.'')
(mkRemovedOptionModule [ "services" "keyd" "settings" ]
(lib.mkRemovedOptionModule [ "services" "keyd" "settings" ]
''Use keyboards.<filename>.settings instead. If you don't need a multi-file configuration, just add keyboards.default before the settings. See https://github.com/NixOS/nixpkgs/pull/243271.'')
];
options.services.keyd = {
enable = mkEnableOption "keyd, a key remapping daemon";
enable = lib.mkEnableOption "keyd, a key remapping daemon";
keyboards = mkOption {
type = types.attrsOf (types.submodule keyboardOptions);
keyboards = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule keyboardOptions);
default = { };
example = literalExpression ''
example = lib.literalExpression ''
{
default = {
ids = [ "*" ];
@ -93,16 +92,16 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
# Creates separate files in the `/etc/keyd/` directory for each key in the dictionary
environment.etc = mapAttrs'
environment.etc = lib.mapAttrs'
(name: options:
nameValuePair "keyd/${name}.conf" {
lib.nameValuePair "keyd/${name}.conf" {
text = ''
[ids]
${concatStringsSep "\n" options.ids}
${lib.concatStringsSep "\n" options.ids}
${generators.toINI {} options.settings}
${lib.generators.toINI {} options.settings}
${options.extraConfig}
'';
})
@ -116,7 +115,7 @@ in
wantedBy = [ "multi-user.target" ];
restartTriggers = mapAttrsToList
restartTriggers = lib.mapAttrsToList
(name: options:
config.environment.etc."keyd/${name}.conf".source
)

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