From 1d5c5266bb6067d322aa6b18d59da5d6b09992dd Mon Sep 17 00:00:00 2001
From: Daiderd Jordan <daiderd@gmail.com>
Date: Sun, 14 May 2017 01:19:07 +0200
Subject: [PATCH] add test for activate-system service

---
 release.nix                        |  2 ++
 tests/services-activate-system.nix | 14 ++++++++++++++
 2 files changed, 16 insertions(+)
 create mode 100644 tests/services-activate-system.nix

diff --git a/release.nix b/release.nix
index e81f9cfd..b0d5e792 100644
--- a/release.nix
+++ b/release.nix
@@ -88,6 +88,8 @@ let
     examples.lnl = genExample ./modules/examples/lnl.nix;
     examples.simple = genExample ./modules/examples/simple.nix;
 
+    tests.services-activate-system = makeTest ./tests/services-activate-system.nix;
+
     tests.system-defaults-write = makeTest ./tests/system-defaults-write.nix;
 
     tests.system-packages = makeTest ./tests/system-packages.nix;
diff --git a/tests/services-activate-system.nix b/tests/services-activate-system.nix
new file mode 100644
index 00000000..02eaf3cb
--- /dev/null
+++ b/tests/services-activate-system.nix
@@ -0,0 +1,14 @@
+{ config, pkgs, ... }:
+
+{
+  services.activate-system.enable = true;
+
+  test = ''
+    echo checking activation service in /Library/LaunchDaemons >&2
+    grep "org.nixos.activate-system" ${config.out}/Library/LaunchDaemons/org.nixos.activate-system.plist
+
+    echo checking activation of /run/current-system >&2
+    script=$(cat ${config.out}/Library/LaunchDaemons/org.nixos.activate-system.plist | awk -F'[< ]' '$3 ~ "^/nix/store/.*" {print $3}')
+    grep "ln -sfn .* /run/current-system" "$script"
+  '';
+}