From 259f39246df4a8eb7460a8a688c1708ad76e3406 Mon Sep 17 00:00:00 2001 From: fortuneteller2k Date: Mon, 25 Dec 2023 07:17:49 +0800 Subject: [PATCH] targets/darwin: allow configuring application linking --- modules/targets/darwin/linkapps.nix | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/modules/targets/darwin/linkapps.nix b/modules/targets/darwin/linkapps.nix index 0d434234..08c354bb 100644 --- a/modules/targets/darwin/linkapps.nix +++ b/modules/targets/darwin/linkapps.nix @@ -1,9 +1,29 @@ { config, lib, pkgs, ... }: -{ - config = lib.mkIf pkgs.stdenv.hostPlatform.isDarwin { +with lib; + +let cfg = config.targets.darwin; +in { + options.targets.darwin.linkApps = { + enable = mkOption { + type = types.bool; + default = true; + example = false; + description = + "Whether to enable linking macOS applications to the user environment."; + }; + + directory = mkOption { + type = types.str; + default = "Applications/Home Manager Apps"; + defaultText = "Applications/Home Manager Apps"; + description = "Path to link apps relative to the home directory."; + }; + }; + + config = lib.mkIf (pkgs.stdenv.hostPlatform.isDarwin && cfg.linkApps.enable) { # Install MacOS applications to the user environment. - home.file."Applications/Home Manager Apps".source = let + home.file.${cfg.linkApps.directory}.source = let apps = pkgs.buildEnv { name = "home-manager-applications"; paths = config.home.packages;