From 829bbc708bb51cf6544dcea3ce77e1a9d1793acd Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 5 Oct 2021 14:38:49 -0400 Subject: [PATCH 01/20] boot.initrd.extraFiles: allow users to add arbitrary files to the initrd --- nixos/modules/system/boot/stage-1.nix | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index bd7e955a6f42..be0d08936260 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -338,7 +338,14 @@ let { object = pkgs.kmod-debian-aliases; symlink = "/etc/modprobe.d/debian.conf"; } - ]; + ] ++ (lib.mapAttrsToList + (symlink: options: + { + inherit symlink; + object = options.source; + } + ) + config.boot.initrd.extraFiles); }; # Script to add secret files to the initrd at bootloader update time @@ -419,6 +426,22 @@ in ''; }; + boot.initrd.extraFiles = mkOption { + default = { }; + type = types.attrsOf + (types.submodule { + options = { + source = mkOption { + type = types.package; + description = "The object to make available inside the initrd."; + }; + }; + }); + description = '' + Extra files to link and copy in to the initrd. + ''; + }; + boot.initrd.prepend = mkOption { default = [ ]; type = types.listOf types.str; From a85dcd9ca310cd955ec480b773bdce2cc212dc9f Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 5 Oct 2021 15:03:00 -0400 Subject: [PATCH 02/20] iscsi root initiator: allow specifying arbitrary iscsi commands too --- .../modules/services/networking/iscsi/root-initiator.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/modules/services/networking/iscsi/root-initiator.nix b/nixos/modules/services/networking/iscsi/root-initiator.nix index 3274878c4fae..c12aca1bc24d 100644 --- a/nixos/modules/services/networking/iscsi/root-initiator.nix +++ b/nixos/modules/services/networking/iscsi/root-initiator.nix @@ -64,6 +64,12 @@ in default = false; }; + extraIscsiCommands = mkOption { + description = "Extra iscsi commands to run in the initrd."; + default = ""; + type = lines; + }; + extraConfig = mkOption { description = "Extra lines to append to /etc/iscsid.conf"; default = null; @@ -162,6 +168,9 @@ in '' else '' iscsiadm --mode node --targetname ${escapeShellArg cfg.target} --login ''} + + ${cfg.extraIscsiCommands} + pkill -9 iscsid ''; }; From c344317f186ce75be82d0a5509df64e68024e38c Mon Sep 17 00:00:00 2001 From: Michael Brantley Date: Thu, 7 Oct 2021 13:27:43 -0400 Subject: [PATCH 03/20] multipath-tools: deprecate systemd-udev-settle.service The systemd service manifest provided with the multipath-tools source makes reference to the systemd-udev-settle.service, and this in turn triggers deprecation warnings on startup. This patch removes these references to silence these warnings. --- pkgs/os-specific/linux/multipath-tools/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/linux/multipath-tools/default.nix b/pkgs/os-specific/linux/multipath-tools/default.nix index 241498057232..13e989243646 100644 --- a/pkgs/os-specific/linux/multipath-tools/default.nix +++ b/pkgs/os-specific/linux/multipath-tools/default.nix @@ -19,9 +19,11 @@ stdenv.mkDerivation rec { substituteInPlace libmultipath/Makefile \ --replace /usr/include/libdevmapper.h ${lib.getDev lvm2}/include/libdevmapper.h + # systemd-udev-settle.service is deprecated. substituteInPlace multipathd/multipathd.service \ --replace /sbin/modprobe ${lib.getBin kmod}/sbin/modprobe \ - --replace /sbin/multipathd "$out/bin/multipathd" + --replace /sbin/multipathd "$out/bin/multipathd" \ + --replace " systemd-udev-settle.service" "" sed -i -re ' s,^( *#define +DEFAULT_MULTIPATHDIR\>).*,\1 "'"$out/lib/multipath"'", From 121cfd1998e50f55d48502c0fc80cb7611f7e699 Mon Sep 17 00:00:00 2001 From: Michael Brantley Date: Thu, 11 Mar 2021 06:46:31 -0500 Subject: [PATCH 04/20] nixos/multipath: add multipath module The multipath-tools package had existed in Nixpkgs for some time but without a nixos module to configure/drive it. This module provides attributes to drive the majority of multipath configuration options and is being successfully used in stage-1 and stage-2 boot to mount /nix from a multipath-serviced iSCSI volume. Credit goes to @grahamc for early contributions to the module and authoring the NixOS module test. --- .../from_md/release-notes/rl-2111.section.xml | 7 + .../manual/release-notes/rl-2111.section.md | 2 + nixos/modules/module-list.nix | 1 + .../modules/services/networking/multipath.nix | 572 ++++++++++++++++++ nixos/modules/system/boot/stage-1.nix | 24 + nixos/tests/iscsi-multipath-root.nix | 267 ++++++++ 6 files changed, 873 insertions(+) create mode 100644 nixos/modules/services/networking/multipath.nix create mode 100644 nixos/tests/iscsi-multipath-root.nix diff --git a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml index 25f984f9378f..b1e129b3d24e 100644 --- a/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml +++ b/nixos/doc/manual/from_md/release-notes/rl-2111.section.xml @@ -329,6 +329,13 @@ controller support. + + + multipath, + the device mapper multipath (DM-MP) daemon. Available as + services.multipath. + +
diff --git a/nixos/doc/manual/release-notes/rl-2111.section.md b/nixos/doc/manual/release-notes/rl-2111.section.md index 40a671e3efa9..11d5dfa9a3b6 100644 --- a/nixos/doc/manual/release-notes/rl-2111.section.md +++ b/nixos/doc/manual/release-notes/rl-2111.section.md @@ -101,6 +101,8 @@ In addition to numerous new and upgraded packages, this release has the followin - [joycond](https://github.com/DanielOgorchock/joycond), a service that uses `hid-nintendo` to provide nintendo joycond pairing and better nintendo switch pro controller support. +- [multipath](https://github.com/opensvc/multipath-tools), the device mapper multipath (DM-MP) daemon. Available as [services.multipath](#opt-services.multipath.enable). + ## Backward Incompatibilities {#sec-release-21.11-incompatibilities} - The `security.wrappers` option now requires to always specify an owner, group and whether the setuid/setgid bit should be set. diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index f701f38c9dd1..2ad562825687 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -779,6 +779,7 @@ ./services/networking/mstpd.nix ./services/networking/mtprotoproxy.nix ./services/networking/mullvad-vpn.nix + ./services/networking/multipath.nix ./services/networking/murmur.nix ./services/networking/mxisd.nix ./services/networking/namecoind.nix diff --git a/nixos/modules/services/networking/multipath.nix b/nixos/modules/services/networking/multipath.nix new file mode 100644 index 000000000000..1cc2ad1fc849 --- /dev/null +++ b/nixos/modules/services/networking/multipath.nix @@ -0,0 +1,572 @@ +{ config, lib, pkgs, ... }: with lib; + +# See http://christophe.varoqui.free.fr/usage.html and +# https://github.com/opensvc/multipath-tools/blob/master/multipath/multipath.conf.5 + +let + cfg = config.services.multipath; + + indentLines = n: str: concatStringsSep "\n" ( + map (line: "${fixedWidthString n " " " "}${line}") ( + filter ( x: x != "" ) ( splitString "\n" str ) + ) + ); + + addCheckDesc = desc: elemType: check: types.addCheck elemType check + // { description = "${elemType.description} (with check: ${desc})"; }; + hexChars = stringToCharacters "0123456789abcdef"; + isHexString = s: all (c: elem c hexChars) (stringToCharacters (toLower s)); + hexStr = addCheckDesc "hexadecimal string" types.str isHexString; + +in { + + options.services.multipath = with types; { + + enable = mkEnableOption "the device mapper multipath (DM-MP) daemon"; + + package = mkOption { + type = package; + description = "multipath-tools package to use"; + default = pkgs.multipath-tools; + defaultText = "pkgs.multipath-tools"; + }; + + devices = mkOption { + default = [ ]; + example = literalExpression '' + [ + { + vendor = "\"COMPELNT\""; + product = "\"Compellent Vol\""; + path_checker = "tur"; + no_path_retry = "queue"; + max_sectors_kb = 256; + }, ... + ] + ''; + description = '' + This option allows you to define arrays for use in multipath + groups. + ''; + type = listOf (submodule { + options = { + + vendor = mkOption { + type = str; + example = "COMPELNT"; + description = "Regular expression to match the vendor name"; + }; + + product = mkOption { + type = str; + example = "Compellent Vol"; + description = "Regular expression to match the product name"; + }; + + revision = mkOption { + type = nullOr str; + default = null; + description = "Regular expression to match the product revision"; + }; + + product_blacklist = mkOption { + type = nullOr str; + default = null; + description = "Products with the given vendor matching this string are blacklisted"; + }; + + alias_prefix = mkOption { + type = nullOr str; + default = null; + description = "The user_friendly_names prefix to use for this device type, instead of the default mpath"; + }; + + vpd_vendor = mkOption { + type = nullOr str; + default = null; + description = "The vendor specific vpd page information, using the vpd page abbreviation"; + }; + + hardware_handler = mkOption { + type = nullOr (enum [ "emc" "rdac" "hp_sw" "alua" "ana" ]); + default = null; + description = "The hardware handler to use for this device type"; + }; + + # Optional arguments + path_grouping_policy = mkOption { + type = nullOr (enum [ "failover" "multibus" "group_by_serial" "group_by_prio" "group_by_node_name" ]); + default = null; # real default: "failover" + description = "The default path grouping policy to apply to unspecified multipaths"; + }; + + uid_attribute = mkOption { + type = nullOr str; + default = null; + description = "The udev attribute providing a unique path identifier (WWID)"; + }; + + getuid_callout = mkOption { + type = nullOr str; + default = null; + description = '' + (Superseded by uid_attribute) The default program and args to callout + to obtain a unique path identifier. Should be specified with an absolute path. + ''; + }; + + path_selector = mkOption { + type = nullOr (enum [ + ''"round-robin 0"'' + ''"queue-length 0"'' + ''"service-time 0"'' + ''"historical-service-time 0"'' + ]); + default = null; # real default: "service-time 0" + description = "The default path selector algorithm to use; they are offered by the kernel multipath target"; + }; + + path_checker = mkOption { + type = enum [ "readsector0" "tur" "emc_clariion" "hp_sw" "rdac" "directio" "cciss_tur" "none" ]; + default = "tur"; + description = "The default method used to determine the paths state"; + }; + + prio = mkOption { + type = nullOr (enum [ + "none" "const" "sysfs" "emc" "alua" "ontap" "rdac" "hp_sw" "hds" + "random" "weightedpath" "path_latency" "ana" "datacore" "iet" + ]); + default = null; # real default: "const" + description = "The name of the path priority routine"; + }; + + prio_args = mkOption { + type = nullOr str; + default = null; + description = "Arguments to pass to to the prio function"; + }; + + features = mkOption { + type = nullOr str; + default = null; + description = "Specify any device-mapper features to be used"; + }; + + failback = mkOption { + type = nullOr str; + default = null; # real default: "manual" + description = "Tell multipathd how to manage path group failback. Quote integers as strings"; + }; + + rr_weight = mkOption { + type = nullOr (enum [ "priorities" "uniform" ]); + default = null; # real default: "uniform" + description = '' + If set to priorities the multipath configurator will assign path weights + as "path prio * rr_min_io". + ''; + }; + + no_path_retry = mkOption { + type = nullOr str; + default = null; # real default: "fail" + description = "Specify what to do when all paths are down. Quote integers as strings"; + }; + + rr_min_io = mkOption { + type = nullOr int; + default = null; # real default: 1000 + description = '' + Number of I/O requests to route to a path before switching to the next in the + same path group. This is only for Block I/O (BIO) based multipath and + only apply to round-robin path_selector. + ''; + }; + + rr_min_io_rq = mkOption { + type = nullOr int; + default = null; # real default: 1 + description = '' + Number of I/O requests to route to a path before switching to the next in the + same path group. This is only for Request based multipath and + only apply to round-robin path_selector. + ''; + }; + + fast_io_fail_tmo = mkOption { + type = nullOr str; + default = null; # real default: 5 + description = '' + Specify the number of seconds the SCSI layer will wait after a problem has been + detected on a FC remote port before failing I/O to devices on that remote port. + This should be smaller than dev_loss_tmo. Setting this to "off" will disable + the timeout. Quote integers as strings. + ''; + }; + + dev_loss_tmo = mkOption { + type = nullOr str; + default = null; # real default: 600 + description = '' + Specify the number of seconds the SCSI layer will wait after a problem has + been detected on a FC remote port before removing it from the system. This + can be set to "infinity" which sets it to the max value of 2147483647 + seconds, or 68 years. It will be automatically adjusted to the overall + retry interval no_path_retry * polling_interval + if a number of retries is given with no_path_retry and the + overall retry interval is longer than the specified dev_loss_tmo value. + The Linux kernel will cap this value to 600 if fast_io_fail_tmo + is not set. + ''; + }; + + flush_on_last_del = mkOption { + type = nullOr (enum [ "yes" "no" ]); + default = null; # real default: "no" + description = '' + If set to "yes" multipathd will disable queueing when the last path to a + device has been deleted. + ''; + }; + + user_friendly_names = mkOption { + type = nullOr (enum [ "yes" "no" ]); + default = null; # real default: "no" + description = '' + If set to "yes", using the bindings file /etc/multipath/bindings + to assign a persistent and unique alias to the multipath, in the + form of mpath. If set to "no" use the WWID as the alias. In either + case this be will be overridden by any specific aliases in the + multipaths section. + ''; + }; + + retain_attached_hw_handler = mkOption { + type = nullOr (enum [ "yes" "no" ]); + default = null; # real default: "yes" + description = '' + (Obsolete for kernels >= 4.3) If set to "yes" and the SCSI layer has + already attached a hardware_handler to the device, multipath will not + force the device to use the hardware_handler specified by mutipath.conf. + If the SCSI layer has not attached a hardware handler, multipath will + continue to use its configured hardware handler. + + Important Note: Linux kernel 4.3 or newer always behaves as if + "retain_attached_hw_handler yes" was set. + ''; + }; + + detect_prio = mkOption { + type = nullOr (enum [ "yes" "no" ]); + default = null; # real default: "yes" + description = '' + If set to "yes", multipath will try to detect if the device supports + SCSI-3 ALUA. If so, the device will automatically use the sysfs + prioritizer if the required sysf attributes access_state and + preferred_path are supported, or the alua prioritizer if not. If set + to "no", the prioritizer will be selected as usual. + ''; + }; + + detect_checker = mkOption { + type = nullOr (enum [ "yes" "no" ]); + default = null; # real default: "yes" + description = '' + If set to "yes", multipath will try to detect if the device supports + SCSI-3 ALUA. If so, the device will automatically use the tur checker. + If set to "no", the checker will be selected as usual. + ''; + }; + + deferred_remove = mkOption { + type = nullOr (enum [ "yes" "no" ]); + default = null; # real default: "no" + description = '' + If set to "yes", multipathd will do a deferred remove instead of a + regular remove when the last path device has been deleted. This means + that if the multipath device is still in use, it will be freed when + the last user closes it. If path is added to the multipath device + before the last user closes it, the deferred remove will be canceled. + ''; + }; + + san_path_err_threshold = mkOption { + type = nullOr str; + default = null; + description = '' + If set to a value greater than 0, multipathd will watch paths and check + how many times a path has been failed due to errors.If the number of + failures on a particular path is greater then the san_path_err_threshold, + then the path will not reinstate till san_path_err_recovery_time. These + path failures should occur within a san_path_err_forget_rate checks, if + not we will consider the path is good enough to reinstantate. + ''; + }; + + san_path_err_forget_rate = mkOption { + type = nullOr str; + default = null; + description = '' + If set to a value greater than 0, multipathd will check whether the path + failures has exceeded the san_path_err_threshold within this many checks + i.e san_path_err_forget_rate. If so we will not reinstante the path till + san_path_err_recovery_time. + ''; + }; + + san_path_err_recovery_time = mkOption { + type = nullOr str; + default = null; + description = '' + If set to a value greater than 0, multipathd will make sure that when + path failures has exceeded the san_path_err_threshold within + san_path_err_forget_rate then the path will be placed in failed state + for san_path_err_recovery_time duration. Once san_path_err_recovery_time + has timeout we will reinstante the failed path. san_path_err_recovery_time + value should be in secs. + ''; + }; + + marginal_path_err_sample_time = mkOption { + type = nullOr int; + default = null; + description = "One of the four parameters of supporting path check based on accounting IO error such as intermittent error"; + }; + + marginal_path_err_rate_threshold = mkOption { + type = nullOr int; + default = null; + description = "The error rate threshold as a permillage (1/1000)"; + }; + + marginal_path_err_recheck_gap_time = mkOption { + type = nullOr str; + default = null; + description = "One of the four parameters of supporting path check based on accounting IO error such as intermittent error"; + }; + + marginal_path_double_failed_time = mkOption { + type = nullOr str; + default = null; + description = "One of the four parameters of supporting path check based on accounting IO error such as intermittent error"; + }; + + delay_watch_checks = mkOption { + type = nullOr str; + default = null; + description = "This option is deprecated, and mapped to san_path_err_forget_rate"; + }; + + delay_wait_checks = mkOption { + type = nullOr str; + default = null; + description = "This option is deprecated, and mapped to san_path_err_recovery_time"; + }; + + skip_kpartx = mkOption { + type = nullOr (enum [ "yes" "no" ]); + default = null; # real default: "no" + description = "If set to yes, kpartx will not automatically create partitions on the device"; + }; + + max_sectors_kb = mkOption { + type = nullOr int; + default = null; + description = "Sets the max_sectors_kb device parameter on all path devices and the multipath device to the specified value"; + }; + + ghost_delay = mkOption { + type = nullOr int; + default = null; + description = "Sets the number of seconds that multipath will wait after creating a device with only ghost paths before marking it ready for use in systemd"; + }; + + all_tg_pt = mkOption { + type = nullOr str; + default = null; + description = "Set the 'all targets ports' flag when registering keys with mpathpersist"; + }; + + }; + }); + }; + + defaults = mkOption { + type = nullOr str; + default = null; + description = '' + This section defines default values for attributes which are used + whenever no values are given in the appropriate device or multipath + sections. + ''; + }; + + blacklist = mkOption { + type = nullOr str; + default = null; + description = '' + This section defines which devices should be excluded from the + multipath topology discovery. + ''; + }; + + blacklist_exceptions = mkOption { + type = nullOr str; + default = null; + description = '' + This section defines which devices should be included in the + multipath topology discovery, despite being listed in the + blacklist section. + ''; + }; + + overrides = mkOption { + type = nullOr str; + default = null; + description = '' + This section defines values for attributes that should override the + device-specific settings for all devices. + ''; + }; + + extraConfig = mkOption { + type = nullOr str; + default = null; + description = "Lines to append to default multipath.conf"; + }; + + extraConfigFile = mkOption { + type = nullOr str; + default = null; + description = "Append an additional file's contents to /etc/multipath.conf"; + }; + + pathGroups = mkOption { + example = literalExpression '' + [ + { + wwid = "360080e500043b35c0123456789abcdef"; + alias = 10001234; + array = "bigarray.example.com"; + fsType = "zfs"; # optional + options = "ro"; # optional + }, ... + ] + ''; + description = '' + This option allows you to define multipath groups as described + in http://christophe.varoqui.free.fr/usage.html. + ''; + type = listOf (submodule { + options = { + + alias = mkOption { + type = int; + example = 1001234; + description = "The name of the multipath device"; + }; + + wwid = mkOption { + type = hexStr; + example = "360080e500043b35c0123456789abcdef"; + description = "The identifier for the multipath device"; + }; + + array = mkOption { + type = str; + default = null; + example = "bigarray.example.com"; + description = "The DNS name of the storage array"; + }; + + fsType = mkOption { + type = nullOr str; + default = null; + example = "zfs"; + description = "Type of the filesystem"; + }; + + options = mkOption { + type = nullOr str; + default = null; + example = "ro"; + description = "Options used to mount the file system"; + }; + + }; + }); + }; + + }; + + config = mkIf cfg.enable { + environment.etc."multipath.conf".text = + let + inherit (cfg) defaults blacklist blacklist_exceptions overrides; + + mkDeviceBlock = cfg: let + nonNullCfg = lib.filterAttrs (k: v: v != null) cfg; + attrs = lib.mapAttrsToList (name: value: " ${name} ${toString value}") nonNullCfg; + in '' + device { + ${lib.concatStringsSep "\n" attrs} + } + ''; + devices = lib.concatMapStringsSep "\n" mkDeviceBlock cfg.devices; + + mkMultipathBlock = m: '' + multipath { + wwid ${m.wwid} + alias ${toString m.alias} + } + ''; + multipaths = lib.concatMapStringsSep "\n" mkMultipathBlock cfg.pathGroups; + + in '' + devices { + ${indentLines 2 devices} + } + + ${optionalString (!isNull defaults) '' + defaults { + ${indentLines 2 defaults} + multipath_dir ${cfg.package}/lib/multipath + } + ''} + ${optionalString (!isNull blacklist) '' + blacklist { + ${indentLines 2 blacklist} + } + ''} + ${optionalString (!isNull blacklist_exceptions) '' + blacklist_exceptions { + ${indentLines 2 blacklist_exceptions} + } + ''} + ${optionalString (!isNull overrides) '' + overrides { + ${indentLines 2 overrides} + } + ''} + multipaths { + ${indentLines 2 multipaths} + } + ''; + + systemd.packages = [ cfg.package ]; + + environment.systemPackages = [ cfg.package ]; + boot.kernelModules = [ "dm-multipath" "dm-service-time" ]; + + # We do not have systemd in stage-1 boot so must invoke `multipathd` + # with the `-1` argument which disables systemd calls. Invoke `multipath` + # to display the multipath mappings in the output of `journalctl -b`. + boot.initrd.kernelModules = [ "dm-multipath" "dm-service-time" ]; + boot.initrd.postDeviceCommands = '' + modprobe -a dm-multipath dm-service-time + multipathd -s + (set -x && sleep 1 && multipath -ll) + ''; + }; +} diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index be0d08936260..adbed9d8d58e 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -137,6 +137,14 @@ let copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/resize2fs ''} + # Copy multipath. + ${optionalString config.services.multipath.enable '' + copy_bin_and_libs ${config.services.multipath.package}/bin/multipath + copy_bin_and_libs ${config.services.multipath.package}/bin/multipathd + # Copy lib/multipath manually. + cp -rpv ${config.services.multipath.package}/lib/multipath $out/lib + ''} + # Copy secrets if needed. # # TODO: move out to a separate script; see #85000. @@ -199,6 +207,10 @@ let $out/bin/dmsetup --version 2>&1 | tee -a log | grep -q "version:" LVM_SYSTEM_DIR=$out $out/bin/lvm version 2>&1 | tee -a log | grep -q "LVM" $out/bin/mdadm --version + ${optionalString config.services.multipath.enable '' + ($out/bin/multipath || true) 2>&1 | grep -q 'need to be root' + ($out/bin/multipathd || true) 2>&1 | grep -q 'need to be root' + ''} ${config.boot.initrd.extraUtilsCommandsTest} fi @@ -338,6 +350,18 @@ let { object = pkgs.kmod-debian-aliases; symlink = "/etc/modprobe.d/debian.conf"; } + ] ++ lib.optionals config.services.multipath.enable [ + { object = pkgs.runCommand "multipath.conf" { + src = config.environment.etc."multipath.conf".text; + preferLocalBuild = true; + } '' + target=$out + printf "$src" > $out + substituteInPlace $out \ + --replace ${config.services.multipath.package}/lib ${extraUtils}/lib + ''; + symlink = "/etc/multipath.conf"; + } ] ++ (lib.mapAttrsToList (symlink: options: { diff --git a/nixos/tests/iscsi-multipath-root.nix b/nixos/tests/iscsi-multipath-root.nix new file mode 100644 index 000000000000..a26fea503b62 --- /dev/null +++ b/nixos/tests/iscsi-multipath-root.nix @@ -0,0 +1,267 @@ +import ./make-test-python.nix ( + { pkgs, lib, ... }: + let + initiatorName = "iqn.2020-08.org.linux-iscsi.initiatorhost:example"; + targetName = "iqn.2003-01.org.linux-iscsi.target.x8664:sn.acf8fd9c23af"; + in + { + name = "iscsi"; + meta = { + maintainers = pkgs.lib.teams.deshaw.members; + }; + + nodes = { + target = { config, pkgs, lib, ... }: { + virtualisation.vlans = [ 1 2 ]; + services.target = { + enable = true; + config = { + fabric_modules = [ ]; + storage_objects = [ + { + dev = "/dev/vdb"; + name = "test"; + plugin = "block"; + write_back = true; + wwn = "92b17c3f-6b40-4168-b082-ceeb7b495522"; + } + ]; + targets = [ + { + fabric = "iscsi"; + tpgs = [ + { + enable = true; + attributes = { + authentication = 0; + generate_node_acls = 1; + }; + luns = [ + { + alias = "94dfe06967"; + alua_tg_pt_gp_name = "default_tg_pt_gp"; + index = 0; + storage_object = "/backstores/block/test"; + } + ]; + node_acls = [ + { + mapped_luns = [ + { + alias = "d42f5bdf8a"; + index = 0; + tpg_lun = 0; + write_protect = false; + } + ]; + node_wwn = initiatorName; + } + ]; + portals = [ + { + ip_address = "0.0.0.0"; + iser = false; + offload = false; + port = 3260; + } + ]; + tag = 1; + } + ]; + wwn = targetName; + } + ]; + }; + }; + + networking.firewall.allowedTCPPorts = [ 3260 ]; + networking.firewall.allowedUDPPorts = [ 3260 ]; + + virtualisation.memorySize = 2048; + virtualisation.emptyDiskImages = [ 2048 ]; + }; + + initiatorAuto = { nodes, config, pkgs, ... }: { + virtualisation.vlans = [ 1 2 ]; + + services.multipath = { + enable = true; + defaults = '' + find_multipaths yes + user_friendly_names yes + ''; + pathGroups = [ + { + alias = 123456; + wwid = "3600140592b17c3f6b404168b082ceeb7"; + } + ]; + }; + + services.openiscsi = { + enable = true; + enableAutoLoginOut = true; + discoverPortal = "target"; + name = initiatorName; + }; + + environment.systemPackages = with pkgs; [ + xfsprogs + ]; + + environment.etc."initiator-root-disk-closure".source = nodes.initiatorRootDisk.config.system.build.toplevel; + + nix.binaryCaches = lib.mkForce [ ]; + nix.extraOptions = '' + hashed-mirrors = + connect-timeout = 1 + ''; + }; + + initiatorRootDisk = { config, pkgs, modulesPath, lib, ... }: { + boot.initrd.network.enable = true; + boot.loader.grub.enable = false; + + boot.kernelParams = lib.mkOverride 5 ( + [ + "boot.shell_on_fail" + "console=tty1" + "ip=192.168.1.1:::255.255.255.0::ens9:none" + "ip=192.168.2.1:::255.255.255.0::ens10:none" + ] + ); + + # defaults to true, puts some code in the initrd that tries to mount an overlayfs on /nix/store + virtualisation.writableStore = false; + virtualisation.vlans = [ 1 2 ]; + + services.multipath = { + enable = true; + defaults = '' + find_multipaths yes + user_friendly_names yes + ''; + pathGroups = [ + { + alias = 123456; + wwid = "3600140592b17c3f6b404168b082ceeb7"; + } + ]; + }; + + fileSystems = lib.mkOverride 5 { + "/" = { + fsType = "xfs"; + device = "/dev/mapper/123456"; + options = [ "_netdev" ]; + }; + }; + + boot.initrd.extraFiles."etc/multipath/wwids".source = pkgs.writeText "wwids" "/3600140592b17c3f6b404168b082ceeb7/"; + + boot.iscsi-initiator = { + discoverPortal = "target"; + name = initiatorName; + target = targetName; + extraIscsiCommands = '' + iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login + ''; + }; + }; + + }; + + testScript = { nodes, ... }: '' + target.start() + target.wait_for_unit("iscsi-target.service") + + initiatorAuto.start() + + initiatorAuto.wait_for_unit("iscsid.service") + initiatorAuto.wait_for_unit("iscsi.service") + initiatorAuto.get_unit_info("iscsi") + + # Expecting this to fail since we should already know about 192.168.1.3 + initiatorAuto.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.1.3 --login") + # Expecting this to succeed since we don't yet know about 192.168.2.3 + initiatorAuto.succeed("iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login") + + # /dev/sda is provided by iscsi on target + initiatorAuto.succeed("set -x; while ! test -e /dev/sda; do sleep 1; done") + + initiatorAuto.succeed("mkfs.xfs /dev/sda") + initiatorAuto.succeed("mkdir /mnt") + + # Start by verifying /dev/sda and /dev/sdb are both the same disk + initiatorAuto.succeed("mount /dev/sda /mnt") + initiatorAuto.succeed("touch /mnt/hi") + initiatorAuto.succeed("umount /mnt") + + initiatorAuto.succeed("mount /dev/sdb /mnt") + initiatorAuto.succeed("test -e /mnt/hi") + initiatorAuto.succeed("umount /mnt") + + initiatorAuto.succeed("systemctl restart multipathd") + initiatorAuto.succeed("multipath -ll | systemd-cat") + + # Install our RootDisk machine to 123456, the alias to the device that multipath is now managing + initiatorAuto.succeed("mount /dev/mapper/123456 /mnt") + initiatorAuto.succeed("mkdir -p /mnt/etc/{multipath,iscsi}") + initiatorAuto.succeed("cp -r /etc/multipath/wwids /mnt/etc/multipath/wwids") + initiatorAuto.succeed("cp -r /etc/iscsi/{nodes,send_targets} /mnt/etc/iscsi") + initiatorAuto.succeed( + "nixos-install --no-bootloader --no-root-passwd --system /etc/initiator-root-disk-closure" + ) + initiatorAuto.succeed("umount /mnt") + initiatorAuto.shutdown() + + initiatorRootDisk.start() + initiatorRootDisk.wait_for_unit("multi-user.target") + initiatorRootDisk.wait_for_unit("iscsid") + + # Log in over both nodes + initiatorRootDisk.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.1.3 --login") + initiatorRootDisk.fail("iscsiadm -m discovery -o update -t sendtargets -p 192.168.2.3 --login") + initiatorRootDisk.succeed("systemctl restart multipathd") + initiatorRootDisk.succeed("multipath -ll | systemd-cat") + + # Verify we can write and sync the root disk + initiatorRootDisk.succeed("mkdir /scratch") + initiatorRootDisk.succeed("touch /scratch/both-up") + initiatorRootDisk.succeed("sync /scratch") + + # Verify we can write to the root with ens9 (sda, 192.168.1.3) down + initiatorRootDisk.succeed("ip link set ens9 down") + initiatorRootDisk.succeed("touch /scratch/ens9-down") + initiatorRootDisk.succeed("sync /scratch") + initiatorRootDisk.succeed("ip link set ens9 up") + + # todo: better way to wait until multipath notices the link is back + initiatorRootDisk.succeed("sleep 5") + initiatorRootDisk.succeed("touch /scratch/both-down") + initiatorRootDisk.succeed("sync /scratch") + + # Verify we can write to the root with ens10 (sdb, 192.168.2.3) down + initiatorRootDisk.succeed("ip link set ens10 down") + initiatorRootDisk.succeed("touch /scratch/ens10-down") + initiatorRootDisk.succeed("sync /scratch") + initiatorRootDisk.succeed("ip link set ens10 up") + initiatorRootDisk.succeed("touch /scratch/ens10-down") + initiatorRootDisk.succeed("sync /scratch") + + initiatorRootDisk.succeed("ip link set ens9 up") + initiatorRootDisk.succeed("ip link set ens10 up") + initiatorRootDisk.shutdown() + + # Verify we can boot with the target's eth1 down, forcing + # it to multipath via the second link + target.succeed("ip link set eth1 down") + initiatorRootDisk.start() + initiatorRootDisk.wait_for_unit("multi-user.target") + initiatorRootDisk.wait_for_unit("iscsid") + initiatorRootDisk.succeed("test -e /scratch/both-up") + ''; + } +) + + From 7ba02a7b1e6ac86bb0826d65c7f44902f171f4bb Mon Sep 17 00:00:00 2001 From: Robbert Gurdeep Singh Date: Sat, 25 Sep 2021 22:16:35 +0200 Subject: [PATCH 05/20] nixos/nextcloud: add services.nextcloud.datadir setting This option can be used to set an alternative storage location for files and app metadata. --- nixos/modules/services/web-apps/nextcloud.nix | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index 4d7f16b1e1a9..5f6faeb170a6 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -5,6 +5,7 @@ with lib; let cfg = config.services.nextcloud; fpm = config.services.phpfpm.pools.nextcloud; + datadir = if cfg.datadir == null then "${cfg.home}" else "${cfg.datadir}"; phpPackage = cfg.phpPackage.buildEnv { extensions = { enabled, all }: @@ -40,7 +41,7 @@ let if [[ "$USER" != nextcloud ]]; then sudo='exec /run/wrappers/bin/sudo -u nextcloud --preserve-env=NEXTCLOUD_CONFIG_DIR --preserve-env=OC_PASS' fi - export NEXTCLOUD_CONFIG_DIR="${cfg.home}/config" + export NEXTCLOUD_CONFIG_DIR="${datadir}/config" $sudo \ ${phpPackage}/bin/php \ occ "$@" @@ -85,6 +86,15 @@ in { default = "/var/lib/nextcloud"; description = "Storage path of nextcloud."; }; + datadir = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + Data storage path of nextcloud. Will be by default. + This folder will be populated with a config.php and data folder which contains the state of the instance (excl the database)."; + ''; + example = "/mnt/nextcloud-file"; + }; logLevel = mkOption { type = types.ints.between 0 4; default = 2; @@ -584,7 +594,7 @@ in { [ 'path' => '${cfg.home}/apps', 'url' => '/apps', 'writable' => false ], [ 'path' => '${cfg.home}/store-apps', 'url' => '/store-apps', 'writable' => true ], ], - 'datadirectory' => '${cfg.home}/data', + 'datadirectory' => '${datadir}/data', 'skeletondirectory' => '${cfg.skeletonDirectory}', ${optionalString cfg.caching.apcu "'memcache.local' => '\\OC\\Memcache\\APCu',"} 'log_type' => 'syslog', @@ -628,7 +638,7 @@ in { "--database-pass" = "\$${dbpass.arg}"; "--admin-user" = ''"${c.adminuser}"''; "--admin-pass" = "\$${adminpass.arg}"; - "--data-dir" = ''"${cfg.home}/data"''; + "--data-dir" = ''"${datadir}/data"''; }); in '' ${mkExport dbpass} @@ -672,7 +682,7 @@ in { # create nextcloud directories. # if the directories exist already with wrong permissions, we fix that - for dir in ${cfg.home}/config ${cfg.home}/data ${cfg.home}/store-apps; do + for dir in ${datadir}/config ${datadir}/data ${cfg.home}/store-apps; do if [ ! -e $dir ]; then install -o nextcloud -g nextcloud -d $dir elif [ $(stat -c "%G" $dir) != "nextcloud" ]; then @@ -680,23 +690,29 @@ in { fi done - ln -sf ${overrideConfig} ${cfg.home}/config/override.config.php + ln -sf ${overrideConfig} ${datadir}/config/override.config.php # Do not install if already installed - if [[ ! -e ${cfg.home}/config/config.php ]]; then + if [[ ! -e ${datadir}/config/config.php ]]; then ${occInstallCmd} fi ${occ}/bin/nextcloud-occ upgrade ${occ}/bin/nextcloud-occ config:system:delete trusted_domains + + ${optionalString (cfg.extraAppsEnable && cfg.extraApps != { }) '' + # Try to enable apps (don't fail when one of them cannot be enabled , eg. due to incompatible version) + ${occ}/bin/nextcloud-occ app:enable ${builtins.concatStringsSep " " ( lib.mapAttrsToList (name: target: "${name}") cfg.extraApps)} || true + ''} + ${occSetTrustedDomainsCmd} ''; serviceConfig.Type = "oneshot"; serviceConfig.User = "nextcloud"; }; nextcloud-cron = { - environment.NEXTCLOUD_CONFIG_DIR = "${cfg.home}/config"; + environment.NEXTCLOUD_CONFIG_DIR = "${datadir}/config"; serviceConfig.Type = "oneshot"; serviceConfig.User = "nextcloud"; serviceConfig.ExecStart = "${phpPackage}/bin/php -f ${cfg.package}/cron.php"; @@ -715,7 +731,7 @@ in { group = "nextcloud"; phpPackage = phpPackage; phpEnv = { - NEXTCLOUD_CONFIG_DIR = "${cfg.home}/config"; + NEXTCLOUD_CONFIG_DIR = "${datadir}/config"; PATH = "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin"; }; settings = mapAttrs (name: mkDefault) { From 18b18929d7537d8acdab7bbd960221b3bc160c6d Mon Sep 17 00:00:00 2001 From: Robbert Gurdeep Singh Date: Sat, 25 Sep 2021 22:19:14 +0200 Subject: [PATCH 06/20] nixos/nextcloud: add settings to manage nextcloud apps Note the appstoreEnable which will prevent nextcloud form updating nix-managed apps. This is needed because nextcloud will store an other version of the app in /var/lib/nextcloud/store-apps and it will no longer be manageable. --- nixos/modules/services/web-apps/nextcloud.nix | 60 ++++++++++++++++++- nixos/modules/services/web-apps/nextcloud.xml | 6 ++ .../fetchnextcloudapp/default.nix | 38 ++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 pkgs/build-support/fetchnextcloudapp/default.nix diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index 5f6faeb170a6..452927e96abe 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -95,6 +95,50 @@ in { ''; example = "/mnt/nextcloud-file"; }; + extraApps = mkOption { + type = types.attrsOf types.package; + default = { }; + description = '' + Extra apps to install. Should be an attrSet of appid to packages generated by fetchNextcloudApp. + The appid must be identical to the "id" value in the apps appinfo/info.xml. + Using this will disable the appstore to prevent Nextcloud from updating these apps (see ). + ''; + example = literalExample '' + { + maps = pkgs.fetchNextcloudApp { + name = "maps"; + sha256 = "007y80idqg6b6zk6kjxg4vgw0z8fsxs9lajnv49vv1zjy6jx2i1i+useTheLatestVersion"; + url = "https://github.com/nextcloud/maps/releases/download/v0.1.9/maps-0.1.9.tar.gz"; + version = "0.1.9"; + }; + phonetrack = pkgs.fetchNextcloudApp { + name = "phonetrack"; + sha256 = "0qf366vbahyl27p9mshfma1as4nvql6w75zy2zk5xwwbp343vsbc+breakSha"; + url = "https://gitlab.com/eneiluj/phonetrack-oc/-/wikis/uploads/931aaaf8dca24bf31a7e169a83c17235/phonetrack-0.6.9.tar.gz"; + version = "0.6.9"; + }; + } + ''; + }; + extraAppsEnable = mkOption { + type = types.bool; + default = true; + description = '' + Automatically enable the apps in every time nextcloud starts. + If set to false, apps need to be enabled in the Nextcloud user interface or with nextcloud-occ app:enable. + ''; + }; + appstoreEnable = mkOption { + type = types.nullOr types.bool; + default = null; + example = true; + description = '' + Allow the installation of apps and app updates from the store. + Enabled by default unless there are packages in . + Set to true to force enable the store even if is used. + Set to false to disable the installation of apps from the global appstore. App management is always enabled regardless of this setting. + ''; + }; logLevel = mkOption { type = types.ints.between 0 4; default = 2; @@ -591,9 +635,15 @@ in { ''} $CONFIG = [ 'apps_paths' => [ + ${optionalString (cfg.extraApps != { }) "[ 'path' => '${cfg.home}/nix-apps', 'url' => '/nix-apps', 'writable' => false ],"} [ 'path' => '${cfg.home}/apps', 'url' => '/apps', 'writable' => false ], [ 'path' => '${cfg.home}/store-apps', 'url' => '/store-apps', 'writable' => true ], ], + ${if (cfg.appstoreEnable != null) + then '''appstoreenabled' => ${lib.boolToString cfg.appstoreEnable},'' + else (if (cfg.extraApps != { }) + then '''appstoreenabled' => false,'' + else "")} 'datadirectory' => '${datadir}/data', 'skeletondirectory' => '${cfg.skeletonDirectory}', ${optionalString cfg.caching.apcu "'memcache.local' => '\\OC\\Memcache\\APCu',"} @@ -679,10 +729,14 @@ in { fi ln -sf ${cfg.package}/apps ${cfg.home}/ + rm -rf ${cfg.home}/nix-apps + + #Install extra apps + ln -sfT ${pkgs.linkFarm "nix-apps" (lib.mapAttrsToList (name: target: {name=name; path=target;}) cfg.extraApps)} ${cfg.home}/nix-apps # create nextcloud directories. # if the directories exist already with wrong permissions, we fix that - for dir in ${datadir}/config ${datadir}/data ${cfg.home}/store-apps; do + for dir in ${datadir}/config ${datadir}/data ${cfg.home}/store-apps ${cfg.home}/nix-apps; do if [ ! -e $dir ]; then install -o nextcloud -g nextcloud -d $dir elif [ $(stat -c "%G" $dir) != "nextcloud" ]; then @@ -781,6 +835,10 @@ in { priority = 201; extraConfig = "root ${cfg.home};"; }; + "~ ^/nix-apps" = { + priority = 201; + extraConfig = "root ${cfg.home};"; + }; "^~ /.well-known" = { priority = 210; extraConfig = '' diff --git a/nixos/modules/services/web-apps/nextcloud.xml b/nixos/modules/services/web-apps/nextcloud.xml index ed84487d233a..f51d1304c1b6 100644 --- a/nixos/modules/services/web-apps/nextcloud.xml +++ b/nixos/modules/services/web-apps/nextcloud.xml @@ -237,6 +237,12 @@ Some apps may require extra PHP extensions to be installed. This can be configured with the setting. + + + Alternatively, extra apps can also be declared in with the setting. + When using this setting, apps can no longer be managed statefully because this can lead to Nextcloud updating apps + that are managed by Nix. If you want automatic updates it is recommended that you use web interface to install apps. +
diff --git a/pkgs/build-support/fetchnextcloudapp/default.nix b/pkgs/build-support/fetchnextcloudapp/default.nix new file mode 100644 index 000000000000..a7cb5209a7ae --- /dev/null +++ b/pkgs/build-support/fetchnextcloudapp/default.nix @@ -0,0 +1,38 @@ +{ stdenv, gnutar, findutils, fetchurl, ... }: +{ name +, url +, version +, sha256 +, patches ? [ ] +}: +stdenv.mkDerivation { + name = "nc-app-${name}"; + inherit version patches; + + src = fetchurl { + url = url; + sha256 = sha256; + }; + + nativeBuildInputs = [ + gnutar + findutils + ]; + + unpackPhase = '' + tar -xzpf $src + ''; + + installPhase = '' + approot="$(dirname $(dirname $(find -path '*/appinfo/info.xml' | head -n 1)))" + + if [ -d "$approot" ]; + then + mv "$approot/" $out + chmod -R a-w $out + else + echo "Could not find appinfo/info.xml" + exit 1; + fi + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 18c5484a9b18..14fed07d3aa3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -520,6 +520,8 @@ with pkgs; tests = callPackages ../build-support/fetchfirefoxaddon/tests.nix { }; }; + fetchNextcloudApp = callPackage ../build-support/fetchnextcloudapp {}; + # `fetchurl' downloads a file from the network. fetchurl = if stdenv.buildPlatform != stdenv.hostPlatform then buildPackages.fetchurl # No need to do special overrides twice, From 1852212872df38a81c2674d08983f2297836fb50 Mon Sep 17 00:00:00 2001 From: Robbert Gurdeep Singh Date: Thu, 30 Sep 2021 22:38:45 +0200 Subject: [PATCH 07/20] nixos/nextcloud: fail systemd-service if apps don't activate --- nixos/modules/services/web-apps/nextcloud.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index 452927e96abe..e35f6c3e5ead 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -757,7 +757,7 @@ in { ${optionalString (cfg.extraAppsEnable && cfg.extraApps != { }) '' # Try to enable apps (don't fail when one of them cannot be enabled , eg. due to incompatible version) - ${occ}/bin/nextcloud-occ app:enable ${builtins.concatStringsSep " " ( lib.mapAttrsToList (name: target: "${name}") cfg.extraApps)} || true + ${occ}/bin/nextcloud-occ app:enable ${builtins.concatStringsSep " " ( lib.mapAttrsToList (name: target: "${name}") cfg.extraApps)} ''} ${occSetTrustedDomainsCmd} From 7856e40da626766c67f631dcc434814e22d93c78 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 9 Oct 2021 20:52:52 +0200 Subject: [PATCH 08/20] nixos/nextcloud: fix wording in manual --- nixos/modules/services/web-apps/nextcloud.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/web-apps/nextcloud.xml b/nixos/modules/services/web-apps/nextcloud.xml index f51d1304c1b6..9d9cb8dfb3f2 100644 --- a/nixos/modules/services/web-apps/nextcloud.xml +++ b/nixos/modules/services/web-apps/nextcloud.xml @@ -239,7 +239,7 @@ - Alternatively, extra apps can also be declared in with the setting. + Alternatively, extra apps can also be declared with the setting. When using this setting, apps can no longer be managed statefully because this can lead to Nextcloud updating apps that are managed by Nix. If you want automatic updates it is recommended that you use web interface to install apps. From 1ee008fcb5d2dd4b9254a3168de97f5c45da9dac Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 9 Oct 2021 22:36:35 +0200 Subject: [PATCH 09/20] nixos/nextcloud: fixup #119638 A few minor changes to get #119638 - nextcloud: add option to set datadir and extensions - ready: * `cfg.datadir` now gets `cfg.home` as default to make the type non-nullable. * Enhanced the `basic` test to check the behavior with a custom datadir that's not `/var/lib/nextcloud`. * Fix hashes for apps in option example. * Simplify if/else for `appstoreenable` in override config. * Simplify a few `mapAttrsToList`-expressions in `nextcloud-setup.service`. --- nixos/modules/services/web-apps/nextcloud.nix | 37 ++++++++++++------- nixos/tests/nextcloud/basic.nix | 6 +++ .../fetchnextcloudapp/default.nix | 3 +- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index e35f6c3e5ead..a5874a2bfb8b 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -5,7 +5,8 @@ with lib; let cfg = config.services.nextcloud; fpm = config.services.phpfpm.pools.nextcloud; - datadir = if cfg.datadir == null then "${cfg.home}" else "${cfg.datadir}"; + + inherit (cfg) datadir; phpPackage = cfg.phpPackage.buildEnv { extensions = { enabled, all }: @@ -87,8 +88,8 @@ in { description = "Storage path of nextcloud."; }; datadir = mkOption { - type = types.nullOr types.str; - default = null; + type = types.str; + defaultText = "config.services.nextcloud.home"; description = '' Data storage path of nextcloud. Will be by default. This folder will be populated with a config.php and data folder which contains the state of the instance (excl the database)."; @@ -107,13 +108,13 @@ in { { maps = pkgs.fetchNextcloudApp { name = "maps"; - sha256 = "007y80idqg6b6zk6kjxg4vgw0z8fsxs9lajnv49vv1zjy6jx2i1i+useTheLatestVersion"; + sha256 = "007y80idqg6b6zk6kjxg4vgw0z8fsxs9lajnv49vv1zjy6jx2i1i"; url = "https://github.com/nextcloud/maps/releases/download/v0.1.9/maps-0.1.9.tar.gz"; version = "0.1.9"; }; phonetrack = pkgs.fetchNextcloudApp { name = "phonetrack"; - sha256 = "0qf366vbahyl27p9mshfma1as4nvql6w75zy2zk5xwwbp343vsbc+breakSha"; + sha256 = "0qf366vbahyl27p9mshfma1as4nvql6w75zy2zk5xwwbp343vsbc"; url = "https://gitlab.com/eneiluj/phonetrack-oc/-/wikis/uploads/931aaaf8dca24bf31a7e169a83c17235/phonetrack-0.6.9.tar.gz"; version = "0.6.9"; }; @@ -578,6 +579,8 @@ in { else nextcloud22 ); + services.nextcloud.datadir = mkOptionDefault config.services.nextcloud.home; + services.nextcloud.phpPackage = if versionOlder cfg.package.version "21" then pkgs.php74 else pkgs.php80; @@ -617,6 +620,14 @@ in { ] ''; + showAppStoreSetting = cfg.appstoreEnable != null || cfg.extraApps != {}; + renderedAppStoreSetting = + let + x = cfg.appstoreEnable; + in + if x == null then "false" + else boolToString x; + overrideConfig = pkgs.writeText "nextcloud-config.php" '' '${cfg.home}/apps', 'url' => '/apps', 'writable' => false ], [ 'path' => '${cfg.home}/store-apps', 'url' => '/store-apps', 'writable' => true ], ], - ${if (cfg.appstoreEnable != null) - then '''appstoreenabled' => ${lib.boolToString cfg.appstoreEnable},'' - else (if (cfg.extraApps != { }) - then '''appstoreenabled' => false,'' - else "")} + ${optionalString (showAppStoreSetting) "'appstoreenabled' => ${renderedAppStoreSetting},"} 'datadirectory' => '${datadir}/data', 'skeletondirectory' => '${cfg.skeletonDirectory}', ${optionalString cfg.caching.apcu "'memcache.local' => '\\OC\\Memcache\\APCu',"} @@ -729,10 +736,12 @@ in { fi ln -sf ${cfg.package}/apps ${cfg.home}/ - rm -rf ${cfg.home}/nix-apps - #Install extra apps - ln -sfT ${pkgs.linkFarm "nix-apps" (lib.mapAttrsToList (name: target: {name=name; path=target;}) cfg.extraApps)} ${cfg.home}/nix-apps + # Install extra apps + ln -sfT \ + ${pkgs.linkFarm "nix-apps" + (mapAttrsToList (name: path: { inherit name path; }) cfg.extraApps)} \ + ${cfg.home}/nix-apps # create nextcloud directories. # if the directories exist already with wrong permissions, we fix that @@ -757,7 +766,7 @@ in { ${optionalString (cfg.extraAppsEnable && cfg.extraApps != { }) '' # Try to enable apps (don't fail when one of them cannot be enabled , eg. due to incompatible version) - ${occ}/bin/nextcloud-occ app:enable ${builtins.concatStringsSep " " ( lib.mapAttrsToList (name: target: "${name}") cfg.extraApps)} + ${occ}/bin/nextcloud-occ app:enable ${concatStringsSep " " (attrNames cfg.extraApps)} ''} ${occSetTrustedDomainsCmd} diff --git a/nixos/tests/nextcloud/basic.nix b/nixos/tests/nextcloud/basic.nix index 1a7b25d5a49e..eb37470a4c7b 100644 --- a/nixos/tests/nextcloud/basic.nix +++ b/nixos/tests/nextcloud/basic.nix @@ -33,8 +33,13 @@ in { in { networking.firewall.allowedTCPPorts = [ 80 ]; + systemd.tmpfiles.rules = [ + "d /var/lib/nextcloud-data 0750 nextcloud nginx - -" + ]; + services.nextcloud = { enable = true; + datadir = "/var/lib/nextcloud-data"; hostName = "nextcloud"; config = { # Don't inherit adminuser since "root" is supposed to be the default @@ -98,6 +103,7 @@ in { "${withRcloneEnv} ${copySharedFile}" ) client.wait_for_unit("multi-user.target") + nextcloud.succeed("test -f /var/lib/nextcloud-data/data/root/files/test-shared-file") client.succeed( "${withRcloneEnv} ${diffSharedFile}" ) diff --git a/pkgs/build-support/fetchnextcloudapp/default.nix b/pkgs/build-support/fetchnextcloudapp/default.nix index a7cb5209a7ae..7fe5b35e2596 100644 --- a/pkgs/build-support/fetchnextcloudapp/default.nix +++ b/pkgs/build-support/fetchnextcloudapp/default.nix @@ -10,8 +10,7 @@ stdenv.mkDerivation { inherit version patches; src = fetchurl { - url = url; - sha256 = sha256; + inherit url sha256; }; nativeBuildInputs = [ From 3498c5ff3c7e476298fa6730c90abec4871f0e9a Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 9 Oct 2021 22:45:39 +0200 Subject: [PATCH 10/20] nixos/nextcloud: build manual without warnings --- nixos/modules/services/web-apps/nextcloud.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/web-apps/nextcloud.nix b/nixos/modules/services/web-apps/nextcloud.nix index a5874a2bfb8b..62ae763b69bc 100644 --- a/nixos/modules/services/web-apps/nextcloud.nix +++ b/nixos/modules/services/web-apps/nextcloud.nix @@ -104,7 +104,7 @@ in { The appid must be identical to the "id" value in the apps appinfo/info.xml. Using this will disable the appstore to prevent Nextcloud from updating these apps (see ). ''; - example = literalExample '' + example = literalExpression '' { maps = pkgs.fetchNextcloudApp { name = "maps"; From 365c58885e2e63936548c5f050650c3f3f0dda44 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 11 Oct 2021 22:19:58 +0200 Subject: [PATCH 11/20] python3Packages.aiodiscover: 1.4.4 -> 1.4.5 --- pkgs/development/python-modules/aiodiscover/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/aiodiscover/default.nix b/pkgs/development/python-modules/aiodiscover/default.nix index 1ad7c0bfd9d9..268654ea9baa 100644 --- a/pkgs/development/python-modules/aiodiscover/default.nix +++ b/pkgs/development/python-modules/aiodiscover/default.nix @@ -11,14 +11,14 @@ buildPythonPackage rec { pname = "aiodiscover"; - version = "1.4.4"; + version = "1.4.5"; disabled = pythonOlder "3.7"; src = fetchFromGitHub { owner = "bdraco"; repo = pname; rev = "v${version}"; - sha256 = "sha256-DobTx6oUr25J8bolo84V4yTT0b0jBsOIzPn93uAmDl0="; + sha256 = "sha256-QfeAEFB5WikuriBTcfFIgnJw5H4vEcGIVX47fyDb1Dk="; }; propagatedBuildInputs = [ From e24366f46d60f613286a825e30ef2b38d6b5a919 Mon Sep 17 00:00:00 2001 From: "R. RyanTM" Date: Wed, 13 Oct 2021 04:42:51 +0000 Subject: [PATCH 12/20] plexRaw: 1.24.3.5033-757abe6b4 -> 1.24.4.5081-e362dc1ee --- pkgs/servers/plex/raw.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/plex/raw.nix b/pkgs/servers/plex/raw.nix index 802e53820796..47198243cbce 100644 --- a/pkgs/servers/plex/raw.nix +++ b/pkgs/servers/plex/raw.nix @@ -12,16 +12,16 @@ # server, and the FHS userenv and corresponding NixOS module should # automatically pick up the changes. stdenv.mkDerivation rec { - version = "1.24.3.5033-757abe6b4"; + version = "1.24.4.5081-e362dc1ee"; pname = "plexmediaserver"; # Fetch the source src = if stdenv.hostPlatform.system == "aarch64-linux" then fetchurl { url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_arm64.deb"; - sha256 = "063llf34h6dbzrysm98xwwmv8fwyk8vsc3sj7dniy9j29wwygwdz"; + sha256 = "0q3s1qcr65rx2jbf9k0i38w5xvnzw1wcy13gvm0150ad2hqw358b"; } else fetchurl { url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb"; - sha256 = "0cnv1i00xv7ls5yb9xlim4haal7bvn41p3zskbab85vwhffr9irx"; + sha256 = "17igy0lq7mjmrw5xq92b57np422x8hj6m8qzjri493yc6fw1cl1m"; }; outputs = [ "out" "basedb" ]; From b290f43a462dc332f7a58da9b867bb8f4a4581b1 Mon Sep 17 00:00:00 2001 From: Lancelot SIX Date: Wed, 13 Oct 2021 13:26:50 +0100 Subject: [PATCH 13/20] skypeforlinux: 8.75.0.140 -> 8.77.0.97 --- .../networking/instant-messengers/skypeforlinux/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix b/pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix index 7db77fbc31e3..7550e72277f5 100644 --- a/pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix +++ b/pkgs/applications/networking/instant-messengers/skypeforlinux/default.nix @@ -7,7 +7,7 @@ let # Please keep the version x.y.0.z and do not update to x.y.76.z because the # source of the latter disappears much faster. - version = "8.75.0.140"; + version = "8.77.0.97"; rpath = lib.makeLibraryPath [ alsa-lib @@ -69,7 +69,7 @@ let "https://mirror.cs.uchicago.edu/skype/pool/main/s/skypeforlinux/skypeforlinux_${version}_amd64.deb" "https://web.archive.org/web/https://repo.skype.com/deb/pool/main/s/skypeforlinux/skypeforlinux_${version}_amd64.deb" ]; - sha256 = "sha256-z3xsl53CSJthSd/BMbMD7RdYQ4z9oI/Rb9jUvd82H4E="; + sha256 = "sha256-0u1fpKJrsEgbvTwdkqJZ/SwCRDmJwEi9IXHbMmY8MJI="; } else throw "Skype for linux is not supported on ${stdenv.hostPlatform.system}"; From a7cd81947a8c5c5c51f14b81073ed2a8a46d788f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Romildo?= Date: Wed, 13 Oct 2021 09:09:25 -0300 Subject: [PATCH 14/20] vivaldi: 4.1.2369.21-1 -> 4.3.2439.44-1 --- pkgs/applications/networking/browsers/vivaldi/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/networking/browsers/vivaldi/default.nix b/pkgs/applications/networking/browsers/vivaldi/default.nix index 6477f4fbe06e..4e44e5841805 100644 --- a/pkgs/applications/networking/browsers/vivaldi/default.nix +++ b/pkgs/applications/networking/browsers/vivaldi/default.nix @@ -18,11 +18,11 @@ let vivaldiName = if isSnapshot then "vivaldi-snapshot" else "vivaldi"; in stdenv.mkDerivation rec { pname = "vivaldi"; - version = "4.1.2369.21-1"; + version = "4.3.2439.44-1"; src = fetchurl { url = "https://downloads.vivaldi.com/${branch}/vivaldi-${branch}_${version}_amd64.deb"; - sha256 = "03062mik6paqp219jz420jsg762jjrfxmj1daq129z2zgzq0qr8l"; + sha256 = "1bsx8axs438f4p019mdq66pmpimf575r31rv6cibpgv85366xhh9"; }; unpackPhase = '' @@ -49,7 +49,7 @@ in stdenv.mkDerivation rec { buildPhase = '' runHook preBuild echo "Patching Vivaldi binaries" - for f in crashpad_handler vivaldi-bin vivaldi-sandbox ; do + for f in chrome_crashpad_handler vivaldi-bin vivaldi-sandbox ; do patchelf \ --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --set-rpath "${libPath}" \ From e2b72ec679a8485ce557c430df7d7b863f124a49 Mon Sep 17 00:00:00 2001 From: Ryan Horiguchi Date: Wed, 13 Oct 2021 14:59:57 +0200 Subject: [PATCH 15/20] gitkraken: 7.8.1 -> 8.0.1 --- pkgs/applications/version-management/gitkraken/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/version-management/gitkraken/default.nix b/pkgs/applications/version-management/gitkraken/default.nix index 1fbb099e0139..748e34c33aea 100644 --- a/pkgs/applications/version-management/gitkraken/default.nix +++ b/pkgs/applications/version-management/gitkraken/default.nix @@ -13,11 +13,11 @@ let in stdenv.mkDerivation rec { pname = "gitkraken"; - version = "7.7.2"; + version = "8.0.1"; src = fetchzip { url = "https://release.axocdn.com/linux/GitKraken-v${version}.tar.gz"; - sha256 = "sha256-jL0XLw0V0ED+lDBn3sGaJmm96zQwXue333UuYGHjB64="; + sha256 = "1n88m41424qwsfp2hy58piqpv2dk6i74hcj184aq6njllvnsznnq"; }; dontBuild = true; From d624bd148b5e0c673d5773b8a42e5f58e125c846 Mon Sep 17 00:00:00 2001 From: John Rinehart Date: Wed, 13 Oct 2021 14:46:38 +0300 Subject: [PATCH 16/20] postman: 8.10.0 -> 9.0.4 --- maintainers/maintainer-list.nix | 6 ++++++ pkgs/development/web/postman/default.nix | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index c81d86ca1f67..8174b36839d4 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -5467,6 +5467,12 @@ githubId = 8735102; name = "John Ramsden"; }; + johnrichardrinehart = { + email = "johnrichardrinehart@gmail.com"; + github = "johnrichardrinehart"; + githubId = 6321578; + name = "John Rinehart"; + }; johntitor = { email = "huyuumi.dev@gmail.com"; github = "JohnTitor"; diff --git a/pkgs/development/web/postman/default.nix b/pkgs/development/web/postman/default.nix index abcf6bfc16ed..fed502e8388b 100644 --- a/pkgs/development/web/postman/default.nix +++ b/pkgs/development/web/postman/default.nix @@ -7,11 +7,11 @@ stdenv.mkDerivation rec { pname = "postman"; - version = "8.10.0"; + version = "9.0.4"; src = fetchurl { url = "https://dl.pstmn.io/download/version/${version}/linux64"; - sha256 = "05f3eaa229483a7e1f698e6e2ea2031d37687de540d4fad05ce677ac216db24d"; + sha256 = "9OX1rSNWq2YJQBCt64iE4osZvfVajgEC2F28w7HSs3U="; name = "${pname}.tar.gz"; }; @@ -74,7 +74,7 @@ stdenv.mkDerivation rec { rm $out/share/postman/Postman mkdir -p $out/bin - ln -s $out/share/postman/_Postman $out/bin/postman + ln -s $out/share/postman/postman $out/bin/postman mkdir -p $out/share/applications ln -s ${desktopItem}/share/applications/* $out/share/applications/ @@ -88,8 +88,8 @@ stdenv.mkDerivation rec { postFixup = '' pushd $out/share/postman - patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" _Postman - for file in $(find . -type f \( -name \*.node -o -name _Postman -o -name \*.so\* \) ); do + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" postman + for file in $(find . -type f \( -name \*.node -o -name postman -o -name \*.so\* \) ); do ORIGIN=$(patchelf --print-rpath $file); \ patchelf --set-rpath "${lib.makeLibraryPath buildInputs}:$ORIGIN" $file done @@ -101,6 +101,6 @@ stdenv.mkDerivation rec { description = "API Development Environment"; license = licenses.postman; platforms = [ "x86_64-linux" ]; - maintainers = with maintainers; [ xurei evanjs ]; + maintainers = with maintainers; [ johnrichardrinehart evanjs ]; }; } From f1220d72a3a06b0fbac1999b5c8a097d1d10cc0f Mon Sep 17 00:00:00 2001 From: Jonas Chevalier Date: Wed, 13 Oct 2021 15:30:26 +0000 Subject: [PATCH 17/20] terraform-providers.kubernetes: 2.4.1 -> 2.5.0 (#141519) --- .../networking/cluster/terraform-providers/providers.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/networking/cluster/terraform-providers/providers.json b/pkgs/applications/networking/cluster/terraform-providers/providers.json index e27cae50a88f..15ce26b6db54 100644 --- a/pkgs/applications/networking/cluster/terraform-providers/providers.json +++ b/pkgs/applications/networking/cluster/terraform-providers/providers.json @@ -563,10 +563,10 @@ "owner": "hashicorp", "provider-source-address": "registry.terraform.io/hashicorp/kubernetes", "repo": "terraform-provider-kubernetes", - "rev": "v2.4.1", - "sha256": "0mk0f12yy58gjkki7xpf9bjfw9h9zdgby2b4bddqp5csq11payhd", + "rev": "v2.5.0", + "sha256": "1hp3bwhlfiwf1a4l6xfldwdxmyjs4nq3n8g343grjya7ibbhh4sg", "vendorSha256": null, - "version": "2.4.1" + "version": "2.5.0" }, "launchdarkly": { "owner": "terraform-providers", From 4d526f3c3e0adfa3cd85a5f183ddcb62af851738 Mon Sep 17 00:00:00 2001 From: AndersonTorres Date: Wed, 13 Oct 2021 12:35:05 -0300 Subject: [PATCH 18/20] emacsPackages.rec-mode: init at 1.8 --- .../emacs/elisp-packages/manual-packages.nix | 2 + .../emacs/elisp-packages/rec-mode/default.nix | 18 ++++++++ pkgs/tools/misc/recutils/default.nix | 46 +++++++++++-------- 3 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 pkgs/applications/editors/emacs/elisp-packages/rec-mode/default.nix diff --git a/pkgs/applications/editors/emacs/elisp-packages/manual-packages.nix b/pkgs/applications/editors/emacs/elisp-packages/manual-packages.nix index 3f5dd795ccb9..2ee92e251bf0 100644 --- a/pkgs/applications/editors/emacs/elisp-packages/manual-packages.nix +++ b/pkgs/applications/editors/emacs/elisp-packages/manual-packages.nix @@ -198,6 +198,8 @@ railgun = callPackage ./railgun { }; + rec-mode = callPackage ./rec-mode { }; + structured-haskell-mode = self.shm; sv-kalender = callPackage ./sv-kalender { }; diff --git a/pkgs/applications/editors/emacs/elisp-packages/rec-mode/default.nix b/pkgs/applications/editors/emacs/elisp-packages/rec-mode/default.nix new file mode 100644 index 000000000000..8cb560fde534 --- /dev/null +++ b/pkgs/applications/editors/emacs/elisp-packages/rec-mode/default.nix @@ -0,0 +1,18 @@ +{ lib +, trivialBuild +, recutils +}: + +trivialBuild { + pname = "rec-mode"; + + inherit (recutils) version src; + + postUnpack = '' + sourceRoot="$sourceRoot/etc" + ''; + + meta = recutils.meta // { + description = "A major mode for editing rec files"; + }; +} diff --git a/pkgs/tools/misc/recutils/default.nix b/pkgs/tools/misc/recutils/default.nix index d6a5b517a84e..1501f8edda1f 100644 --- a/pkgs/tools/misc/recutils/default.nix +++ b/pkgs/tools/misc/recutils/default.nix @@ -1,36 +1,42 @@ -{ fetchurl, lib, stdenv, emacs, curl, check, bc }: +{ lib +, stdenv +, fetchurl +, bc +, check +, curl +}: stdenv.mkDerivation rec { pname = "recutils"; version = "1.8"; src = fetchurl { - url = "mirror://gnu/recutils/recutils-${version}.tar.gz"; - sha256 = "14xiln4immfsw8isnvwvq0h23f6z0wilpgsc4qzabnrzb5lsx3nz"; + url = "mirror://gnu/recutils/${pname}-${version}.tar.gz"; + hash = "sha256-346uaVk/26U+Jky/SyMH37ghIMCbb6sj4trVGomlsZM="; }; hardeningDisable = [ "format" ]; - buildInputs = [ curl emacs ]; + buildInputs = [ + curl + ]; - checkInputs = [ check bc ]; + checkInputs = [ + check + bc + ]; doCheck = true; - meta = { - description = "Tools and libraries to access human-editable, text-based databases"; - - longDescription = - '' GNU Recutils is a set of tools and libraries to access - human-editable, text-based databases called recfiles. The data is - stored as a sequence of records, each record containing an arbitrary - number of named fields. - ''; - + meta = with lib; { homepage = "https://www.gnu.org/software/recutils/"; - - license = lib.licenses.gpl3Plus; - - platforms = lib.platforms.all; - maintainers = [ ]; + description = "Tools and libraries to access human-editable, text-based databases"; + longDescription = '' + GNU Recutils is a set of tools and libraries to access human-editable, + text-based databases called recfiles. The data is stored as a sequence of + records, each record containing an arbitrary number of named fields. + ''; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ AndersonTorres ]; + platforms = platforms.all; }; } From 7ff58e4a86d10d699fad1459c640ca87ede4a387 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 8 Jun 2021 11:59:56 +0000 Subject: [PATCH 19/20] busybox: use more featureful modprobe by default The default version (modprobe-small) is missing important features, and can also be _extremely_ slow (on purpose[1]). The non-small modprobe implementation doesn't have all features enabled by default, so by changing implementation we'd be risking regression. To mitigate that, I've ensured every feature checked for in modprobe.c is enabled. So unless there's functionality that's _only_ in modprobe-small, we should be fine. [1]: https://git.busybox.net/busybox/tree/modutils/Config.src?h=1_34_1#n8 --- pkgs/os-specific/linux/busybox/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/os-specific/linux/busybox/default.nix b/pkgs/os-specific/linux/busybox/default.nix index 40d44690afe7..b8a017adcf42 100644 --- a/pkgs/os-specific/linux/busybox/default.nix +++ b/pkgs/os-specific/linux/busybox/default.nix @@ -81,6 +81,14 @@ stdenv.mkDerivation rec { CONFIG_LFS y + # More features for modprobe. + ${lib.optionalString (!enableMinimal) '' + CONFIG_FEATURE_MODPROBE_BLACKLIST y + CONFIG_FEATURE_MODUTILS_ALIAS y + CONFIG_FEATURE_MODUTILS_SYMBOLS y + CONFIG_MODPROBE_SMALL n + ''} + ${lib.optionalString enableStatic '' CONFIG_STATIC y ''} From 851b719ac6bea528908fae1ec3ec9e0efae82e84 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 13 Oct 2021 16:38:22 +0000 Subject: [PATCH 20/20] treewide: use stdenv.hostPlatform.extensions.sharedLibrary where appropriate --- pkgs/applications/science/logic/z3/4.4.0.nix | 2 +- pkgs/development/libraries/nss/3.53.nix | 4 +--- pkgs/development/libraries/nss/default.nix | 4 +--- pkgs/development/libraries/unixODBCDrivers/default.nix | 2 +- pkgs/development/python-modules/augeas/default.nix | 2 +- pkgs/development/python-modules/ifcopenshell/default.nix | 2 +- pkgs/development/tools/database/prisma-engines/default.nix | 6 ++---- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/pkgs/applications/science/logic/z3/4.4.0.nix b/pkgs/applications/science/logic/z3/4.4.0.nix index 9b7dabeb7200..2fbaa0a28caf 100644 --- a/pkgs/applications/science/logic/z3/4.4.0.nix +++ b/pkgs/applications/science/logic/z3/4.4.0.nix @@ -19,7 +19,7 @@ stdenv.mkDerivation rec { # z3's install phase is stupid because it tries to calculate the # python package store location itself, meaning it'll attempt to # write files into the nix store, and fail. - soext = if stdenv.system == "x86_64-darwin" then ".dylib" else ".so"; + soext = stdenv.hostPlatform.extensions.sharedLibrary; installPhase = '' mkdir -p $out/bin $out/lib/${python.libPrefix}/site-packages $out/include cp ../src/api/z3*.h $out/include diff --git a/pkgs/development/libraries/nss/3.53.nix b/pkgs/development/libraries/nss/3.53.nix index 4d22e9a1a7cf..2f18b466f981 100644 --- a/pkgs/development/libraries/nss/3.53.nix +++ b/pkgs/development/libraries/nss/3.53.nix @@ -151,13 +151,11 @@ stdenv.mkDerivation rec { in (lib.optionalString enableFIPS ('' for libname in freebl3 nssdbm3 softokn3 - do '' + + do libfile="$out/lib/lib$libname${stdenv.hostPlatform.extensions.sharedLibrary}"'' + (if stdenv.isDarwin then '' - libfile="$out/lib/lib$libname.dylib" DYLD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \ '' else '' - libfile="$out/lib/lib$libname.so" LD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \ '') + '' ${nss}/bin/shlibsign -v -i "$libfile" diff --git a/pkgs/development/libraries/nss/default.nix b/pkgs/development/libraries/nss/default.nix index f8bd34a164de..c1b90a8da873 100644 --- a/pkgs/development/libraries/nss/default.nix +++ b/pkgs/development/libraries/nss/default.nix @@ -166,13 +166,11 @@ stdenv.mkDerivation rec { in (lib.optionalString enableFIPS ('' for libname in freebl3 nssdbm3 softokn3 - do '' + + do libfile="$out/lib/lib$libname${stdenv.hostPlatform.extensions.sharedLibrary}"'' + (if stdenv.isDarwin then '' - libfile="$out/lib/lib$libname.dylib" DYLD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \ '' else '' - libfile="$out/lib/lib$libname.so" LD_LIBRARY_PATH=$out/lib:${nspr.out}/lib \ '') + '' ${nss}/bin/shlibsign -v -i "$libfile" diff --git a/pkgs/development/libraries/unixODBCDrivers/default.nix b/pkgs/development/libraries/unixODBCDrivers/default.nix index 14f41b015e9c..b766b933a656 100644 --- a/pkgs/development/libraries/unixODBCDrivers/default.nix +++ b/pkgs/development/libraries/unixODBCDrivers/default.nix @@ -57,7 +57,7 @@ passthru = { fancyName = "MariaDB"; - driver = if stdenv.isDarwin then "lib/libmaodbc.dylib" else "lib/libmaodbc.so"; + driver = "lib/libmaodbc${stdenv.hostPlatform.extensions.sharedLibrary}"; }; meta = with lib; { diff --git a/pkgs/development/python-modules/augeas/default.nix b/pkgs/development/python-modules/augeas/default.nix index cf1d4544e4ad..6b70f3675268 100644 --- a/pkgs/development/python-modules/augeas/default.nix +++ b/pkgs/development/python-modules/augeas/default.nix @@ -12,7 +12,7 @@ buildPythonPackage rec { # TODO: not very nice! postPatch = - let libname = if stdenv.isDarwin then "libaugeas.dylib" else "libaugeas.so"; + let libname = "libaugeas${stdenv.hostPlatform.extensions.sharedLibrary}"; in '' substituteInPlace augeas/ffi.py \ diff --git a/pkgs/development/python-modules/ifcopenshell/default.nix b/pkgs/development/python-modules/ifcopenshell/default.nix index 2eedaaece690..33816631584e 100644 --- a/pkgs/development/python-modules/ifcopenshell/default.nix +++ b/pkgs/development/python-modules/ifcopenshell/default.nix @@ -48,7 +48,7 @@ buildPythonPackage rec { "-DOPENCOLLADA_LIBRARY_DIR=${opencollada}/lib/opencollada" "-DSWIG_EXECUTABLE=${swig}/bin/swig" "-DLIBXML2_INCLUDE_DIR=${libxml2.dev}/include/libxml2" - "-DLIBXML2_LIBRARIES=${libxml2.out}/lib/${if stdenv.isDarwin then "libxml2.dylib" else "libxml2.so"}" + "-DLIBXML2_LIBRARIES=${libxml2.out}/lib/libxml2${stdenv.hostPlatform.extensions.sharedLibrary}" ]; meta = with lib; { diff --git a/pkgs/development/tools/database/prisma-engines/default.nix b/pkgs/development/tools/database/prisma-engines/default.nix index 5417f2b83a5d..977f05aea5c6 100644 --- a/pkgs/development/tools/database/prisma-engines/default.nix +++ b/pkgs/development/tools/database/prisma-engines/default.nix @@ -8,9 +8,7 @@ , stdenv }: -let - node-api-lib = (if stdenv.isDarwin then "libquery_engine.dylib" else "libquery_engine.so"); -in rustPlatform.buildRustPackage rec { +rustPlatform.buildRustPackage rec { pname = "prisma-engines"; version = "3.2.0"; @@ -47,7 +45,7 @@ in rustPlatform.buildRustPackage rec { cargoBuildFlags = "-p query-engine -p query-engine-node-api -p migration-engine-cli -p introspection-core -p prisma-fmt"; postInstall = '' - mv $out/lib/${node-api-lib} $out/lib/libquery_engine.node + mv $out/lib/libquery_engine${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libquery_engine.node ''; # Tests are long to compile