about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-07T09·18+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-04-07T09·50+0200
commit84d6936371037559704337614c65007a8e61b5e1 (patch)
treeeb21a77502e0c67d525128e74212606e11ce0ea5
parent8e5fbf4d730b9fcf39eddf5539a206cf19d2cdce (diff)
Install systemd units
-rw-r--r--.gitignore3
-rw-r--r--Makefile1
-rw-r--r--misc/systemd/local.mk1
-rw-r--r--misc/systemd/nix-daemon.service10
-rw-r--r--misc/systemd/nix-daemon.service.in9
-rw-r--r--misc/systemd/nix-daemon.socket.in11
-rw-r--r--nix.spec.in8
7 files changed, 25 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index 76fc815eba1f..008f5de8a46e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -108,6 +108,9 @@ Makefile.config
 /perl/lib/Nix/Config.pm
 /perl/lib/Nix/Store.cc
 
+/misc/systemd/nix-daemon.service
+/misc/systemd/nix-daemon.socket
+
 *.a
 *.o
 *.so
diff --git a/Makefile b/Makefile
index bcfa89dd2305..77f22db9f218 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,7 @@ makefiles = \
   perl/local.mk \
   scripts/local.mk \
   corepkgs/local.mk \
+  misc/systemd/local.mk \
   misc/emacs/local.mk \
   doc/manual/local.mk \
   tests/local.mk
diff --git a/misc/systemd/local.mk b/misc/systemd/local.mk
new file mode 100644
index 000000000000..a5f6131ce878
--- /dev/null
+++ b/misc/systemd/local.mk
@@ -0,0 +1 @@
+$(foreach n, nix-daemon.socket nix-daemon.service, $(eval $(call install-file-in, $(d)/$(n), $(libdir)/systemd/system, 0644)))
diff --git a/misc/systemd/nix-daemon.service b/misc/systemd/nix-daemon.service
deleted file mode 100644
index ee28209f090e..000000000000
--- a/misc/systemd/nix-daemon.service
+++ /dev/null
@@ -1,10 +0,0 @@
-[Unit]
-Description=Helper daemon for managing secure, multi-user Nix stores
-After=syslog.target
-
-[Service]
-Type=simple
-ExecStart=/usr/bin/nix-daemon
-
-[Install]
-WantedBy=multi-user.target
diff --git a/misc/systemd/nix-daemon.service.in b/misc/systemd/nix-daemon.service.in
new file mode 100644
index 000000000000..5fc04a3f5713
--- /dev/null
+++ b/misc/systemd/nix-daemon.service.in
@@ -0,0 +1,9 @@
+[Unit]
+Description=Nix Daemon
+RequiresMountsFor=@storedir@
+RequiresMountsFor=@localstatedir@
+ConditionPathIsReadWrite=@localstatedir@/nix/daemon-socket
+
+[Service]
+ExecStart=@@bindir@/nix-daemon nix-daemon --daemon
+KillMode=process
diff --git a/misc/systemd/nix-daemon.socket.in b/misc/systemd/nix-daemon.socket.in
new file mode 100644
index 000000000000..9ed39ffe6eb2
--- /dev/null
+++ b/misc/systemd/nix-daemon.socket.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=Nix Daemon Socket
+Before=multi-user.target
+RequiresMountsFor=@storedir@
+ConditionPathIsReadWrite=@localstatedir@/nix/daemon-socket
+
+[Socket]
+ListenStream=@localstatedir@/nix/daemon-socket/socket
+
+[Install]
+WantedBy=sockets.target
diff --git a/nix.spec.in b/nix.spec.in
index f067c3896fb2..1457308d1e0e 100644
--- a/nix.spec.in
+++ b/nix.spec.in
@@ -132,14 +132,6 @@ done
 # (until this is fixed in the relevant Makefile)
 chmod -x $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/nix.sh
 
-# systemd not available on RHEL yet
-%if ! 0%{?rhel}
-# install systemd service descriptor
-mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system
-cp -p misc/systemd/nix-daemon.service \
-  $RPM_BUILD_ROOT%{_prefix}/lib/systemd/system/
-%endif
-
 # Copy the byte-compiled mode file by hand
 cp -p misc/emacs/nix-mode.elc $RPM_BUILD_ROOT%{_emacs_sitelispdir}/