Skip to content

Commit

Permalink
Merge branch 'master' into staging
Browse files Browse the repository at this point in the history
Thousands of rebuilds from master :-/
  • Loading branch information
vcunat committed Sep 23, 2017
2 parents 1dd63de + 18ebc8d commit 73282c8
Show file tree
Hide file tree
Showing 103 changed files with 5,522 additions and 3,361 deletions.
2 changes: 2 additions & 0 deletions lib/maintainers.nix
Expand Up @@ -186,6 +186,7 @@
ellis = "Ellis Whitehead <nixos@ellisw.net>";
eperuffo = "Emanuele Peruffo <info@emanueleperuffo.com>";
epitrochoid = "Mabry Cervin <mpcervin@uncg.edu>";
eqyiel = "Ruben Maher <r@rkm.id.au>";
ericbmerritt = "Eric Merritt <eric@afiniate.com>";
ericsagnes = "Eric Sagnes <eric.sagnes@gmail.com>";
erikryb = "Erik Rybakken <erik.rybakken@math.ntnu.no>";
Expand Down Expand Up @@ -663,4 +664,5 @@
zoomulator = "Kim Simmons <zoomulator@gmail.com>";
zraexy = "David Mell <zraexy@gmail.com>";
zx2c4 = "Jason A. Donenfeld <Jason@zx2c4.com>";
zzamboni = "Diego Zamboni <diego@zzamboni.org>";
}
1 change: 1 addition & 0 deletions nixos/modules/profiles/base.nix
Expand Up @@ -20,6 +20,7 @@

# Some networking tools.
pkgs.fuse
pkgs.fuse3
pkgs.sshfs-fuse
pkgs.socat
pkgs.screen
Expand Down
12 changes: 10 additions & 2 deletions nixos/modules/security/lock-kernel-modules.nix
Expand Up @@ -17,19 +17,27 @@ with lib;
};

config = mkIf config.security.lockKernelModules {
boot.kernelModules = concatMap (x:
if x.device != null
then
if x.fsType == "vfat"
then [ "vfat" "nls-cp437" "nls-iso8859-1" ]
else [ x.fsType ]
else []) config.system.build.fileSystems;

systemd.services.disable-kernel-module-loading = rec {
description = "Disable kernel module loading";

wantedBy = [ config.systemd.defaultUnit ];
after = [ "systemd-udev-settle.service" "firewall.service" "systemd-modules-load.service" ] ++ wantedBy;

script = "echo -n 1 > /proc/sys/kernel/modules_disabled";
after = [ "systemd-udev-settle.service" "firewall.service" "systemd-modules-load.service" ] ++ wantedBy;

unitConfig.ConditionPathIsReadWrite = "/proc/sys/kernel";

serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "/bin/sh -c 'echo -n 1 >/proc/sys/kernel/modules_disabled'";
};
};
};
Expand Down
5 changes: 4 additions & 1 deletion nixos/modules/security/wrappers/default.nix
Expand Up @@ -155,7 +155,10 @@ in
###### implementation
config = {

security.wrappers.fusermount.source = "${pkgs.fuse}/bin/fusermount";
security.wrappers = {
fusermount.source = "${pkgs.fuse}/bin/fusermount";
fusermount3.source = "${pkgs.fuse3}/bin/fusermount3";
};

boot.specialFileSystems.${parentWrapperDir} = {
fsType = "tmpfs";
Expand Down
126 changes: 111 additions & 15 deletions nixos/modules/services/misc/gitolite.nix
Expand Up @@ -49,6 +49,35 @@ in
'';
};

extraGitoliteRc = mkOption {
type = types.lines;
default = "";
example = literalExample ''
$RC{UMASK} = 0027;
$RC{SITE_INFO} = 'This is our private repository host';
push( @{$RC{ENABLE}}, 'Kindergarten' ); # enable the command/feature
@{$RC{ENABLE}} = grep { $_ ne 'desc' } @{$RC{ENABLE}}; # disable the command/feature
'';
description = ''
Extra configuration to append to the default <literal>~/.gitolite.rc</literal>.
This should be Perl code that modifies the <literal>%RC</literal>
configuration variable. The default <literal>~/.gitolite.rc</literal>
content is generated by invoking <literal>gitolite print-default-rc</literal>,
and extra configuration from this option is appended to it. The result
is placed to Nix store, and the <literal>~/.gitolite.rc</literal> file
becomes a symlink to it.
If you already have a customized (or otherwise changed)
<literal>~/.gitolite.rc</literal> file, NixOS will refuse to replace
it with a symlink, and the `gitolite-init` initialization service
will fail. In this situation, in order to use this option, you
will need to take any customizations you may have in
<literal>~/.gitolite.rc</literal>, convert them to appropriate Perl
statements, add them to this option, and remove the file.
'';
};

user = mkOption {
type = types.str;
default = "gitolite";
Expand All @@ -59,7 +88,34 @@ in
};
};

config = mkIf cfg.enable {
config = mkIf cfg.enable (
let
manageGitoliteRc = cfg.extraGitoliteRc != "";
rcDir = pkgs.runCommand "gitolite-rc" { } rcDirScript;
rcDirScript =
''
mkdir "$out"
export HOME=temp-home
mkdir -p "$HOME/.gitolite/logs" # gitolite can't run without it
'${pkgs.gitolite}'/bin/gitolite print-default-rc >>"$out/gitolite.rc.default"
cat <<END >>"$out/gitolite.rc"
# This file is managed by NixOS.
# Use services.gitolite options to control it.
END
cat "$out/gitolite.rc.default" >>"$out/gitolite.rc"
'' +
optionalString (cfg.extraGitoliteRc != "") ''
echo -n ${escapeShellArg ''
# Added by NixOS:
${removeSuffix "\n" cfg.extraGitoliteRc}
# per perl rules, this should be the last line in such a file:
1;
''} >>"$out/gitolite.rc"
'';
in {
users.extraUsers.${cfg.user} = {
description = "Gitolite user";
home = cfg.dataDir;
Expand All @@ -77,21 +133,61 @@ in
serviceConfig.Type = "oneshot";
serviceConfig.RemainAfterExit = true;

path = [ pkgs.gitolite pkgs.git pkgs.perl pkgs.bash config.programs.ssh.package ];
script = ''
cd ${cfg.dataDir}
mkdir -p .gitolite/logs
if [ ! -d repositories ]; then
gitolite setup -pk ${pubkeyFile}
fi
if [ -n "${hooks}" ]; then
cp ${hooks} .gitolite/hooks/common/
chmod +x .gitolite/hooks/common/*
fi
gitolite setup # Upgrade if needed
'';
path = [ pkgs.gitolite pkgs.git pkgs.perl pkgs.bash pkgs.diffutils config.programs.ssh.package ];
script =
let
rcSetupScriptIfCustomFile =
if manageGitoliteRc then ''
cat <<END
<3>ERROR: NixOS can't apply declarative configuration
<3>to your .gitolite.rc file, because it seems to be
<3>already customized manually.
<3>See the services.gitolite.extraGitoliteRc option
<3>in "man configuration.nix" for more information.
END
# Not sure if the line below addresses the issue directly or just
# adds a delay, but without it our error message often doesn't
# show up in `systemctl status gitolite-init`.
journalctl --flush
exit 1
'' else ''
:
'';
rcSetupScriptIfDefaultFileOrStoreSymlink =
if manageGitoliteRc then ''
ln -sf "${rcDir}/gitolite.rc" "$GITOLITE_RC"
'' else ''
[[ -L "$GITOLITE_RC" ]] && rm -f "$GITOLITE_RC"
'';
in
''
cd ${cfg.dataDir}
mkdir -p .gitolite/logs
GITOLITE_RC=.gitolite.rc
GITOLITE_RC_DEFAULT=${rcDir}/gitolite.rc.default
if ( [[ ! -e "$GITOLITE_RC" ]] && [[ ! -L "$GITOLITE_RC" ]] ) ||
( [[ -f "$GITOLITE_RC" ]] && diff -q "$GITOLITE_RC" "$GITOLITE_RC_DEFAULT" >/dev/null ) ||
( [[ -L "$GITOLITE_RC" ]] && [[ "$(readlink "$GITOLITE_RC")" =~ ^/nix/store/ ]] )
then
'' + rcSetupScriptIfDefaultFileOrStoreSymlink +
''
else
'' + rcSetupScriptIfCustomFile +
''
fi
if [ ! -d repositories ]; then
gitolite setup -pk ${pubkeyFile}
fi
if [ -n "${hooks}" ]; then
cp ${hooks} .gitolite/hooks/common/
chmod +x .gitolite/hooks/common/*
fi
gitolite setup # Upgrade if needed
'';
};

environment.systemPackages = [ pkgs.gitolite pkgs.git ];
};
});
}
Expand Up @@ -33,7 +33,7 @@ in {
default = [];
example = ''[ "systemd" ]'';
description = ''
Collectors to enable, additionally to the defaults.
Collectors to enable. Only collectors explicitly listed here will be enabled.
'';
};

Expand Down
61 changes: 61 additions & 0 deletions nixos/modules/services/network-filesystems/glusterfs.nix
Expand Up @@ -5,6 +5,22 @@ with lib;
let
inherit (pkgs) glusterfs rsync;

tlsCmd = if (cfg.tlsSettings != null) then
''
mkdir -p /var/lib/glusterd
touch /var/lib/glusterd/secure-access
''
else
''
rm -f /var/lib/glusterd/secure-access
'';

restartTriggers = if (cfg.tlsSettings != null) then [
config.environment.etc."ssl/glusterfs.pem".source
config.environment.etc."ssl/glusterfs.key".source
config.environment.etc."ssl/glusterfs.ca".source
] else [];

cfg = config.services.glusterfs;

in
Expand All @@ -30,6 +46,41 @@ in
description = "Extra flags passed to the GlusterFS daemon";
default = [];
};

tlsSettings = mkOption {
description = ''
Make the server communicate via TLS.
This means it will only connect to other gluster
servers having certificates signed by the same CA.
Enabling this will create a file <filename>/var/lib/glusterd/secure-access</filename>.
Disabling will delete this file again.
See also: https://gluster.readthedocs.io/en/latest/Administrator%20Guide/SSL/
'';
default = null;
type = types.nullOr (types.submodule {
options = {
tlsKeyPath = mkOption {
default = null;
type = types.str;
description = "Path to the private key used for TLS.";
};

tlsPem = mkOption {
default = null;
type = types.path;
description = "Path to the certificate used for TLS.";
};

caCert = mkOption {
default = null;
type = types.path;
description = "Path certificate authority used to sign the cluster certificates.";
};
};
});
};
};
};

Expand All @@ -40,7 +91,14 @@ in

services.rpcbind.enable = true;

environment.etc = mkIf (cfg.tlsSettings != null) {
"ssl/glusterfs.pem".source = cfg.tlsSettings.tlsPem;
"ssl/glusterfs.key".source = cfg.tlsSettings.tlsKeyPath;
"ssl/glusterfs.ca".source = cfg.tlsSettings.caCert;
};

systemd.services.glusterd = {
inherit restartTriggers;

description = "GlusterFS, a clustered file-system server";

Expand All @@ -57,6 +115,8 @@ in
+ ''
mkdir -p /var/lib/glusterd/hooks/
${rsync}/bin/rsync -a ${glusterfs}/var/lib/glusterd/hooks/ /var/lib/glusterd/hooks/
${tlsCmd}
''
# `glusterfind` needs dirs that upstream installs at `make install` phase
# https://github.com/gluster/glusterfs/blob/v3.10.2/tools/glusterfind/Makefile.am#L16-L17
Expand All @@ -75,6 +135,7 @@ in
};

systemd.services.glustereventsd = {
inherit restartTriggers;

description = "Gluster Events Notifier";

Expand Down
12 changes: 11 additions & 1 deletion nixos/modules/system/boot/luksroot.nix
Expand Up @@ -235,6 +235,16 @@ in
'';
};

boot.initrd.luks.forceLuksSupportInInitrd = mkOption {
type = types.bool;
default = false;
internal = true;
description = ''
Whether to configure luks support in the initrd, when no luks
devices are configured.
'';
};

boot.initrd.luks.devices = mkOption {
default = { };
example = { "luksroot".device = "/dev/disk/by-uuid/430e9eff-d852-4f68-aa3b-2fa3599ebe08"; };
Expand Down Expand Up @@ -417,7 +427,7 @@ in
};
};

config = mkIf (luks.devices != {}) {
config = mkIf (luks.devices != {} || luks.forceLuksSupportInInitrd) {

# actually, sbp2 driver is the one enabling the DMA attack, but this needs to be tested
boot.blacklistedKernelModules = optionals luks.mitigateDMAAttacks
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/tasks/encrypted-devices.nix
Expand Up @@ -61,6 +61,7 @@ in
devices =
map (dev: { name = dev.encrypted.label; device = dev.encrypted.blkDev; } ) keylessEncDevs;
cryptoModules = [ "aes" "sha256" "sha1" "xts" ];
forceLuksSupportInInitrd = true;
};
postMountCommands =
concatMapStrings (dev: "cryptsetup luksOpen --key-file ${dev.encrypted.keyFile} ${dev.encrypted.blkDev} ${dev.encrypted.label};\n") keyedEncDevs;
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/tasks/filesystems.nix
Expand Up @@ -217,7 +217,7 @@ in
# Add the mount helpers to the system path so that `mount' can find them.
system.fsPackages = [ pkgs.dosfstools ];

environment.systemPackages = [ pkgs.fuse ] ++ config.system.fsPackages;
environment.systemPackages = with pkgs; [ fuse3 fuse ] ++ config.system.fsPackages;

environment.etc.fstab.text =
let
Expand Down
6 changes: 6 additions & 0 deletions nixos/modules/tasks/filesystems/nfs.nix
Expand Up @@ -85,8 +85,14 @@ in
enable = mkDefault false;
};

systemd.services.auth-rpcgss-module =
{
unitConfig.ConditionPathExists = [ "" "/etc/krb5.keytab" ];
};

systemd.services.rpc-gssd =
{ restartTriggers = [ nfsConfFile ];
unitConfig.ConditionPathExists = [ "" "/etc/krb5.keytab" ];
};

systemd.services.rpc-statd =
Expand Down

0 comments on commit 73282c8

Please sign in to comment.