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 similarity index 100% rename from tests/modules/targets/default.nix rename to tests/modules/targets-linux/default.nix diff --git a/tests/modules/targets/generic-linux.nix b/tests/modules/targets-linux/generic-linux.nix similarity index 100% rename from tests/modules/targets/generic-linux.nix rename to tests/modules/targets-linux/generic-linux.nix