Setup nix flake to work with darwin, wsl and linux system configuration. This has ONLY been tested on Darwin so far.

This commit is contained in:
Martin Lasson 2025-01-26 00:29:25 +01:00
parent 5322764881
commit f0f8aeb7b8
15 changed files with 468 additions and 144 deletions

58
nix/system/darwin.nix Normal file
View file

@ -0,0 +1,58 @@
{
pkgs,
config,
self,
...
}:
{
system.configurationRevision = self.rev or self.dirtyRev or null;
environment.systemPackages = with pkgs; [
home-manager
mkalias
];
homebrew = {
enable = true;
casks = [
"ghostty"
];
brews = [
"mas"
];
masApps = { };
onActivation.cleanup = "zap";
onActivation.autoUpdate = true;
onActivation.upgrade = true;
};
system.defaults = {
dock.autohide = true;
finder.FXPreferredViewStyle = "clmv";
loginwindow.GuestEnabled = false;
NSGlobalDomain.AppleICUForce24HourTime = true;
NSGlobalDomain.AppleInterfaceStyle = "Dark";
NSGlobalDomain.KeyRepeat = 2;
};
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
'';
}

2
nix/system/linux.nix Normal file
View file

@ -0,0 +1,2 @@
{ ... }: {
}

7
nix/system/wsl.nix Normal file
View file

@ -0,0 +1,7 @@
{ nixos-wsl, ... }: {
imports = [
nixosWSL.nixosModules.default
];
wsl.enable = true;
}