From 83c03b6efed6fce094c4ed378023a9324f038ab8 Mon Sep 17 00:00:00 2001 From: Hraban Luyat Date: Fri, 27 Sep 2024 14:06:07 -0400 Subject: [PATCH] feat: enable option for home manager module Fixes #5 --- flake.nix | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/flake.nix b/flake.nix index e61526d..a7a93d3 100644 --- a/flake.nix +++ b/flake.nix @@ -27,19 +27,29 @@ outputs = { self, nixpkgs, flake-utils, cl-nix-lite, ... }: { - homeManagerModules.default = { pkgs, lib, ... }: { - assertions = [ { - assertion = builtins.hasAttr pkgs.stdenv.system self.packages; - message = "mac-app-util home manager module: Unsupported architecture ${pkgs.stdenv.system}. Supported: ${builtins.toString (builtins.attrNames self.packages)}"; - } ]; - home.activation = { - trampolineApps = let - mac-app-util = self.packages.${pkgs.stdenv.system}.default; - in lib.hm.dag.entryAfter [ "writeBoundary" ] '' - fromDir="$HOME/Applications/Home Manager Apps" - toDir="$HOME/Applications/Home Manager Trampolines" - ${mac-app-util}/bin/mac-app-util sync-trampolines "$fromDir" "$toDir" - ''; + homeManagerModules.default = { pkgs, lib, config, ... }: { + options = with lib; { + targets.darwin.mac-app-util.enable = mkOption { + type = types.bool; + default = builtins.hasAttr pkgs.stdenv.system self.packages; + example = true; + description = "Whether to enable mac-app-util home manager integration"; + }; + }; + config = lib.mkIf config.targets.darwin.mac-app-util.enable { + assertions = [ { + default = builtins.hasAttr pkgs.stdenv.system self.packages; + message = "mac-app-util home manager module: Unsupported architecture ${pkgs.stdenv.system}. Supported: ${builtins.toString (builtins.attrNames self.packages)}"; + } ]; + home.activation = { + trampolineApps = let + mac-app-util = self.packages.${pkgs.stdenv.system}.default; + in lib.hm.dag.entryAfter [ "writeBoundary" ] '' + fromDir="$HOME/Applications/Home Manager Apps" + toDir="$HOME/Applications/Home Manager Trampolines" + ${mac-app-util}/bin/mac-app-util sync-trampolines "$fromDir" "$toDir" + ''; + }; }; }; darwinModules.default = { pkgs, ... }: {