git.iko.soy/typeable/nixpkgs
on master help sign in
netatalk: 3.1.0 -> 3.1.7, new service module
commita2b8cc0aaf74f4a98b820925f96a33123fbcd1c4 authorJordan Mulcahey <snhjordy@gmail.com> dateThu 13 Aug 2015, 22:05 (11 years ago) parente3aa635
4 files changed+196−6
nixos/modules/module-list.nix+1 nixos/modules/services/network-filesystems/netatalk.nix+150 pkgs/tools/filesystems/netatalk/default.nix+10−6 pkgs/tools/filesystems/netatalk/omitLocalstatedirCreation.patch+35
nixos/modules/module-list.nix+1
@@ -275,6 +275,7 @@
275275 ./services/monitoring/zabbix-agent.nix
276276 ./services/monitoring/zabbix-server.nix
277277 ./services/network-filesystems/drbd.nix
278+ ./services/network-filesystems/netatalk.nix
278279 ./services/network-filesystems/nfsd.nix
279280 ./services/network-filesystems/openafs-client/default.nix
280281 ./services/network-filesystems/rsyncd.nix
nixos/modules/services/network-filesystems/netatalk.nixnew file+150
@@ -0,0 +1,150 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+
7+ cfg = config.services.netatalk;
8+
9+ extmapFile = pkgs.writeText "extmap.conf" cfg.extmap;
10+
11+ afpToString = x: if builtins.typeOf x == "bool"
12+ then (if x then "true" else "false")
13+ else toString x;
14+
15+ volumeConfig = name:
16+ let vol = getAttr name cfg.volumes; in
17+ "[${name}]\n " + (toString (
18+ map
19+ (key: "${key} = ${afpToString (getAttr key vol)}\n")
20+ (attrNames vol)
21+ ));
22+
23+ afpConf = ''[Global]
24+ extmap file = ${extmapFile}
25+ afp port = ${toString cfg.port}
26+
27+ ${cfg.extraConfig}
28+
29+ ${if cfg.homes.enable then ''[Homes]
30+ ${optionalString (cfg.homes.path != "") "path = ${cfg.homes.path}"}
31+ basedir regex = ${cfg.homes.basedirRegex}
32+ ${cfg.homes.extraConfig}
33+ '' else ""}
34+
35+ ${toString (map volumeConfig (attrNames cfg.volumes))}
36+ '';
37+
38+ afpConfFile = pkgs.writeText "afp.conf" afpConf;
39+
40+in
41+
42+{
43+ options = {
44+ services.netatalk = {
45+
46+ enable = mkOption {
47+ default = false;
48+ description = "Whether to enable the Netatalk AFP fileserver.";
49+ };
50+
51+ port = mkOption {
52+ default = 548;
53+ description = "TCP port to be used for AFP.";
54+ };
55+
56+ extraConfig = mkOption {
57+ type = types.lines;
58+ default = "";
59+ example = "uam list = uams_guest.so";
60+ description = ''
61+ Lines of configuration to add to the <literal>[Global]</literal> section.
62+ See <literal>man apf.conf</literal> for more information.
63+ '';
64+ };
65+
66+ homes = {
67+ enable = mkOption {
68+ default = false;
69+ description = "Enable sharing of the UNIX server user home directories.";
70+ };
71+
72+ path = mkOption {
73+ default = "";
74+ example = "afp-data";
75+ description = "Share not the whole user home but this subdirectory path.";
76+ };
77+
78+ basedirRegex = mkOption {
79+ example = "/home";
80+ description = "Regex which matches the parent directory of the user homes.";
81+ };
82+
83+ extraConfig = mkOption {
84+ type = types.lines;
85+ default = "";
86+ description = ''
87+ Lines of configuration to add to the <literal>[Homes]</literal> section.
88+ See <literal>man apf.conf</literal> for more information.
89+ '';
90+ };
91+ };
92+
93+ volumes = mkOption {
94+ default = { };
95+ type = types.attrsOf (types.attrsOf types.unspecified);
96+ description =
97+ ''
98+ Set of AFP volumes to export.
99+ See <literal>man apf.conf</literal> for more information.
100+ '';
101+ example =
102+ { srv =
103+ { path = "/srv";
104+ "read only" = true;
105+ "hosts allow" = "10.1.0.0/16 10.2.1.100 2001:0db8:1234::/48";
106+ };
107+ };
108+ };
109+
110+ extmap = mkOption {
111+ type = types.lines;
112+ default = "";
113+ description = ''
114+ File name extension mappings.
115+ See <literal>man extmap.conf</literal> for more information.
116+ '';
117+ };
118+
119+ };
120+ };
121+
122+ config = mkIf cfg.enable {
123+
124+ systemd.services.netatalk = {
125+ description = "Netatalk AFP fileserver for Macintosh clients";
126+ unitConfig.Documentation = "man:afp.conf(5) man:netatalk(8) man:afpd(8) man:cnid_metad(8) man:cnid_dbd(8)";
127+ after = [ "network.target" "avahi-daemon.service" ];
128+ wantedBy = [ "multi-user.target" ];
129+
130+ path = [ pkgs.netatalk ];
131+
132+ serviceConfig = {
133+ Type = "forking";
134+ GuessMainPID = "no";
135+ PIDFile = "/run/lock/netatalk";
136+ ExecStartPre = "${pkgs.coreutils}/bin/mkdir -m 0755 -p /var/lib/netatalk/CNID";
137+ ExecStart = "${pkgs.netatalk}/sbin/netatalk -F ${afpConfFile}";
138+ ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
139+ ExecStop = "${pkgs.coreutils}/bin/kill -TERM $MAINPID";
140+ Restart = "always";
141+ RestartSec = 1;
142+ };
143+
144+ };
145+
146+ security.pam.services.netatalk.unixAuth = true;
147+
148+ };
149+
150+}
pkgs/tools/filesystems/netatalk/default.nix+10−6
@@ -1,24 +1,28 @@
1−{ fetchurl, stdenv, pkgconfig, db, libgcrypt, avahi, libiconv, pam, openssl }:
1+{ fetchurl, stdenv, pkgconfig, db, libgcrypt, avahi, libiconv, pam, openssl, acl }:
22
3−stdenv.mkDerivation rec {
4− name = "netatalk-3.1.0";
3+stdenv.mkDerivation rec{
4+ name = "netatalk-3.1.7";
55
66 src = fetchurl {
77 url = "mirror://sourceforge/netatalk/netatalk/${name}.tar.bz2";
8− sha256 = "1d8dc8ysslkis4yl1xab1w9p0pz7a1kg0i6fds4wxsp4fhb6wqhq";
8+ sha256 = "0wf09fyqzza024qr1s26z5x7rsvh9zb4pv598gw7gm77wjcr6174";
99 };
1010
11− buildInputs = [ pkgconfig db libgcrypt avahi pam openssl libiconv ];
11+ buildInputs = [ pkgconfig db libgcrypt avahi libiconv pam openssl acl ];
12+
13+ patches = ./omitLocalstatedirCreation.patch;
1214
1315 configureFlags = [
1416 "--with-bdb=${db}"
1517 "--with-openssl=${openssl}"
18+ "--with-lockfile=/run/lock/netatalk"
19+ "--localstatedir=/var/lib"
1620 ];
1721
1822 enableParallelBuild = true;
1923
2024 meta = {
21− description = "Apple File Protocl Server";
25+ description = "Apple Filing Protocol Server";
2226 homepage = http://netatalk.sourceforge.net/;
2327 license = stdenv.lib.licenses.gpl3;
2428 platforms = stdenv.lib.platforms.linux;
pkgs/tools/filesystems/netatalk/omitLocalstatedirCreation.patchnew file+35
@@ -0,0 +1,35 @@
1+diff -ur netatalk-3.1.7-old/config/Makefile.in netatalk-3.1.7-new/config/Makefile.in
2+--- netatalk-3.1.7-old/config/Makefile.in 2014-08-29 03:33:35.000000000 -0700
3++++ netatalk-3.1.7-new/config/Makefile.in 2015-08-13 20:52:35.000000000 -0700
4+@@ -699,7 +699,7 @@
5+
6+ info-am:
7+
8+-install-data-am: install-data-local install-dbusserviceDATA
9++install-data-am: install-dbusserviceDATA
10+
11+ install-dvi: install-dvi-recursive
12+
13+@@ -754,7 +754,7 @@
14+ cscopelist cscopelist-recursive ctags ctags-recursive \
15+ distclean distclean-generic distclean-libtool distclean-tags \
16+ distdir dvi dvi-am html html-am info info-am install \
17+- install-am install-data install-data-am install-data-local \
18++ install-am install-data install-data-am \
19+ install-dbusserviceDATA install-dvi install-dvi-am \
20+ install-exec install-exec-am install-html install-html-am \
21+ install-info install-info-am install-man install-pdf \
22+@@ -782,12 +782,6 @@
23+ # install configuration files
24+ #
25+
26+-install-data-local: install-config-files
27+- mkdir -pm 0755 $(DESTDIR)$(localstatedir)/netatalk/
28+- mkdir -pm 0755 $(DESTDIR)$(localstatedir)/netatalk/CNID/
29+- $(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(localstatedir)/netatalk/
30+- $(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(localstatedir)/netatalk/CNID/
31+-
32+ uninstall-local:
33+ @for f in $(CONFFILES) $(GENFILES); do \
34+ echo rm -f $(DESTDIR)$(pkgconfdir)/$$f; \
35+