aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Berbiche <nic.berbiche@gmail.com>2020-08-28 09:42:05 -0400
committerRobert Helgesson <robert@rycee.net>2020-09-04 15:21:48 +0200
commitd3aee544b686a72b2bb7eeb379f72c6b6b2665b7 (patch)
tree535b273147ad5a6832b9b41c5400e5e60cd9706e
parentbd4c2b06515fb7cdef9dda19bccd47f37aa66324 (diff)
targets.darwin: add module
Currently, this module makes sure that `/Applications` directories for packages in `home.packages` get linked into the user's environment.
-rw-r--r--modules/modules.nix1
-rw-r--r--modules/targets/darwin.nix14
-rw-r--r--tests/default.nix4
-rw-r--r--tests/modules/targets-darwin/darwin.nix20
-rw-r--r--tests/modules/targets-darwin/default.nix1
-rw-r--r--tests/modules/targets-linux/default.nix (renamed from tests/modules/targets/default.nix)0
-rw-r--r--tests/modules/targets-linux/generic-linux.nix (renamed from tests/modules/targets/generic-linux.nix)0
7 files changed, 39 insertions, 1 deletions
diff --git a/modules/modules.nix b/modules/modules.nix
index b4eb4d4027c..08c978b177d 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -189,6 +189,7 @@ let
(loadModule ./services/xscreensaver.nix { })
(loadModule ./services/xsuspender.nix { condition = hostPlatform.isLinux; })
(loadModule ./systemd.nix { })
+ (loadModule ./targets/darwin.nix { condition = hostPlatform.isDarwin; })
(loadModule ./targets/generic-linux.nix { condition = hostPlatform.isLinux; })
(loadModule ./xcursor.nix { })
(loadModule ./xresources.nix { })
diff --git a/modules/targets/darwin.nix b/modules/targets/darwin.nix
new file mode 100644
index 00000000000..0d434234bbb
--- /dev/null
+++ b/modules/targets/darwin.nix
@@ -0,0 +1,14 @@
+{ config, lib, pkgs, ... }:
+
+{
+ config = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin {
+ # Install MacOS applications to the user environment.
+ home.file."Applications/Home Manager Apps".source = let
+ apps = pkgs.buildEnv {
+ name = "home-manager-applications";
+ paths = config.home.packages;
+ pathsToLink = "/Applications";
+ };
+ in "${apps}/Applications";
+ };
+}
diff --git a/tests/default.nix b/tests/default.nix
index 02afd5a2518..b44e4185fcc 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -69,6 +69,8 @@ import nmt {
./modules/programs/zplug
./modules/programs/zsh
./modules/xresources
+ ] ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
+ ./modules/targets-darwin
] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
./meta # Suffices to run on one platform.
./modules/misc/debug
@@ -93,6 +95,6 @@ import nmt {
./modules/services/window-managers/i3
./modules/services/window-managers/sway
./modules/systemd
- ./modules/targets
+ ./modules/targets-linux
]);
}
diff --git a/tests/modules/targets-darwin/darwin.nix b/tests/modules/targets-darwin/darwin.nix
new file mode 100644
index 00000000000..511ae87fd98
--- /dev/null
+++ b/tests/modules/targets-darwin/darwin.nix
@@ -0,0 +1,20 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ darwinTestApp = pkgs.runCommandLocal "target-darwin-example-app" { } ''
+ mkdir -p $out/Applications
+ touch $out/Applications/example-app
+ '';
+
+in {
+ config = {
+ home.packages = [ darwinTestApp ];
+
+ nmt.script = ''
+ assertFileExists 'home-files/Applications/Home Manager Apps/example-app'
+ '';
+ };
+}
diff --git a/tests/modules/targets-darwin/default.nix b/tests/modules/targets-darwin/default.nix
new file mode 100644
index 00000000000..479f586eef3
--- /dev/null
+++ b/tests/modules/targets-darwin/default.nix
@@ -0,0 +1 @@
+{ targets-darwin = ./darwin.nix; }
diff --git a/tests/modules/targets/default.nix b/tests/modules/targets-linux/default.nix
index e13617ccb74..e13617ccb74 100644
--- a/tests/modules/targets/default.nix
+++ b/tests/modules/targets-linux/default.nix
diff --git a/tests/modules/targets/generic-linux.nix b/tests/modules/targets-linux/generic-linux.nix
index d9bb85b651a..d9bb85b651a 100644
--- a/tests/modules/targets/generic-linux.nix
+++ b/tests/modules/targets-linux/generic-linux.nix