hraban / mac-app-util

Fix .app programs installed by Nix on Mac
GNU Affero General Public License v3.0
155 stars 5 forks source link

Noop-Module on Linux and/or enable option #5

Closed Tarow closed 1 month ago

Tarow commented 2 months ago

Thanks for the module, it works great!

On my hosts (Linux/Darwin) i use Home Manager as a standalone installation and reuse the same home.nix file and HM modules. Since conditional module imports such as

  imports = [
    ./modules
  ] ++ lib.lists.optional pkgs.stdenv.isDarwin inputs.mac-app-util.homeManagerModules.default;

are not possible, it would be great if this module could simply be imported on Linux systems aswell and be a noop module in that case. Alternatively an enable option would be great.

Currently the assertions prevent an import on linux systems, which requires me to define separate "entrypoint" home.nix files on my darwin based systems.

hraban commented 2 months ago

Fair I never thought of that. Having a .enable property like the other nixos modules would solve this, right?

I always wondered why they do that but now I know :D

Tarow commented 2 months ago

That would be one way, though, since on Linux it does not make any sense to enable this module (nor would it work), you might as well hardcode it.

So personally it would help me, if the assertion was removed and just turned into a condition such as

homeManagerModules.default = { pkgs, lib, ... }: lib.mkIf (builtins.hasAttr pkgs.stdenv.system 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"
    '';
  };
};

An additional enable option could be useful on Darwin systems to conditionally disable this module without changing the imports.

hraban commented 1 month ago

Philosophical question : what are assertions good for , then?

hraban commented 1 month ago

POC in github:hraban/mac-app-util/enable -- give it a spin.

I have left in the asserts in favor of a .enable because I think now they do make sense.

Tarow commented 1 month ago

Thanks a lot, works just fine with the feature branch: image