Skip to content

Commit

Permalink
Merge master into haskell-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Aug 16, 2023
2 parents 7000d9d + 8ce8940 commit 4a85282
Show file tree
Hide file tree
Showing 173 changed files with 1,850 additions and 946 deletions.
4 changes: 2 additions & 2 deletions lib/strings.nix
Expand Up @@ -629,10 +629,10 @@ rec {
This behavior is deprecated and will throw an error in the future.''
(let
preLen = stringLength prefix;
sLen = stringLength str;
in
if substring 0 preLen str == prefix then
substring preLen (sLen - preLen) str
# -1 will take the string until the end
substring preLen (-1) str
else
str);

Expand Down
21 changes: 21 additions & 0 deletions lib/tests/misc.nix
Expand Up @@ -349,6 +349,27 @@ runTests {
expected = true;
};

testRemovePrefixExample1 = {
expr = removePrefix "foo." "foo.bar.baz";
expected = "bar.baz";
};
testRemovePrefixExample2 = {
expr = removePrefix "xxx" "foo.bar.baz";
expected = "foo.bar.baz";
};
testRemovePrefixEmptyPrefix = {
expr = removePrefix "" "foo";
expected = "foo";
};
testRemovePrefixEmptyString = {
expr = removePrefix "foo" "";
expected = "";
};
testRemovePrefixEmptyBoth = {
expr = removePrefix "" "";
expected = "";
};

testNormalizePath = {
expr = strings.normalizePath "//a/b//c////d/";
expected = "/a/b/c/d/";
Expand Down
18 changes: 18 additions & 0 deletions maintainers/maintainer-list.nix
Expand Up @@ -8730,6 +8730,11 @@
githubId = 1927188;
name = "karolchmist";
};
katexochen = {
github = "katexochen";
githubId = 49727155;
name = "Paul Meyer";
};
kayhide = {
email = "kayhide@gmail.com";
github = "kayhide";
Expand Down Expand Up @@ -15087,6 +15092,13 @@
fingerprint = "30BB FF3F AB0B BB3E 0435 F83C 8E8F F66E 2AE8 D970";
}];
};
scm2342 = {
name = "Sven Mattsen";
email = "nix@sven.cc";
matrix = "@scm:matrix.sven.cc";
github = "scm2342";
githubId = 154108;
};
scode = {
email = "peter.schuller@infidyne.com";
github = "scode";
Expand Down Expand Up @@ -17799,6 +17811,12 @@
fingerprint = "5814 50EB 6E17 E715 7C63 E7F1 9879 8C3C 4D68 8D6D";
}];
};
viluon = {
email = "nix@viluon.me";
github = "viluon";
githubId = 7235381;
name = "Ondřej Kvapil";
};
vincentbernat = {
email = "vincent@bernat.ch";
github = "vincentbernat";
Expand Down
1 change: 1 addition & 0 deletions maintainers/team-list.nix
Expand Up @@ -413,6 +413,7 @@ with lib.maintainers; {

jupyter = {
members = [
GaetanLepage
natsukium
];
scope = "Maintain Jupyter and related packages.";
Expand Down
6 changes: 3 additions & 3 deletions nixos/modules/i18n/input-method/fcitx5.nix
Expand Up @@ -107,14 +107,14 @@ in
};
in
lib.attrsets.mergeAttrsList [
(optionalFile "config" (lib.generators.toINI { }) sts.globalOptions)
(optionalFile "profile" (lib.generators.toINI { }) sts.inputMethod)
(optionalFile "config" (lib.generators.toINI { }) cfg.settings.globalOptions)
(optionalFile "profile" (lib.generators.toINI { }) cfg.settings.inputMethod)
(lib.concatMapAttrs
(name: value: optionalFile
"conf/${name}.conf"
(lib.generators.toINIWithGlobalSection { })
value)
sts.addons)
cfg.settings.addons)
];

environment.variables = {
Expand Down
17 changes: 6 additions & 11 deletions nixos/modules/services/networking/haproxy.nix
Expand Up @@ -17,14 +17,9 @@ with lib;
options = {
services.haproxy = {

enable = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc ''
Whether to enable HAProxy, the reliable, high performance TCP/HTTP
load balancer.
'';
};
enable = mkEnableOption (lib.mdDoc "HAProxy, the reliable, high performance TCP/HTTP load balancer.");

package = mkPackageOptionMD pkgs "haproxy" { };

user = mkOption {
type = types.str;
Expand Down Expand Up @@ -70,15 +65,15 @@ with lib;
ExecStartPre = [
# when the master process receives USR2, it reloads itself using exec(argv[0]),
# so we create a symlink there and update it before reloading
"${pkgs.coreutils}/bin/ln -sf ${pkgs.haproxy}/sbin/haproxy /run/haproxy/haproxy"
"${pkgs.coreutils}/bin/ln -sf ${lib.getExe cfg.package} /run/haproxy/haproxy"
# when running the config test, don't be quiet so we can see what goes wrong
"/run/haproxy/haproxy -c -f ${haproxyCfg}"
];
ExecStart = "/run/haproxy/haproxy -Ws -f /etc/haproxy.cfg -p /run/haproxy/haproxy.pid";
# support reloading
ExecReload = [
"${pkgs.haproxy}/sbin/haproxy -c -f ${haproxyCfg}"
"${pkgs.coreutils}/bin/ln -sf ${pkgs.haproxy}/sbin/haproxy /run/haproxy/haproxy"
"${lib.getExe cfg.package} -c -f ${haproxyCfg}"
"${pkgs.coreutils}/bin/ln -sf ${lib.getExe cfg.package} /run/haproxy/haproxy"
"${pkgs.coreutils}/bin/kill -USR2 $MAINPID"
];
KillMode = "mixed";
Expand Down
14 changes: 8 additions & 6 deletions nixos/modules/services/security/kanidm.nix
Expand Up @@ -69,6 +69,8 @@ in
enableServer = lib.mkEnableOption (lib.mdDoc "the Kanidm server");
enablePam = lib.mkEnableOption (lib.mdDoc "the Kanidm PAM and NSS integration");

package = lib.mkPackageOptionMD pkgs "kanidm" {};

serverSettings = lib.mkOption {
type = lib.types.submodule {
freeformType = settingsFormat.type;
Expand Down Expand Up @@ -222,7 +224,7 @@ in
}
];

environment.systemPackages = lib.mkIf cfg.enableClient [ pkgs.kanidm ];
environment.systemPackages = lib.mkIf cfg.enableClient [ cfg.package ];

systemd.services.kanidm = lib.mkIf cfg.enableServer {
description = "kanidm identity management daemon";
Expand All @@ -237,7 +239,7 @@ in
StateDirectory = "kanidm";
StateDirectoryMode = "0700";
RuntimeDirectory = "kanidmd";
ExecStart = "${pkgs.kanidm}/bin/kanidmd server -c ${serverConfigFile}";
ExecStart = "${cfg.package}/bin/kanidmd server -c ${serverConfigFile}";
User = "kanidm";
Group = "kanidm";

Expand Down Expand Up @@ -270,7 +272,7 @@ in
CacheDirectory = "kanidm-unixd";
CacheDirectoryMode = "0700";
RuntimeDirectory = "kanidm-unixd";
ExecStart = "${pkgs.kanidm}/bin/kanidm_unixd";
ExecStart = "${cfg.package}/bin/kanidm_unixd";
User = "kanidm-unixd";
Group = "kanidm-unixd";

Expand Down Expand Up @@ -302,7 +304,7 @@ in
partOf = [ "kanidm-unixd.service" ];
restartTriggers = [ unixConfigFile clientConfigFile ];
serviceConfig = {
ExecStart = "${pkgs.kanidm}/bin/kanidm_unixd_tasks";
ExecStart = "${cfg.package}/bin/kanidm_unixd_tasks";

BindReadOnlyPaths = [
"/nix/store"
Expand Down Expand Up @@ -346,7 +348,7 @@ in
})
];

system.nssModules = lib.mkIf cfg.enablePam [ pkgs.kanidm ];
system.nssModules = lib.mkIf cfg.enablePam [ cfg.package ];

system.nssDatabases.group = lib.optional cfg.enablePam "kanidm";
system.nssDatabases.passwd = lib.optional cfg.enablePam "kanidm";
Expand All @@ -365,7 +367,7 @@ in
description = "Kanidm server";
isSystemUser = true;
group = "kanidm";
packages = with pkgs; [ kanidm ];
packages = [ cfg.package ];
};
})
(lib.mkIf cfg.enablePam {
Expand Down
64 changes: 52 additions & 12 deletions nixos/modules/services/web-apps/invidious.nix
Expand Up @@ -7,29 +7,57 @@ let

settingsFile = settingsFormat.generate "invidious-settings" cfg.settings;

generatedHmacKeyFile = "/var/lib/invidious/hmac_key";
generateHmac = cfg.hmacKeyFile == null;

serviceConfig = {
systemd.services.invidious = {
description = "Invidious (An alternative YouTube front-end)";
wants = [ "network-online.target" ];
after = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];

script =
let
jqFilter = "."
+ lib.optionalString (cfg.database.host != null) "[0].db.password = \"'\"'\"$(cat ${lib.escapeShellArg cfg.database.passwordFile})\"'\"'\""
+ " | .[0]"
+ lib.optionalString (cfg.extraSettingsFile != null) " * .[1]";
jqFiles = [ settingsFile ] ++ lib.optional (cfg.extraSettingsFile != null) cfg.extraSettingsFile;
in
''
export INVIDIOUS_CONFIG="$(${pkgs.jq}/bin/jq -s "${jqFilter}" ${lib.escapeShellArgs jqFiles})"
exec ${cfg.package}/bin/invidious
'';
preStart = lib.optionalString generateHmac ''
if [[ ! -e "${generatedHmacKeyFile}" ]]; then
${pkgs.pwgen}/bin/pwgen 20 1 > "${generatedHmacKeyFile}"
chmod 0600 "${generatedHmacKeyFile}"
fi
'';

script = ''
configParts=()
''
# autogenerated hmac_key
+ lib.optionalString generateHmac ''
configParts+=("$(${pkgs.jq}/bin/jq -R '{"hmac_key":.}' <"${generatedHmacKeyFile}")")
''
# generated settings file
+ ''
configParts+=("$(< ${lib.escapeShellArg settingsFile})")
''
# optional database password file
+ lib.optionalString (cfg.database.host != null) ''
configParts+=("$(${pkgs.jq}/bin/jq -R '{"db":{"password":.}}' ${lib.escapeShellArg cfg.database.passwordFile})")
''
# optional extra settings file
+ lib.optionalString (cfg.extraSettingsFile != null) ''
configParts+=("$(< ${lib.escapeShellArg cfg.extraSettingsFile})")
''
# explicitly specified hmac key file
+ lib.optionalString (cfg.hmacKeyFile != null) ''
configParts+=("$(< ${lib.escapeShellArg cfg.hmacKeyFile})")
''
# merge all parts into a single configuration with later elements overriding previous elements
+ ''
export INVIDIOUS_CONFIG="$(${pkgs.jq}/bin/jq -s 'reduce .[] as $item ({}; . * $item)' <<<"''${configParts[*]}")"
exec ${cfg.package}/bin/invidious
'';

serviceConfig = {
RestartSec = "2s";
DynamicUser = true;
StateDirectory = "invidious";
StateDirectoryMode = "0750";

CapabilityBoundingSet = "";
PrivateDevices = true;
Expand Down Expand Up @@ -171,6 +199,18 @@ in
'';
};

hmacKeyFile = lib.mkOption {
type = types.nullOr types.path;
default = null;
description = lib.mdDoc ''
A path to a file containing the `hmac_key`. If `null`, a key will be generated automatically on first
start.
If non-`null`, this option overrides any `hmac_key` specified in {option}`services.invidious.settings` or
via {option}`services.invidious.extraSettingsFile`.
'';
};

extraSettingsFile = lib.mkOption {
type = types.nullOr types.str;
default = null;
Expand Down
6 changes: 4 additions & 2 deletions nixos/modules/services/x11/picom.nix
Expand Up @@ -61,6 +61,8 @@ in {
'';
};

package = mkPackageOptionMD pkgs "picom" { };

fade = mkOption {
type = types.bool;
default = false;
Expand Down Expand Up @@ -301,13 +303,13 @@ in {
};

serviceConfig = {
ExecStart = "${pkgs.picom}/bin/picom --config ${configFile}";
ExecStart = "${getExe cfg.package} --config ${configFile}";
RestartSec = 3;
Restart = "always";
};
};

environment.systemPackages = [ pkgs.picom ];
environment.systemPackages = [ cfg.package ];
};

meta.maintainers = with lib.maintainers; [ rnhmjoj ];
Expand Down
11 changes: 0 additions & 11 deletions nixos/tests/fcitx5/config

This file was deleted.

47 changes: 37 additions & 10 deletions nixos/tests/fcitx5/default.nix
Expand Up @@ -36,14 +36,50 @@ rec {
pkgs.fcitx5-m17n
pkgs.fcitx5-mozc
];
fcitx5.settings = {
globalOptions = {
"Hotkey"."EnumerateSkipFirst" = "False";
"Hotkey/TriggerKeys"."0" = "Control+space";
"Hotkey/EnumerateForwardKeys"."0" = "Alt+Shift_L";
"Hotkey/EnumerateBackwardKeys"."0" = "Alt+Shift_R";
};
inputMethod = {
"GroupOrder" = {
"0" = "NixOS_test";
};
"Groups/0" = {
"Default Layout" = "us";
"DefaultIM" = "wbx";
"Name" = "NixOS_test";
};
"Groups/0/Items/0" = {
"Name" = "keyboard-us";
};
"Groups/0/Items/1" = {
"Layout" = "us";
"Name" = "wbx";
};
"Groups/0/Items/2" = {
"Layout" = "us";
"Name" = "hangul";
};
"Groups/0/Items/3" = {
"Layout" = "us";
"Name" = "m17n_sa_harvard-kyoto";
};
"Groups/0/Items/4" = {
"Layout" = "us";
"Name" = "mozc";
};
};
};
};
};

testScript = { nodes, ... }:
let
user = nodes.machine.users.users.alice;
xauth = "${user.home}/.Xauthority";
fcitx_confdir = "${user.home}/.config/fcitx5";
in
''
start_all()
Expand All @@ -56,15 +92,6 @@ rec {
machine.succeed("su - ${user.name} -c 'kill $(pgrep fcitx5)'")
machine.sleep(1)
machine.copy_from_host(
"${./profile}",
"${fcitx_confdir}/profile",
)
machine.copy_from_host(
"${./config}",
"${fcitx_confdir}/config",
)
machine.succeed("su - ${user.name} -c 'alacritty >&2 &'")
machine.succeed("su - ${user.name} -c 'fcitx5 >&2 &'")
machine.sleep(10)
Expand Down

0 comments on commit 4a85282

Please sign in to comment.