dotfiles.nix/home/copyApplications.nix

23 lines
846 B
Nix

# adapted from
# https://github.com/reckenrode/nixos-configs/blob/2acd7b0699fd57628deb7b8855b4d5f0ea8f8cb1/common/darwin/home-manager/copyApplications.nix
# workaround for
# https://github.com/nix-community/home-manager/issues/1341
{ config, pkgs, lib, ... }:
{
home.activation = lib.optionalAttrs pkgs.stdenv.isDarwin {
copyApplications = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
appsSrc="${config.home.homeDirectory}/Applications/Nix Apps/"
if [ -d "$appsSrc" ]; then
baseDir="$HOME/Applications/Home Manager Apps"
rsyncArgs="--archive --checksum --chmod=-w --copy-unsafe-links --delete"
$DRY_RUN_CMD mkdir -p "$baseDir"
$DRY_RUN_CMD sudo rm -rf "$baseDir"/*
$DRY_RUN_CMD sudo ${pkgs.rsync}/bin/rsync ''${VERBOSE_ARG:+-v} $rsyncArgs "$appsSrc" "$baseDir"
fi
'';
};
}