up
This commit is contained in:
78
modules/platform/darwin/default.nix
Normal file
78
modules/platform/darwin/default.nix
Normal file
@@ -0,0 +1,78 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
nixvim,
|
||||
user,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
../../core
|
||||
../../networking/tailscale.nix
|
||||
./secrets.nix
|
||||
./system.nix
|
||||
./homebrew.nix
|
||||
./dock
|
||||
];
|
||||
|
||||
system = {
|
||||
primaryUser = user;
|
||||
stateVersion = 6;
|
||||
};
|
||||
|
||||
nix = {
|
||||
settings.trusted-users = ["@admin" "${user}"];
|
||||
gc.interval = {
|
||||
Weekday = 0;
|
||||
Hour = 2;
|
||||
Minute = 0;
|
||||
};
|
||||
};
|
||||
|
||||
users.users.${user} = {
|
||||
name = "${user}";
|
||||
home = "/Users/${user}";
|
||||
isHidden = false;
|
||||
shell = pkgs.fish;
|
||||
};
|
||||
|
||||
home-manager = {
|
||||
users.${user} = {
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
_module.args = {inherit user;};
|
||||
imports = [
|
||||
nixvim.homeModules.nixvim
|
||||
../../home-manager/base
|
||||
../../home-manager/darwin
|
||||
];
|
||||
fonts.fontconfig.enable = true;
|
||||
home = {
|
||||
packages = pkgs.callPackage ../../packages {}
|
||||
++ pkgs.callPackage ./packages.nix {};
|
||||
stateVersion = "25.11";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
local = {
|
||||
dock = {
|
||||
enable = true;
|
||||
username = user;
|
||||
entries = [
|
||||
{path = "/Applications/Safari.app/";}
|
||||
{path = "/${pkgs.ghostty-bin}/Applications/Ghostty.app/";}
|
||||
{path = "/System/Applications/Notes.app/";}
|
||||
{path = "/System/Applications/Music.app/";}
|
||||
{path = "/System/Applications/System Settings.app/";}
|
||||
{
|
||||
path = "${config.users.users.${user}.home}/Downloads";
|
||||
section = "others";
|
||||
options = "--sort name --view grid --display stack";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
104
modules/platform/darwin/dock/default.nix
Normal file
104
modules/platform/darwin/dock/default.nix
Normal file
@@ -0,0 +1,104 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.local.dock;
|
||||
inherit (pkgs) stdenv dockutil;
|
||||
in {
|
||||
options = {
|
||||
local.dock = {
|
||||
enable = mkOption {
|
||||
description = "Enable dock";
|
||||
default = stdenv.isDarwin;
|
||||
example = false;
|
||||
};
|
||||
|
||||
entries = mkOption {
|
||||
description = "Entries on the Dock";
|
||||
type = with types;
|
||||
listOf (submodule {
|
||||
options = {
|
||||
path = lib.mkOption {type = str;};
|
||||
section = lib.mkOption {
|
||||
type = str;
|
||||
default = "apps";
|
||||
};
|
||||
options = lib.mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
});
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
username = mkOption {
|
||||
description = "Username to apply the dock settings to";
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
let
|
||||
normalize = path:
|
||||
if hasSuffix ".app" path
|
||||
then path + "/"
|
||||
else path;
|
||||
entryURI = path:
|
||||
"file://"
|
||||
+ (
|
||||
builtins.replaceStrings
|
||||
[
|
||||
" "
|
||||
"!"
|
||||
"\""
|
||||
"#"
|
||||
"$"
|
||||
"%"
|
||||
"&"
|
||||
"'"
|
||||
"("
|
||||
")"
|
||||
]
|
||||
[
|
||||
"%20"
|
||||
"%21"
|
||||
"%22"
|
||||
"%23"
|
||||
"%24"
|
||||
"%25"
|
||||
"%26"
|
||||
"%27"
|
||||
"%28"
|
||||
"%29"
|
||||
]
|
||||
(normalize path)
|
||||
);
|
||||
wantURIs = concatMapStrings (entry: "${entryURI entry.path}\n") cfg.entries;
|
||||
createEntries =
|
||||
concatMapStrings (
|
||||
entry: "${dockutil}/bin/dockutil --no-restart --add '${entry.path}' --section ${entry.section} ${entry.options}\n"
|
||||
)
|
||||
cfg.entries;
|
||||
in {
|
||||
system.activationScripts.postActivation.text = ''
|
||||
echo >&2 "Setting up the Dock for ${cfg.username}..."
|
||||
su ${cfg.username} -s /bin/sh <<'USERBLOCK'
|
||||
haveURIs="$(${dockutil}/bin/dockutil --list | ${pkgs.coreutils}/bin/cut -f2)"
|
||||
if ! diff -wu <(echo -n "$haveURIs") <(echo -n '${wantURIs}') >&2 ; then
|
||||
echo >&2 "Resetting Dock."
|
||||
${dockutil}/bin/dockutil --no-restart --remove all
|
||||
${createEntries}
|
||||
killall Dock
|
||||
else
|
||||
echo >&2 "Dock setup complete."
|
||||
fi
|
||||
USERBLOCK
|
||||
'';
|
||||
}
|
||||
);
|
||||
}
|
||||
11
modules/platform/darwin/homebrew.nix
Normal file
11
modules/platform/darwin/homebrew.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
homebrew = {
|
||||
enable = true;
|
||||
casks = [
|
||||
"orbstack"
|
||||
];
|
||||
masApps = {
|
||||
"wipr2" = 1662217862;
|
||||
};
|
||||
};
|
||||
}
|
||||
8
modules/platform/darwin/packages.nix
Normal file
8
modules/platform/darwin/packages.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{pkgs}:
|
||||
with pkgs; [
|
||||
_1password-gui
|
||||
dockutil
|
||||
mas
|
||||
raycast
|
||||
whatsapp-for-mac
|
||||
]
|
||||
8
modules/platform/darwin/secrets.nix
Normal file
8
modules/platform/darwin/secrets.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
user,
|
||||
...
|
||||
}: {
|
||||
age.identityPaths = [
|
||||
"/Users/${user}/.ssh/id_ed25519"
|
||||
];
|
||||
}
|
||||
30
modules/platform/darwin/system.nix
Normal file
30
modules/platform/darwin/system.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{lib, ...}: {
|
||||
system.defaults = {
|
||||
NSGlobalDomain = {
|
||||
AppleShowAllExtensions = true;
|
||||
ApplePressAndHoldEnabled = false;
|
||||
KeyRepeat = 2;
|
||||
InitialKeyRepeat = 15;
|
||||
"com.apple.mouse.tapBehavior" = 1;
|
||||
"com.apple.sound.beep.volume" = 0.0;
|
||||
"com.apple.sound.beep.feedback" = 0;
|
||||
};
|
||||
|
||||
dock = {
|
||||
autohide = true;
|
||||
show-recents = false;
|
||||
launchanim = true;
|
||||
orientation = "bottom";
|
||||
tilesize = 60;
|
||||
};
|
||||
|
||||
finder = {
|
||||
_FXShowPosixPathInTitle = false;
|
||||
};
|
||||
|
||||
trackpad = {
|
||||
Clicking = true;
|
||||
TrackpadThreeFingerDrag = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user