Merge pull request #109345 from cole-h/zfs-closure

Shrink the ZFS closure by making mail support optional
This commit is contained in:
Linus Heckemann 2021-02-10 23:04:24 +01:00 committed by GitHub
commit e4cf0e7a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 32 deletions

View File

@ -326,7 +326,12 @@ in
}; };
}; };
services.zfs.zed.settings = mkOption { services.zfs.zed = {
enableMail = mkEnableOption "ZED's ability to send emails" // {
default = cfgZfs.package.enableMail;
};
settings = mkOption {
type = with types; attrsOf (oneOf [ str int bool (listOf str) ]); type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
example = literalExample '' example = literalExample ''
{ {
@ -352,12 +357,21 @@ in
''; '';
}; };
}; };
};
###### implementation ###### implementation
config = mkMerge [ config = mkMerge [
(mkIf cfgZfs.enabled { (mkIf cfgZfs.enabled {
assertions = [ assertions = [
{
assertion = cfgZED.enableMail -> cfgZfs.package.enableMail;
message = ''
To allow ZED to send emails, ZFS needs to be configured to enable
this. To do so, one must override the `zfs` package and set
`enableMail` to true.
'';
}
{ {
assertion = config.networking.hostId != null; assertion = config.networking.hostId != null;
message = "ZFS requires networking.hostId to be set"; message = "ZFS requires networking.hostId to be set";
@ -437,7 +451,7 @@ in
}; };
services.zfs.zed.settings = { services.zfs.zed.settings = {
ZED_EMAIL_PROG = mkDefault "${pkgs.mailutils}/bin/mail"; ZED_EMAIL_PROG = mkIf cfgZED.enableMail (mkDefault "${pkgs.mailutils}/bin/mail");
PATH = lib.makeBinPath [ PATH = lib.makeBinPath [
cfgZfs.package cfgZfs.package
pkgs.coreutils pkgs.coreutils

View File

@ -8,8 +8,8 @@
, libtirpc , libtirpc
, nfs-utils , nfs-utils
, gawk, gnugrep, gnused, systemd , gawk, gnugrep, gnused, systemd
, smartmontools, sysstat, sudo , smartmontools, enableMail ? false
, pkg-config , sysstat, sudo, pkg-config
# Kernel dependencies # Kernel dependencies
, kernel ? null , kernel ? null
@ -18,6 +18,8 @@
with lib; with lib;
let let
smartmon = smartmontools.override { inherit enableMail; };
buildKernel = any (n: n == configFile) [ "kernel" "all" ]; buildKernel = any (n: n == configFile) [ "kernel" "all" ];
buildUser = any (n: n == configFile) [ "user" "all" ]; buildUser = any (n: n == configFile) [ "user" "all" ];
@ -148,7 +150,7 @@ let
''; '';
postFixup = let postFixup = let
path = "PATH=${makeBinPath [ coreutils gawk gnused gnugrep util-linux smartmontools sysstat ]}:$PATH"; path = "PATH=${makeBinPath [ coreutils gawk gnused gnugrep util-linux smartmon sysstat ]}:$PATH";
in '' in ''
for i in $out/libexec/zfs/zpool.d/*; do for i in $out/libexec/zfs/zpool.d/*; do
sed -i '2i${path}' $i sed -i '2i${path}' $i
@ -157,12 +159,17 @@ let
outputs = [ "out" ] ++ optionals buildUser [ "lib" "dev" ]; outputs = [ "out" ] ++ optionals buildUser [ "lib" "dev" ];
passthru.tests = if isUnstable then passthru = {
[ nixosTests.zfs.unstable ] inherit enableMail;
else [
tests =
if isUnstable then [
nixosTests.zfs.unstable
] else [
nixosTests.zfs.installer nixosTests.zfs.installer
nixosTests.zfs.stable nixosTests.zfs.stable
]; ];
};
meta = { meta = {
description = "ZFS Filesystem Linux Kernel module"; description = "ZFS Filesystem Linux Kernel module";

View File

@ -1,5 +1,6 @@
{ lib, stdenv, fetchurl, autoreconfHook { lib, stdenv, fetchurl, autoreconfHook
, mailutils, inetutils , mailutils, enableMail ? true
, inetutils
, IOKit, ApplicationServices }: , IOKit, ApplicationServices }:
let let
@ -26,7 +27,7 @@ in stdenv.mkDerivation rec {
postPatch = "cp -v ${driverdb} drivedb.h"; postPatch = "cp -v ${driverdb} drivedb.h";
configureFlags = [ configureFlags = [
"--with-scriptpath=${lib.makeBinPath [ mailutils inetutils ]}" "--with-scriptpath=${lib.makeBinPath ([ inetutils ] ++ lib.optional enableMail mailutils)}"
]; ];
nativeBuildInputs = [ autoreconfHook ]; nativeBuildInputs = [ autoreconfHook ];