diff --git a/flake.nix b/flake.nix index 78da99a..9debbed 100644 --- a/flake.nix +++ b/flake.nix @@ -53,13 +53,7 @@ }; }; }; - darwinModules.default = { pkgs, ... }: { - system.activationScripts.postActivation.text = let - mac-app-util = self.packages.${pkgs.stdenv.system}.default; - in '' - ${mac-app-util}/bin/mac-app-util sync-trampolines "/Applications/Nix Apps" "/Applications/Nix Trampolines" - ''; - }; + darwinModules.default = import ./nix-darwin-module.nix { mac-app-util-packages = self.packages; }; } // (with flake-utils.lib; eachDefaultSystem (system: diff --git a/nix-darwin-module.nix b/nix-darwin-module.nix new file mode 100644 index 0000000..b4b5e0c --- /dev/null +++ b/nix-darwin-module.nix @@ -0,0 +1,35 @@ +{ mac-app-util-packages }: +{ pkgs, config, lib, ... }: with lib; { + options = { + mac-app-util = { + enable = mkOption { + description = "Whether to enable mac-app-util nix-darwin integration"; + type = types.bool; + default = true; + }; + hide-trampolines-folder = mkOption { + description = "Hide the folder containing the trampolines in `/Applications/`"; + type = types.bool; + default = false; + }; + }; + }; + + config = let + cfg = config.mac-app-util; + in + mkIf cfg.enable { + system.activationScripts.postActivation.text = let + mac-app-util = mac-app-util-packages.${pkgs.stdenv.system}.default; + in '' + trampolines_dir="/Applications/Nix Trampolines" + nix_apps_dir="/Applications/Nix Apps" + + echo "mac-app-util: syncing trampolines for $nix_apps_dir..." + ${mac-app-util}/bin/mac-app-util sync-trampolines "$nix_apps_dir" "$trampolines_dir" + '' + + strings.optionalString cfg.hide-trampolines-folder '' + chflags hidden "$trampolines_dir" + ''; + }; +}