Update Nix flake, refactor Darwin app aliases and use it for system and

home config. Remove qutebrowser, mousecat, move some apps from brew ->
nixpkgs, add firefox to mac
This commit is contained in:
Martin Larsson 2025-07-13 16:25:17 +02:00
parent 677baf3d71
commit de7f2ff31f
6 changed files with 95 additions and 82 deletions

View file

@ -1,5 +1,6 @@
{
pkgs,
lib,
config,
...
}:
@ -13,12 +14,26 @@ let
];
in
{
imports = [
./common/firefox.nix
];
home = {
packages = with pkgs; [
gawk
discord
bitwarden-cli
aerospace
mas
raycast
];
file = utils.mk_symlinks { inherit config dotfiles; };
activation.applications = utils.mkAppAliasHome {
derivationName = "home-applications";
appsPath = config.home.packages;
outputDir = "${config.home.homeDirectory}/Applications/Nix";
pkgs = pkgs;
lib = lib;
};
};
}

View file

@ -53,7 +53,6 @@ in
mako
bitwarden-cli
sway-audio-idle-inhibit
qutebrowser
ffmpeg
imv
];

View file

@ -1,9 +1,13 @@
{
pkgs,
config,
lib,
self,
...
}:
let
utils = import ../utils.nix;
in
{
environment.systemPackages = with pkgs; [
@ -15,12 +19,9 @@
enable = true;
casks = [
"ghostty"
"nikitabobko/tap/aerospace"
"qutebrowser"
"shortcat"
];
brews = [
"mas"
"bitwarden-cli"
];
masApps = { };
onActivation.cleanup = "zap";
@ -68,25 +69,13 @@
remapCapsLockToEscape = true;
swapLeftCtrlAndFn = false;
};
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
'';
activationScripts.applications.text = utils.mkAppAliasSystem {
derivationName = "system-applications";
appsPath = config.environment.systemPackages;
outputDir = "/Applications/Nix";
pkgs = pkgs;
lib = lib;
};
};
}

View file

@ -1,4 +1,4 @@
{
rec {
mk_symlinks =
{
config,
@ -13,4 +13,37 @@
};
}) dotfiles
);
mkAppAliasSystem = args: args.pkgs.lib.mkForce (mkAppAliasScriptContent args);
mkAppAliasHome =
args: args.lib.hm.dag.entryAfter [ "writeBoundary" ] (mkAppAliasScriptContent args);
# Darwin System / Home Manager expects activation scripts in different formats
# This only return the script body, use the other two functions in the config.
mkAppAliasScriptContent =
{
derivationName,
appsPath,
outputDir,
pkgs,
lib,
}:
let
env = pkgs.buildEnv {
name = derivationName;
paths = appsPath;
pathsToLink = "/Applications";
};
in
''
echo "Setting up macOS .app aliases..." >&2
rm -rf "${outputDir}"
mkdir -p "${outputDir}"
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read -r src; do
app_name=$(basename "$src")
${pkgs.mkalias}/bin/mkalias "$src" "${outputDir}/$app_name"
done
'';
}