refactor(nix/darwin): Simplify Spotlight/LaunchPad fix script
REF: https://youtu.be/Z8BL8mdzWHI?t=1104
This commit is contained in:
parent
f218e3d721
commit
bc08f68068
1 changed files with 17 additions and 27 deletions
|
@ -24,6 +24,7 @@
|
||||||
pkgs.android-tools
|
pkgs.android-tools
|
||||||
pkgs.duti
|
pkgs.duti
|
||||||
pkgs.undmg
|
pkgs.undmg
|
||||||
|
pkgs.mkalias
|
||||||
|
|
||||||
pkgs.pass
|
pkgs.pass
|
||||||
pkgs.passExtensions.pass-otp
|
pkgs.passExtensions.pass-otp
|
||||||
|
@ -68,33 +69,22 @@
|
||||||
# in spotlight, and when launched through the dock they come with a terminal window. This is a workaround.
|
# in spotlight, and when launched through the dock they come with a terminal window. This is a workaround.
|
||||||
# Upstream issue: https://github.com/LnL7/nix-darwin/issues/214
|
# Upstream issue: https://github.com/LnL7/nix-darwin/issues/214
|
||||||
# Original code: https://github.com/IvarWithoutBones/dotfiles/commit/0b3faad8bd1d0e1af6103caf59b206666ab742f4
|
# Original code: https://github.com/IvarWithoutBones/dotfiles/commit/0b3faad8bd1d0e1af6103caf59b206666ab742f4
|
||||||
activationScripts.applications.text = pkgs.lib.mkForce ''
|
activationScripts.applications.text = let
|
||||||
echo "setting up ~/Applications..." >&2
|
env = pkgs.buildEnv {
|
||||||
applications="/Applications"
|
name = "system-applications";
|
||||||
nix_apps="$applications/Nix Apps"
|
paths = config.environment.systemPackages;
|
||||||
|
pathsToLink = "/Applications";
|
||||||
# Delete the directory to remove old links
|
};
|
||||||
rm -rf "$nix_apps"
|
in pkgs.lib.mkForce ''
|
||||||
mkdir -p "$nix_apps"
|
echo "setting up /Applications..." >&2
|
||||||
find ${config.system.build.applications}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
|
rm -rf "/Applications/Nix Apps"
|
||||||
while read src; do
|
mkdir -p "/Applications/Nix Apps"
|
||||||
ln -s "$src" "$nix_apps"
|
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
|
||||||
|
while read src; do
|
||||||
# >> Original linking script - I don't use Spotlight
|
app_name=$(basename "$src")
|
||||||
# Spotlight does not recognize symlinks, it will ignore directory we link to the applications folder.
|
echo "copying $src" >&2
|
||||||
# It does understand MacOS aliases though, a unique filesystem feature. Sadly they cannot be created
|
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
|
||||||
# from bash (as far as I know), so we use the oh-so-great Apple Script instead.
|
done
|
||||||
# /usr/bin/osascript -e "
|
|
||||||
# set fileToAlias to POSIX file \"$src\"
|
|
||||||
# set applicationsFolder to POSIX file \"$nix_apps\"
|
|
||||||
# tell application \"Finder\"
|
|
||||||
# make alias file to fileToAlias at applicationsFolder
|
|
||||||
# # This renames the alias; 'mpv.app alias' -> 'mpv.app'
|
|
||||||
# set name of result to \"$(rev <<< "$src" | cut -d'/' -f1 | rev)\"
|
|
||||||
# end tell
|
|
||||||
# " 1>/dev/null
|
|
||||||
# << Original linking script
|
|
||||||
done
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue