Last active
September 7, 2025 14:20
-
-
Save elliottminns/211ef645ebd484eb9a5228570bb60ec3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system.activationScripts.applications.text = let | |
env = pkgs.buildEnv { | |
name = "system-applications"; | |
paths = config.environment.systemPackages; | |
pathsToLink = "/Applications"; | |
}; | |
in | |
pkgs.lib.mkForce '' | |
# Set up applications. | |
echo "setting up /Applications..." >&2 | |
rm -rf /Applications/Nix\ Apps | |
mkdir -p /Applications/Nix\ Apps | |
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + | | |
while read -r src; do | |
app_name=$(basename "$src") | |
echo "copying $src" >&2 | |
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name" | |
done | |
''; |
@Kapi2910 - You could try to remove (or rename) the old directory, then re-run your rebuild so nix-darwin can create its symlink.
mac-app-util ... This is the way. I had to delete my existing /Applications/Nix Apps and re-run my darwin-rebuild command for the magic to happen.
@mikewebbtech That worked. Thank you so much.
{
description = "Example nix-darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, nixpkgs, nix-darwin, ... }:
let
system = "aarch64-darwin";
configuration = { config, pkgs, ... }:
let
env = pkgs.buildEnv {
name = "system-applications";
paths = config.environment.systemPackages;
pathsToLink = "/Applications";
};
in {
environment.systemPackages = with pkgs; [
neovim
];
system.activationScripts.applications.text = pkgs.lib.mkForce ''
echo "setting up /Applications..." >&2
rm -rf /Applications/Nix\ Apps
mkdir -p /Applications/Nix\ Apps
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read -r src; do
app_name=$(basename "$src")
echo "copying $src" >&2
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
done
'';
nix.settings.experimental-features = "nix-command flakes";
system.configurationRevision = self.rev or self.dirtyRev or null;
system.stateVersion = 6;
nixpkgs.hostPlatform = system;
};
in {
darwinConfigurations."mini" = nix-darwin.lib.darwinSystem {
inherit system;
modules = [ configuration ];
};
};
}
This is how I fixed it :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@frarredondo Thanks for the snippet.
when I try to run the flake, I get this warning:
Any idea how to fix this?