mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-15 17:51:01 +00:00
ed1e73d01e
While the Nix store is almost always at `/nix/store`, we shouldn't assume it to be. Checking only the trailing part of the link is less exact but removes this bad assumption. I also added a check for the symlink's contents when overwriting it to more accurately check whether we own it and should replace it.
49 lines
1.1 KiB
Nix
49 lines
1.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.system;
|
|
|
|
in
|
|
|
|
{
|
|
options = {
|
|
};
|
|
|
|
config = {
|
|
|
|
system.build.applications = pkgs.buildEnv {
|
|
name = "system-applications";
|
|
paths = config.environment.systemPackages;
|
|
pathsToLink = "/Applications";
|
|
};
|
|
|
|
system.activationScripts.applications.text = ''
|
|
# Set up applications.
|
|
echo "setting up /Applications/Nix Apps..." >&2
|
|
|
|
ourLink () {
|
|
local link
|
|
link=$(readlink "$1")
|
|
[ -L "$1" ] && [ "''${link#*-}" = 'system-applications/Applications' ]
|
|
}
|
|
|
|
# Clean up for links created at the old location in HOME
|
|
if ourLink ~/Applications; then
|
|
rm ~/Applications
|
|
elif ourLink ~/Applications/'Nix Apps'; then
|
|
rm ~/Applications/'Nix Apps'
|
|
fi
|
|
|
|
if [ ! -e '/Applications/Nix Apps' ] \
|
|
|| ourLink '/Applications/Nix Apps'; then
|
|
ln -sfn ${cfg.build.applications}/Applications '/Applications/Nix Apps'
|
|
else
|
|
echo "warning: /Applications/Nix Apps is not owned by nix-darwin, skipping App linking..." >&2
|
|
fi
|
|
'';
|
|
|
|
};
|
|
}
|