Author: eelco
Date: Fri Mar 16 20:41:49 2012
New Revision: 33174
URL: https://nixos.org/websvn/nix/?rev=33174&sc=1
Log:
* Renamed services.nfsKernel to services.nfs. Unfortunately
rename.nix doesn't allow renaming sets of options...
* Renamed nfs-kernel.nix to nfsd.nix
* Move NFS client stuff from nfsd.nix to filesystems/nfs.nix.
Added:
nixos/trunk/modules/services/network-filesystems/nfsd.nix
- copied, changed from r33172,
nixos/trunk/modules/services/network-filesystems/nfs-kernel.nix
Deleted:
nixos/trunk/modules/services/network-filesystems/nfs-kernel.nix
Modified:
nixos/trunk/modules/module-list.nix
nixos/trunk/modules/tasks/filesystems.nix
nixos/trunk/modules/tasks/filesystems/nfs.nix
nixos/trunk/tests/check-filesystems.nix
nixos/trunk/tests/nfs.nix
nixos/trunk/tests/trac.nix
Modified: nixos/trunk/modules/module-list.nix
==============================================================================
--- nixos/trunk/modules/module-list.nix Fri Mar 16 20:23:45 2012 (r33173)
+++ nixos/trunk/modules/module-list.nix Fri Mar 16 20:41:49 2012 (r33174)
@@ -105,7 +105,7 @@
./services/monitoring/zabbix-agent.nix
./services/monitoring/zabbix-server.nix
./services/network-filesystems/drbd.nix
- ./services/network-filesystems/nfs-kernel.nix
+ ./services/network-filesystems/nfsd.nix
./services/network-filesystems/openafs-client/default.nix
./services/network-filesystems/samba.nix
./services/networking/amuled.nix
Copied and modified: nixos/trunk/modules/services/network-filesystems/nfsd.nix
(from r33172, nixos/trunk/modules/services/network-filesystems/nfs-kernel.nix)
==============================================================================
--- nixos/trunk/modules/services/network-filesystems/nfs-kernel.nix Fri Mar
16 20:10:14 2012 (r33172, copy source)
+++ nixos/trunk/modules/services/network-filesystems/nfsd.nix Fri Mar 16
20:41:49 2012 (r33174)
@@ -4,11 +4,9 @@
let
- inherit (pkgs) writeText openssh;
+ cfg = config.services.nfs.server;
- cfg = config.services.nfsKernel;
-
- exports = pkgs.writeText "exports" cfg.server.exports;
+ exports = pkgs.writeText "exports" cfg.exports;
in
@@ -18,14 +16,7 @@
options = {
- services.nfsKernel = {
-
- client.enable = mkOption {
- default = any (fs: fs.fsType == "nfs" || fs.fsType == "nfs4")
config.fileSystems;
- description = ''
- Whether to enable the kernel's NFS client daemons.
- '';
- };
+ services.nfs = {
server = {
enable = mkOption {
@@ -74,108 +65,82 @@
###### implementation
- config = {
+ config = mkIf cfg.enable {
- services.portmap.enable = cfg.client.enable || cfg.server.enable;
+ services.portmap.enable = true;
- environment.systemPackages = mkIf cfg.server.enable [ pkgs.nfsUtils ];
+ services.nfs.client.enable = true; # needed for statd
- environment.etc = mkIf cfg.server.enable (singleton
+ environment.systemPackages = [ pkgs.nfsUtils ];
+
+ environment.etc = singleton
{ source = exports;
target = "exports";
- });
+ };
- boot.kernelModules = mkIf cfg.server.enable [ "nfsd" ];
+ boot.kernelModules = [ "nfsd" ];
- jobs =
- optionalAttrs cfg.server.enable
- { nfsd =
- { description = "Kernel NFS server";
+ jobs.nfsd =
+ { description = "Kernel NFS server";
- startOn = "started networking";
+ startOn = "started networking";
- path = [ pkgs.nfsUtils ];
+ path = [ pkgs.nfsUtils ];
- preStart =
- ''
- start portmap || true
- start mountd || true
-
- # Create a state directory required by NFSv4.
- mkdir -p /var/lib/nfs/v4recovery
-
- rpc.nfsd \
- ${if cfg.server.hostName != null then "-H
${cfg.server.hostName}" else ""} \
- ${builtins.toString cfg.server.nproc}
- '';
+ preStart =
+ ''
+ start portmap || true
+ start mountd || true
- postStop = "rpc.nfsd 0";
+ # Create a state directory required by NFSv4.
+ mkdir -p /var/lib/nfs/v4recovery
- postStart =
- ''
- start statd || true
- '';
- };
- }
-
- // optionalAttrs cfg.server.enable
- { mountd =
- { description = "Kernel NFS server - mount daemon";
+ rpc.nfsd \
+ ${if cfg.hostName != null then "-H ${cfg.hostName}" else ""} \
+ ${builtins.toString cfg.nproc}
+ '';
- path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ];
+ postStop = "rpc.nfsd 0";
- preStart =
- ''
- start portmap || true
-
- mkdir -p /var/lib/nfs
- touch /var/lib/nfs/rmtab
-
- mountpoint -q /proc/fs/nfsd || mount -t nfsd none /proc/fs/nfsd
-
- ${optionalString cfg.server.createMountPoints
- ''
- # create export directories:
- # skip comments, take first col which may either be a
quoted
- # "foo bar" or just foo (-> man export)
- sed '/^#.*/d;s/^"\([^"]*\)".*/\1/;t;s/[ ].*//' ${exports} \
- | xargs -d '\n' mkdir -p
- ''
- }
-
- # exports file is ${exports}
- # keep this comment so that this job is restarted whenever
exports changes!
- exportfs -ra
- '';
-
- daemonType = "fork";
-
- exec = "rpc.mountd -f /etc/exports";
- };
- }
-
- // optionalAttrs (cfg.client.enable || cfg.server.enable)
- { statd =
- { description = "Kernel NFS server - Network Status Monitor";
+ postStart =
+ ''
+ start statd || true
+ '';
+ };
+
+ jobs.mountd =
+ { description = "Kernel NFS server - mount daemon";
+
+ path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ];
- path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ];
+ preStart =
+ ''
+ start portmap || true
- stopOn = "never"; # needed during shutdown
+ mkdir -p /var/lib/nfs
+ touch /var/lib/nfs/rmtab
- preStart =
+ mountpoint -q /proc/fs/nfsd || mount -t nfsd none /proc/fs/nfsd
+
+ ${optionalString cfg.createMountPoints
+ ''
+ # create export directories:
+ # skip comments, take first col which may either be a quoted
+ # "foo bar" or just foo (-> man export)
+ sed '/^#.*/d;s/^"\([^"]*\)".*/\1/;t;s/[ ].*//' ${exports} \
+ | xargs -d '\n' mkdir -p
''
- start portmap || true
- mkdir -p /var/lib/nfs
- mkdir -p /var/lib/nfs/sm
- mkdir -p /var/lib/nfs/sm.bak
- sm-notify -d
- '';
+ }
- daemonType = "fork";
+ # exports file is ${exports}
+ # keep this comment so that this job is restarted whenever exports
changes!
+ exportfs -ra
+ '';
- exec = "rpc.statd --no-notify";
- };
- };
+ daemonType = "fork";
+
+ exec = "rpc.mountd -f /etc/exports";
+ };
};
Modified: nixos/trunk/modules/tasks/filesystems.nix
==============================================================================
--- nixos/trunk/modules/tasks/filesystems.nix Fri Mar 16 20:23:45 2012
(r33173)
+++ nixos/trunk/modules/tasks/filesystems.nix Fri Mar 16 20:41:49 2012
(r33174)
@@ -183,7 +183,7 @@
# Ensure that this job is restarted when fstab changed:
# ${fstab}
- ${optionalString config.services.nfsKernel.client.enable ''
+ ${optionalString config.services.nfs.client.enable ''
start statd || true
''}
@@ -196,9 +196,8 @@
# The `mount-failed' event is emitted synchronously, but we don't
# want `mountall' to wait for the emergency shell. So use this
# intermediate job to make the event asynchronous.
- jobs.mount_failed =
- { name = "mount-failed";
- task = true;
+ jobs."mount-failed" =
+ { task = true;
startOn = "mount-failed";
script =
''
@@ -210,9 +209,8 @@
# On an `ip-up' event, notify mountall so that it retries mounting
# remote filesystems.
- jobs.mountall_ip_up =
+ jobs."mountall-ip-up" =
{
- name = "mountall-ip-up";
task = true;
startOn = "ip-up";
script =
@@ -221,10 +219,8 @@
'';
};
- jobs.emergency_shell =
- { name = "emergency-shell";
-
- task = true;
+ jobs."emergency-shell" =
+ { task = true;
extraConfig = "console owner";
Modified: nixos/trunk/modules/tasks/filesystems/nfs.nix
==============================================================================
--- nixos/trunk/modules/tasks/filesystems/nfs.nix Fri Mar 16 20:23:45
2012 (r33173)
+++ nixos/trunk/modules/tasks/filesystems/nfs.nix Fri Mar 16 20:41:49
2012 (r33174)
@@ -9,8 +9,27 @@
in
{
- config = {
+ ###### interface
+
+ options = {
+
+ services.nfs.client.enable = mkOption {
+ default = any (fs: fs.fsType == "nfs" || fs.fsType == "nfs4")
config.fileSystems;
+ description = ''
+ Whether to enable support for mounting NFS filesystems.
+ '';
+ };
+
+ };
+
+
+ ###### implementation
+
+ config = mkIf config.services.nfs.client.enable {
+
+ services.portmap.enable = true;
+
system.fsPackages = [ pkgs.nfsUtils ];
boot.initrd.kernelModules = mkIf inInitrd [ "nfs" ];
@@ -21,5 +40,26 @@
cp -v ${pkgs.klibc}/lib/klibc/bin.static/nfsmount $out/bin
'';
+ jobs.statd =
+ { description = "Kernel NFS server - Network Status Monitor";
+
+ path = [ pkgs.nfsUtils pkgs.sysvtools pkgs.utillinux ];
+
+ stopOn = "never"; # needed during shutdown
+
+ preStart =
+ ''
+ start portmap || true
+ mkdir -p /var/lib/nfs
+ mkdir -p /var/lib/nfs/sm
+ mkdir -p /var/lib/nfs/sm.bak
+ sm-notify -d
+ '';
+
+ daemonType = "fork";
+
+ exec = "rpc.statd --no-notify";
+ };
+
};
}
Modified: nixos/trunk/tests/check-filesystems.nix
==============================================================================
--- nixos/trunk/tests/check-filesystems.nix Fri Mar 16 20:23:45 2012
(r33173)
+++ nixos/trunk/tests/check-filesystems.nix Fri Mar 16 20:41:49 2012
(r33174)
@@ -8,14 +8,12 @@
rec {
nodes = {
share = {pkgs, config, ...}: {
- services.portmap.enable = true;
- services.nfsKernel.client.enable = true;
- services.nfsKernel.server.enable = true;
- services.nfsKernel.server.exports = ''
+ services.nfs.server.enable = true;
+ services.nfs.server.exports = ''
/repos1 192.168.1.0/255.255.255.0(rw,no_root_squash)
/repos2 192.168.1.0/255.255.255.0(rw,no_root_squash)
'';
- services.nfsKernel.server.createMountPoints = true;
+ services.nfs.server.createMountPoints = true;
jobs.checkable = {
startOn = [
@@ -27,22 +25,20 @@
};
fsCheck = {pkgs, config, ...}: {
- # enable nfs import
- services.portmap.enable = true;
- services.nfsKernel.client.enable = true;
-
fileSystems =
let
repos1 = {
mountPoint = "/repos1";
autocreate = true;
device = "share:/repos1";
+ fsType = "nfs";
};
repos2 = {
mountPoint = "/repos2";
autocreate = true;
device = "share:/repos2";
+ fsType = "nfs";
};
in pkgs.lib.mkOverrideTemplate 50 {} [
repos1
Modified: nixos/trunk/tests/nfs.nix
==============================================================================
--- nixos/trunk/tests/nfs.nix Fri Mar 16 20:23:45 2012 (r33173)
+++ nixos/trunk/tests/nfs.nix Fri Mar 16 20:41:49 2012 (r33174)
@@ -23,12 +23,12 @@
server =
{ config, pkgs, ... }:
- { services.nfsKernel.server.enable = true;
- services.nfsKernel.server.exports =
+ { services.nfs.server.enable = true;
+ services.nfs.server.exports =
''
/data 192.168.1.0/255.255.255.0(rw,no_root_squash)
'';
- services.nfsKernel.server.createMountPoints = true;
+ services.nfs.server.createMountPoints = true;
};
};
Modified: nixos/trunk/tests/trac.nix
==============================================================================
--- nixos/trunk/tests/trac.nix Fri Mar 16 20:23:45 2012 (r33173)
+++ nixos/trunk/tests/trac.nix Fri Mar 16 20:41:49 2012 (r33174)
@@ -5,12 +5,11 @@
storage =
{pkgs, config, ...}:
{
- services.portmap.enable = true;
- services.nfsKernel.server.enable = true;
- services.nfsKernel.server.exports = ''
+ services.nfs.server.enable = true;
+ services.nfs.server.exports = ''
/repos 192.168.1.0/255.255.255.0(rw,no_root_squash)
'';
- services.nfsKernel.server.createMountPoints = true;
+ services.nfs.server.createMountPoints = true;
};
postgresql =
@@ -35,11 +34,10 @@
[ { mountPoint = "/repos";
device = "storage:/repos";
fsType = "nfs";
- options = "bootwait"; }
+ options = "bootwait";
+ }
];
- services.portmap.enable = true;
- services.nfsKernel.client.enable = true;
services.httpd.enable = true;
services.httpd.adminAddr = "root@localhost";
services.httpd.extraSubservices = [ { serviceType = "trac"; } ];
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits