Skip to content

Commit

Permalink
Merge staging-next-23.11 into staging-23.11
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Dec 1, 2023
2 parents f06ae9e + b2f8bcb commit 6bbceb4
Show file tree
Hide file tree
Showing 73 changed files with 922 additions and 428 deletions.
5 changes: 2 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,8 @@ pkgs/applications/version-management/forgejo @bendlas @emilylange
/pkgs/development/ocaml-modules @ulrikstrid

# ZFS
pkgs/os-specific/linux/zfs @raitobezarius
nixos/lib/make-single-disk-zfs-image.nix @raitobezarius
nixos/lib/make-multi-disk-zfs-image.nix @raitobezarius
pkgs/os-specific/linux/zfs/2_1.nix @raitobezarius
pkgs/os-specific/linux/zfs/generic.nix @raitobezarius
nixos/modules/tasks/filesystems/zfs.nix @raitobezarius
nixos/tests/zfs.nix @raitobezarius

Expand Down
29 changes: 20 additions & 9 deletions lib/attrsets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,10 @@ rec {
recursiveUpdateUntil (path: lhs: rhs: !(isAttrs lhs && isAttrs rhs)) lhs rhs;


/* Returns true if the pattern is contained in the set. False otherwise.
/*
Recurse into every attribute set of the first argument and check that:
- Each attribute path also exists in the second argument.
- If the attribute's value is not a nested attribute set, it must have the same value in the right argument.
Example:
matchAttrs { cpu = {}; } { cpu = { bits = 64; }; }
Expand All @@ -895,16 +898,24 @@ rec {
matchAttrs =
# Attribute set structure to match
pattern:
# Attribute set to find patterns in
# Attribute set to check
attrs:
assert isAttrs pattern;
all id (attrValues (zipAttrsWithNames (attrNames pattern) (n: values:
let pat = head values; val = elemAt values 1; in
if length values == 1 then false
else if isAttrs pat then isAttrs val && matchAttrs pat val
else pat == val
) [pattern attrs]));

all
( # Compare equality between `pattern` & `attrs`.
attr:
# Missing attr, not equal.
attrs ? ${attr} && (
let
lhs = pattern.${attr};
rhs = attrs.${attr};
in
# If attrset check recursively
if isAttrs lhs then isAttrs rhs && matchAttrs lhs rhs
else lhs == rhs
)
)
(attrNames pattern);

/* Override only the attributes that are already present in the old set
useful for deep-overriding.
Expand Down
20 changes: 20 additions & 0 deletions lib/tests/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,26 @@ runTests {
};
};

testMatchAttrsMatchingExact = {
expr = matchAttrs { cpu = { bits = 64; }; } { cpu = { bits = 64; }; };
expected = true;
};

testMatchAttrsMismatch = {
expr = matchAttrs { cpu = { bits = 128; }; } { cpu = { bits = 64; }; };
expected = false;
};

testMatchAttrsMatchingImplicit = {
expr = matchAttrs { cpu = { }; } { cpu = { bits = 64; }; };
expected = true;
};

testMatchAttrsMissingAttrs = {
expr = matchAttrs { cpu = {}; } { };
expected = false;
};

testOverrideExistingEmpty = {
expr = overrideExisting {} { a = 1; };
expected = {};
Expand Down
9 changes: 6 additions & 3 deletions nixos/modules/installer/tools/tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ in
'';
};

config = lib.mkIf (config.nix.enable && !config.system.disableInstallerTools) {
config = lib.mkMerge [ (lib.mkIf (config.nix.enable && !config.system.disableInstallerTools) {

system.nixos-generate-config.configuration = mkDefault ''
# Edit this configuration file to define what should be installed on
Expand Down Expand Up @@ -257,10 +257,13 @@ in

documentation.man.man-db.skipPackages = [ nixos-version ];

})

# These may be used in auxiliary scripts (ie not part of toplevel), so they are defined unconditionally.
({
system.build = {
inherit nixos-install nixos-generate-config nixos-option nixos-rebuild nixos-enter;
};

};
})];

}
13 changes: 13 additions & 0 deletions nixos/modules/profiles/macos-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ in
# server that QEMU provides (normally 10.0.2.3)
networking.nameservers = [ "8.8.8.8" ];

# The linux builder is a lightweight VM for remote building; not evaluation.
nix.channel.enable = false;
# remote builder uses `nix-daemon` (ssh-ng:) or `nix-store --serve` (ssh:)
# --force: do not complain when missing
# TODO: install a store-only nix
# https://github.com/NixOS/rfcs/blob/master/rfcs/0134-nix-store-layer.md#detailed-design
environment.extraSetup = ''
rm --force $out/bin/{nix-instantiate,nix-build,nix-shell,nix-prefetch*,nix}
'';
# Deployment is by image.
# TODO system.switch.enable = false;?
system.disableInstallerTools = true;

nix.settings = {
auto-optimise-store = true;

Expand Down
8 changes: 2 additions & 6 deletions nixos/modules/services/backup/syncoid.nix
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ in
};

sshKey = mkOption {
type = types.nullOr types.path;
# Prevent key from being copied to store
apply = mapNullable toString;
type = with types; nullOr (coercedTo path toString str);
default = null;
description = lib.mdDoc ''
SSH private key file to use to login to the remote system. Can be
Expand Down Expand Up @@ -205,9 +203,7 @@ in
recursive = mkEnableOption (lib.mdDoc ''the transfer of child datasets'');

sshKey = mkOption {
type = types.nullOr types.path;
# Prevent key from being copied to store
apply = mapNullable toString;
type = with types; nullOr (coercedTo path toString str);
description = lib.mdDoc ''
SSH private key file to use to login to the remote system.
Defaults to {option}`services.syncoid.sshKey` option.
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/web-apps/jitsi-meet.nix
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ in
extraConfig =
let
templatedJitsiMeet = pkgs.runCommand "templated-jitsi-meet" { } ''
cp -R ${pkgs.jitsi-meet}/* .
cp -R --no-preserve=all ${pkgs.jitsi-meet}/* .
for file in *.html **/*.html ; do
${pkgs.sd}/bin/sd '<!--#include virtual="(.*)" -->' '{{ include "$1" }}' $file
done
Expand Down
7 changes: 2 additions & 5 deletions nixos/modules/services/web-apps/mediawiki.nix
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,8 @@ in
"${if hasSSL config.services.nginx.virtualHosts.${cfg.nginx.hostName} then "https" else "http"}://${cfg.nginx.hostName}"
else
"http://localhost";
defaultText = literalExpression ''
if cfg.webserver == "apache" then
"''${if cfg.httpd.virtualHost.addSSL || cfg.httpd.virtualHost.forceSSL || cfg.httpd.virtualHost.onlySSL then "https" else "http"}://''${cfg.httpd.virtualHost.hostName}"
else
"http://localhost";
defaultText = ''
if "mediawiki uses ssl" then "{"https" else "http"}://''${cfg.hostName}" else "http://localhost";
'';
example = "https://wiki.example.org";
description = lib.mdDoc "URL of the wiki.";
Expand Down
15 changes: 15 additions & 0 deletions nixos/modules/services/x11/window-managers/i3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ with lib;

let
cfg = config.services.xserver.windowManager.i3;
updateSessionEnvironmentScript = ''
systemctl --user import-environment PATH DISPLAY XAUTHORITY DESKTOP_SESSION XDG_CONFIG_DIRS XDG_DATA_DIRS XDG_RUNTIME_DIR XDG_SESSION_ID DBUS_SESSION_BUS_ADDRESS || true
dbus-update-activation-environment --systemd --all || true
'';
in

{
Expand All @@ -19,6 +23,15 @@ in
'';
};

updateSessionEnvironment = mkOption {
default = true;
type = types.bool;
description = lib.mdDoc ''
Whether to run dbus-update-activation-environment and systemctl import-environment before session start.
Required for xdg portals to function properly.
'';
};

extraSessionCommands = mkOption {
default = "";
type = types.lines;
Expand Down Expand Up @@ -58,6 +71,8 @@ in
start = ''
${cfg.extraSessionCommands}
${lib.optionalString cfg.updateSessionEnvironment updateSessionEnvironmentScript}
${cfg.package}/bin/i3 ${optionalString (cfg.configFile != null)
"-c /etc/i3/config"
} &
Expand Down
31 changes: 19 additions & 12 deletions nixos/modules/tasks/filesystems/zfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ let
cfgTrim = config.services.zfs.trim;
cfgZED = config.services.zfs.zed;

selectModulePackage = package: config.boot.kernelPackages.${package.kernelModuleAttribute};
inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;

Expand Down Expand Up @@ -210,11 +211,17 @@ in
options = {
boot.zfs = {
package = mkOption {
readOnly = true;
type = types.package;
default = if config.boot.zfs.enableUnstable then pkgs.zfsUnstable else pkgs.zfs;
defaultText = literalExpression "if config.boot.zfs.enableUnstable then pkgs.zfsUnstable else pkgs.zfs";
description = lib.mdDoc "Configured ZFS userland tools package.";
default = if cfgZfs.enableUnstable then pkgs.zfsUnstable else pkgs.zfs;
defaultText = literalExpression "if zfsUnstable is enabled then pkgs.zfsUnstable else pkgs.zfs";
description = lib.mdDoc "Configured ZFS userland tools package, use `pkgs.zfsUnstable` if you want to track the latest staging ZFS branch.";
};

modulePackage = mkOption {
internal = true; # It is supposed to be selected automatically, but can be overridden by expert users.
default = selectModulePackage cfgZfs.package;
type = types.package;
description = lib.mdDoc "Configured ZFS kernel module package.";
};

enabled = mkOption {
Expand Down Expand Up @@ -533,6 +540,10 @@ in
config = mkMerge [
(mkIf cfgZfs.enabled {
assertions = [
{
assertion = cfgZfs.modulePackage.version == cfgZfs.package.version;
message = "The kernel module and the userspace tooling versions are not matching, this is an unsupported usecase.";
}
{
assertion = cfgZED.enableMail -> cfgZfs.package.enableMail;
message = ''
Expand Down Expand Up @@ -571,18 +582,14 @@ in
# https://github.com/NixOS/nixpkgs/issues/106093
kernelParams = lib.optionals (!config.boot.zfs.allowHibernation) [ "nohibernate" ];

extraModulePackages = let
kernelPkg = if config.boot.zfs.enableUnstable then
config.boot.kernelPackages.zfsUnstable
else
config.boot.kernelPackages.zfs;
in [
(kernelPkg.override { inherit (cfgZfs) removeLinuxDRM; })
extraModulePackages = [
(cfgZfs.modulePackage.override { inherit (cfgZfs) removeLinuxDRM; })
];
};

boot.initrd = mkIf inInitrd {
kernelModules = [ "zfs" ] ++ optional (!cfgZfs.enableUnstable) "spl";
# spl has been removed in ≥ 2.2.0.
kernelModules = [ "zfs" ] ++ lib.optional (lib.versionOlder "2.2.0" version) "spl";
extraUtilsCommands =
mkIf (!config.boot.initrd.systemd.enable) ''
copy_bin_and_libs ${cfgZfs.package}/sbin/zfs
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/virtualisation/libvirtd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ in
] ++ cfg.extraOptions
);

path = [ cfg.qemu.package ] # libvirtd requires qemu-img to manage disk images
path = [ cfg.qemu.package pkgs.netcat ] # libvirtd requires qemu-img to manage disk images
++ optional vswitch.enable vswitch.package
++ optional cfg.qemu.swtpm.enable cfg.qemu.swtpm.package;

Expand Down
26 changes: 24 additions & 2 deletions nixos/tests/jitsi-meet.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,23 @@ import ./make-test-python.nix ({ pkgs, ... }: {
security.acme.acceptTerms = true;
security.acme.defaults.email = "[email protected]";
security.acme.defaults.server = "https://example.com"; # self-signed only

specialisation.caddy = {
inheritParentConfig = true;
configuration = {
services.jitsi-meet = {
caddy.enable = true;
nginx.enable = false;
};
services.caddy.virtualHosts.${config.services.jitsi-meet.hostName}.extraConfig = ''
tls internal
'';
};
};
};
};

testScript = ''
testScript = { nodes, ... }: ''
server.wait_for_unit("jitsi-videobridge2.service")
server.wait_for_unit("jicofo.service")
server.wait_for_unit("nginx.service")
Expand All @@ -41,6 +54,15 @@ import ./make-test-python.nix ({ pkgs, ... }: {
)
client.wait_for_unit("network.target")
assert "<title>Jitsi Meet</title>" in client.succeed("curl -sSfkL http://server/")
def client_curl():
assert "<title>Jitsi Meet</title>" in client.succeed("curl -sSfkL http://server/")
client_curl()
with subtest("Testing backup service"):
server.succeed("${nodes.server.system.build.toplevel}/specialisation/caddy/bin/switch-to-configuration test")
server.wait_for_unit("caddy.service")
client_curl()
'';
})
12 changes: 8 additions & 4 deletions nixos/tests/nextcloud/with-declarative-redis-and-secrets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ in {
};
secretFile = "/etc/nextcloud-secrets.json";

extraOptions.redis = {
dbindex = 0;
timeout = 1.5;
# password handled via secretfile below
extraOptions = {
allow_local_remote_servers = true;
redis = {
dbindex = 0;
timeout = 1.5;
# password handled via secretfile below
};
};
configureRedis = true;
};
Expand All @@ -62,6 +65,7 @@ in {

services.postgresql = {
enable = true;
package = pkgs.postgresql_14;
};
systemd.services.postgresql.postStart = pkgs.lib.mkAfter ''
password=$(cat ${passFile})
Expand Down
10 changes: 8 additions & 2 deletions nixos/tests/zfs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let
else pkgs.linuxPackages
, enableUnstable ? false
, enableSystemdStage1 ? false
, zfsPackage ? if enableUnstable then pkgs.zfs else pkgs.zfsUnstable
, extraTest ? ""
}:
makeTest {
Expand All @@ -21,7 +22,7 @@ let
maintainers = [ adisbladis elvishjerricco ];
};

nodes.machine = { pkgs, lib, ... }:
nodes.machine = { config, pkgs, lib, ... }:
let
usersharePath = "/var/lib/samba/usershares";
in {
Expand All @@ -35,8 +36,8 @@ let
boot.loader.efi.canTouchEfiVariables = true;
networking.hostId = "deadbeef";
boot.kernelPackages = kernelPackage;
boot.zfs.package = zfsPackage;
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.enableUnstable = enableUnstable;
boot.initrd.systemd.enable = enableSystemdStage1;

environment.systemPackages = [ pkgs.parted ];
Expand Down Expand Up @@ -193,6 +194,11 @@ let

in {

# maintainer: @raitobezarius
series_2_1 = makeZfsTest "2.1-series" {
zfsPackage = pkgs.zfs_2_1;
};

stable = makeZfsTest "stable" { };

unstable = makeZfsTest "unstable" {
Expand Down
Loading

0 comments on commit 6bbceb4

Please sign in to comment.