feat(mac): Define system settings with nix-darwin

This commit is contained in:
js0ny 2025-03-03 18:30:48 +00:00
parent a7dfb2272c
commit d93d153827
2 changed files with 165 additions and 0 deletions

View file

@ -0,0 +1,113 @@
# vim:shiftwidth=2
# https://github.com/LnL7/nix-darwin/tree/5d6e0851b60508cffd66b4a6982440a40720338d/modules/system/defaults
{ pkgs, ... }: {
system.defaults = {
dock = {
appswitcher-all-displays = true;
autohide = true;
# Launch Animation
launchanim = false;
# Minimize Animation
mineffect = "suck";
minimize-to-application = true;
persistent-apps = [
{ app = "/Applications/Vivaldi.app"; }
{ app = "/Applications/WezTerm.app"; }
{ app = "/Applications/Obsidian.app"; }
{ app = "/Applications/Visual Studio Code.app"; }
{ app = "/Applications/Neovide.app"; }
# { spacer = { small = false; }; }
# { spacer = { small = true; }; }
# { folder = "/System/Applications/Utilities"; }
# { folder = "/Users/js0ny/Downloads/"; }
];
persistent-others = [
"/Users/js0ny/Downloads"
"/Users/js0ny/Source"
];
show-recents = false;
orientation = "bottom";
# tr - Top Right
# tl - Top Left (disable this)
# br - Bottom Right
# bl - Bottom Left
# `1`: Disabled
# `2`: Mission Control
# `3`: Application Windows
# `4`: Desktop
# `5`: Start Screen Saver
# `6`: Disable Screen Saver
# `7`: Dashboard
# `10`: Put Display to Sleep
# `11`: Launchpad
# `12`: Notification Center
# `13`: Lock Screen
# `14`: Quick Note
wvous-tr-corner = 2;
wvous-bl-corner = 11; # Simulate Windows button on Windows
wvous-br-corner = 4;
};
finder = {
AppleShowAllFiles = true;
ShowStatusBar = true;
ShowPathbar = true;
FXRemoveOldTrashItems = true;
AppleShowAllExtensions = true;
QuitMenuItem = true;
ShowExternalHardDrivesOnDesktop = false;
ShowRemovableMediaOnDesktop = false;
# This will look show full path in title bar
# For example: /Users/username/Downloads
# instead of just Downloads
_FXShowPosixPathInTitle = false;
_FXSortFoldersFirst = true;
FXEnableExtensionChangeWarning = false;
# Use `Home` instead of `PfHm`
# nix-darwin won't parse `PfHm`
NewWindowTarget = "Home";
};
trackpad = {
TrackpadRightClick = true;
TrackpadThreeFingerDrag = true;
};
screencapture = {
location = "~/Pictures/Screenshots";
type = "png";
include-date = true;
};
SoftwareUpdate.AutomaticallyInstallMacOSUpdates = false;
".GlobalPreferences" = {
"com.apple.sound.beep.sound" = "/System/Library/Sounds/Blow.aiff";
};
NSGlobalDomain = {
AppleInterfaceStyle = "Dark";
AppleInterfaceStyleSwitchesAutomatically = true;
AppleShowAllExtensions = true;
# Use Fn key as standard function keys instead of media keys
"com.apple.keyboard.fnState" = true;
AppleMeasurementUnits = "Centimeters";
AppleICUForce24HourTime = true;
};
controlcenter.BatteryShowPercentage = true;
# Fn usage:
# 0: Show Emoji & Symbols
# 1: Change Input Source
# 2: Show Emoji & Symbols
# 3: Start Dictation
hitoolbox.AppleFnUsageType = "Change Input Source";
WindowManager = {
EnableTilingByEdgeDrag = true;
EnableTopTilingByEdgeDrag = true;
EnableTilingOptionAccelerator = true;
EnableTiledWindowMargins = true;
};
# universalaccess = {
# mouseDriverCursorSize = 1.5;
# reduceMotion = true;
# reduceTransparency = false;
# };
menuExtraClock = {
ShowSeconds = true;
};
};
}

View file

@ -0,0 +1,52 @@
{
description = "Example nix-darwin system flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:LnL7/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, nix-darwin, nixpkgs }:
let
configuration = { pkgs, ... }: {
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages =
[ pkgs.vim
];
environment.etc."zshenv".text = ''
if [ -d $HOME/.config/zsh ]; then
export ZDOTDIR=$HOME/.config/zsh
fi
'';
# Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes";
# Enable alternative shell support in nix-darwin.
# programs.fish.enable = true;
# Set Git commit hash for darwin-version.
system.configurationRevision = self.rev or self.dirtyRev or null;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 6;
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "aarch64-darwin";
};
in
{
# Build darwin flake using:
# $ darwin-rebuild build --flake .#Zen
darwinConfigurations."Zen" = nix-darwin.lib.darwinSystem {
modules = [
configuration
./default-system.nix
];
};
};
}