2023-03-23 01:04:29 +00:00
|
|
|
{
|
2023-06-18 00:46:31 +00:00
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}: {
|
2023-06-16 23:12:54 +00:00
|
|
|
# This patch exists since Darwin's search bar requires solid apps and not
|
|
|
|
# symlinked
|
|
|
|
# TODO: QA
|
|
|
|
# - [x] works for base case
|
|
|
|
# - [x] works for repeated case
|
2023-06-18 00:46:31 +00:00
|
|
|
# - [ ] works after base case, then removed
|
2023-06-16 23:12:54 +00:00
|
|
|
# - [ ] works for repeated case, then removed
|
|
|
|
|
2023-03-23 01:04:29 +00:00
|
|
|
# Copy GUI apps to "~/Applications/Home Manager Apps"
|
|
|
|
# Based on this comment: https://github.com/nix-community/home-manager/issues/1341#issuecomment-778820334
|
2023-06-15 19:46:01 +00:00
|
|
|
home.activation.patch-spotlight =
|
2023-06-18 00:46:31 +00:00
|
|
|
if pkgs.stdenv.isDarwin
|
|
|
|
then let
|
|
|
|
apps = pkgs.buildEnv {
|
|
|
|
name = "home-manager-applications";
|
|
|
|
paths = config.home.packages;
|
|
|
|
pathsToLink = "/Applications";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
lib.hm.dag.entryAfter ["linkGeneration"] ''
|
2023-03-23 01:04:29 +00:00
|
|
|
# Install MacOS applications to the user environment.
|
|
|
|
HM_APPS="$HOME/Applications/Home Manager Apps"
|
|
|
|
# Reset current state
|
2023-06-07 15:30:46 +00:00
|
|
|
if [ -e "$HM_APPS" ]; then
|
2023-06-08 04:53:56 +00:00
|
|
|
$DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)"
|
2023-06-07 15:30:46 +00:00
|
|
|
fi
|
2023-03-23 01:04:29 +00:00
|
|
|
$DRY_RUN_CMD mkdir -p "$HM_APPS"
|
|
|
|
# .app dirs need to be actual directories for Finder to detect them as Apps.
|
|
|
|
# In the env of Apps we build, the .apps are symlinks. We pass all of them as
|
|
|
|
# arguments to cp and make it dereference those using -H
|
|
|
|
$DRY_RUN_CMD cp --archive -H --dereference ${apps}/Applications/* "$HM_APPS"
|
|
|
|
$DRY_RUN_CMD chmod +w -R "$HM_APPS"
|
|
|
|
''
|
2023-06-18 00:46:31 +00:00
|
|
|
else "";
|
2023-06-15 19:46:01 +00:00
|
|
|
# We need this in case upstream home-manager changes the behavior of linking
|
|
|
|
# applications
|
2023-06-18 00:46:31 +00:00
|
|
|
home.activation.remove-patch-spotlight =
|
|
|
|
if pkgs.stdenv.isDarwin
|
|
|
|
then
|
|
|
|
lib.hm.dag.entryBefore ["checkLinkTargets"] ''
|
2023-06-15 19:46:01 +00:00
|
|
|
HM_APPS="$HOME/Applications/Home Manager Apps"
|
|
|
|
# Reset current state
|
|
|
|
if [ -e "$HM_APPS" ]; then
|
|
|
|
$DRY_RUN_CMD mv "$HM_APPS" "$HM_APPS.$(date +%Y%m%d%H%M%S)"
|
|
|
|
fi
|
|
|
|
''
|
2023-06-18 00:46:31 +00:00
|
|
|
else "";
|
2023-03-23 01:04:29 +00:00
|
|
|
}
|