-
Notifications
You must be signed in to change notification settings - Fork 1
/
home-manager-apps.nix
32 lines (30 loc) · 1009 Bytes
/
home-manager-apps.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf hm;
inherit (pkgs.stdenv.hostPlatform) isDarwin;
in {
disabledModules = [ "targets/darwin/linkapps.nix" ];
# Copy apps to ~/Applications/ rather than symlinking,
# so they can be picked up by Alfred.
# https://github.com/nix-community/home-manager/issues/1341
config = mkIf isDarwin {
home.activation.copyApplications = let
apps = pkgs.buildEnv {
name = "home-manager-applications";
paths = config.home.packages;
pathsToLink = "/Applications";
};
in hm.dag.entryAfter [ "writeBoundary" ] ''
baseDir="$HOME/Applications/Home Manager Apps"
if [ -d "$baseDir" ]; then
rm -rf "$baseDir"
fi
mkdir -p "$baseDir"
for appFile in ${apps}/Applications/*; do
target="$baseDir/$(basename "$appFile")"
$DRY_RUN_CMD cp ''${VERBOSE_ARG:+-v} -fHRL "$appFile" "$baseDir"
$DRY_RUN_CMD chmod ''${VERBOSE_ARG:+-v} -R +w "$target"
done
'';
};
}