mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-06 12:00:14 +00:00
initial refactoring
This commit is contained in:
@ -0,0 +1,26 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.programs.doas;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.programs.doas.enable = lib.mkEnableOption "doas sudo alternative";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
# Alias sudo to doas for convenience
|
||||
fish.shellAliases = {
|
||||
sudo = "doas";
|
||||
};
|
||||
|
||||
# Disable overriding our sudo alias with a TERMINFO alias
|
||||
kitty.settings.shell_integration = "no-sudo";
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.programs.fish;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.programs.fish.enable = lib.mkEnableOption "Fish shell";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.fish.enable = true;
|
||||
|
||||
environment.shells = [ pkgs.fish ];
|
||||
|
||||
users.users.${config.user}.shell = pkgs.fish;
|
||||
|
||||
# Speeds up fish launch time on macOS
|
||||
programs.fish.useBabelfish = true;
|
||||
};
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.programs.homebrew;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.programs.homebrew.enable =
|
||||
lib.mkEnableOption "Homebrew macOS package manager";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Requires Homebrew to be installed
|
||||
system.activationScripts.preUserActivation.text = ''
|
||||
if ! xcode-select --version 2>/dev/null; then
|
||||
$DRY_RUN_CMD xcode-select --install
|
||||
fi
|
||||
if ! /opt/homebrew/bin/brew --version 2>/dev/null; then
|
||||
$DRY_RUN_CMD /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
fi
|
||||
'';
|
||||
|
||||
# Add homebrew paths to CLI path
|
||||
home.sessionPath = [ "/opt/homebrew/bin/" ];
|
||||
|
||||
homebrew = {
|
||||
enable = true;
|
||||
onActivation = {
|
||||
autoUpdate = false; # Don't update during rebuild
|
||||
cleanup = "zap"; # Uninstall all programs not declared
|
||||
upgrade = true;
|
||||
};
|
||||
global = {
|
||||
brewfile = true; # Run brew bundle from anywhere
|
||||
lockfiles = false; # Don't save lockfile (since running from anywhere)
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.dock;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.dock.enable = lib.mkEnableOption "macOS Dock";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
system.defaults.CustomUserPreferences = {
|
||||
"com.apple.dock" = {
|
||||
magnification = true;
|
||||
largesize = 48;
|
||||
};
|
||||
};
|
||||
|
||||
system.defaults.dock = {
|
||||
|
||||
# Automatically show and hide the dock
|
||||
autohide = true;
|
||||
|
||||
# Add translucency in dock for hidden applications
|
||||
showhidden = true;
|
||||
|
||||
# Enable spring loading on all dock items
|
||||
enable-spring-load-actions-on-all-items = true;
|
||||
|
||||
# Highlight hover effect in dock stack grid view
|
||||
mouse-over-hilite-stack = true;
|
||||
|
||||
mineffect = "genie";
|
||||
orientation = "bottom";
|
||||
show-recents = false;
|
||||
tilesize = 44;
|
||||
|
||||
persistent-apps = [
|
||||
"/Applications/1Password.app"
|
||||
"${pkgs.slack}/Applications/Slack.app"
|
||||
"/System/Applications/Calendar.app"
|
||||
"${pkgs.firefox-bin}/Applications/Firefox.app"
|
||||
"/System/Applications/Messages.app"
|
||||
"/System/Applications/Mail.app"
|
||||
"/Applications/zoom.us.app"
|
||||
"${pkgs.discord}/Applications/Discord.app"
|
||||
"${pkgs.obsidian}/Applications/Obsidian.app"
|
||||
"${pkgs.wezterm}/Applications/WezTerm.app"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.finder;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.finder.enable = lib.mkEnableOption "macOS Finder options";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
system.defaults = {
|
||||
|
||||
finder = {
|
||||
|
||||
# Default Finder window set to column view
|
||||
FXPreferredViewStyle = "clmv";
|
||||
|
||||
# Finder search in current folder by default
|
||||
FXDefaultSearchScope = "SCcf";
|
||||
|
||||
# Disable warning when changing file extension
|
||||
FXEnableExtensionChangeWarning = false;
|
||||
|
||||
# Allow quitting of Finder application
|
||||
QuitMenuItem = true;
|
||||
};
|
||||
|
||||
NSGlobalDomain = {
|
||||
|
||||
# Save to local disk by default, not iCloud
|
||||
NSDocumentSaveNewDocumentsToCloud = false;
|
||||
|
||||
};
|
||||
|
||||
CustomUserPreferences = {
|
||||
|
||||
"com.apple.finder" = {
|
||||
# Disable the warning before emptying the Trash
|
||||
WarnOnEmptyTrash = false;
|
||||
|
||||
# Finder search in current folder by default
|
||||
FXDefaultSearchScope = "SCcf";
|
||||
|
||||
# Default Finder window set to column view
|
||||
FXPreferredViewStyle = "clmv";
|
||||
};
|
||||
# Avoid creating .DS_Store files on network or USB volumes
|
||||
"com.apple.desktopservices" = {
|
||||
DSDontWriteNetworkStores = true;
|
||||
DSDontWriteUSBStores = true;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
# User-level settings
|
||||
activationScripts.postUserActivation.text = ''
|
||||
echo "Show the ~/Library folder"
|
||||
chflags nohidden ~/Library
|
||||
'';
|
||||
|
||||
};
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.hammerspoon;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.hammerspoon.enable =
|
||||
lib.mkEnableOption "Hammerspoon macOS automation";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
homebrew.casks = [ "hammerspoon" ];
|
||||
|
||||
system.activationScripts.postUserActivation.text = ''
|
||||
defaults write org.hammerspoon.Hammerspoon MJConfigFile "${config.homePath}/.config/hammerspoon/init.lua"
|
||||
sudo killall Dock
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.menubar;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.menubar.enable = lib.mkEnableOption "macOS menubar settings";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
# User-level settings
|
||||
activationScripts.postUserActivation.text = ''
|
||||
echo "Reduce Menu Bar padding"
|
||||
defaults write -globalDomain NSStatusItemSelectionPadding -int 6
|
||||
defaults write -globalDomain NSStatusItemSpacing -int 6
|
||||
'';
|
||||
|
||||
system.defaults = {
|
||||
|
||||
# Show seconds on the clock
|
||||
menuExtraClock.ShowSeconds = true;
|
||||
|
||||
NSGlobalDomain = {
|
||||
|
||||
# Only hide menu bar in fullscreen
|
||||
_HIHideMenuBar = false;
|
||||
|
||||
};
|
||||
|
||||
CustomUserPreferences = {
|
||||
"leits.MeetingBar" = {
|
||||
eventTimeFormat = ''"show"'';
|
||||
eventTitleFormat = ''"none"'';
|
||||
eventTitleIconFormat = ''"iconCalendar"'';
|
||||
slackBrowser = ''{"deletable":true,"arguments":"","name":"Slack","path":""}'';
|
||||
zoomBrowser = ''{"deletable":true,"arguments":"","name":"Zoom","path":""}'';
|
||||
teamsBrowser = ''{"deletable":true,"arguments":"","name":"Teams","path":""}'';
|
||||
KeyboardShortcuts_joinEventShortcut = ''{"carbonModifiers":6400,"carbonKeyCode":38}'';
|
||||
timeFormat = ''"12-hour"'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.nix-daemon;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.nix-daemon.enable = lib.mkEnableOption "Nix garbage collection";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.nix-daemon.enable = true;
|
||||
|
||||
nix.gc.interval = {
|
||||
Hour = 12;
|
||||
Minute = 15;
|
||||
Day = 1;
|
||||
};
|
||||
};
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.settings;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.settings.enable = lib.mkEnableOption "macOS settings";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
security.pam.enableSudoTouchIdAuth = true;
|
||||
|
||||
system = {
|
||||
|
||||
stateVersion = 5;
|
||||
|
||||
keyboard = {
|
||||
remapCapsLockToControl = true;
|
||||
enableKeyMapping = true; # Allows for skhd
|
||||
};
|
||||
|
||||
defaults = {
|
||||
NSGlobalDomain = {
|
||||
|
||||
# Set to dark mode
|
||||
AppleInterfaceStyle = "Dark";
|
||||
|
||||
# Don't change from dark to light automatically
|
||||
# AppleInterfaceSwitchesAutomatically = false;
|
||||
|
||||
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
|
||||
AppleKeyboardUIMode = 3;
|
||||
|
||||
# Expand save panel by default
|
||||
NSNavPanelExpandedStateForSaveMode = true;
|
||||
|
||||
# Expand print panel by default
|
||||
PMPrintingExpandedStateForPrint = true;
|
||||
|
||||
# Replace press-and-hold with key repeat
|
||||
ApplePressAndHoldEnabled = false;
|
||||
|
||||
# Set a fast key repeat rate
|
||||
KeyRepeat = 2;
|
||||
|
||||
# Shorten delay before key repeat begins
|
||||
InitialKeyRepeat = 12;
|
||||
|
||||
# Disable autocorrect capitalization
|
||||
NSAutomaticCapitalizationEnabled = false;
|
||||
|
||||
# Disable autocorrect smart dashes
|
||||
NSAutomaticDashSubstitutionEnabled = false;
|
||||
|
||||
# Disable autocorrect adding periods
|
||||
NSAutomaticPeriodSubstitutionEnabled = false;
|
||||
|
||||
# Disable autocorrect smart quotation marks
|
||||
NSAutomaticQuoteSubstitutionEnabled = false;
|
||||
|
||||
# Disable autocorrect spellcheck
|
||||
NSAutomaticSpellingCorrectionEnabled = false;
|
||||
};
|
||||
|
||||
# Disable "Are you sure you want to open" dialog
|
||||
LaunchServices.LSQuarantine = false;
|
||||
|
||||
# Disable trackpad tap to click
|
||||
trackpad.Clicking = false;
|
||||
|
||||
# Where to save screenshots
|
||||
screencapture.location = "~/Downloads";
|
||||
|
||||
CustomUserPreferences = {
|
||||
# Disable disk image verification
|
||||
"com.apple.frameworks.diskimages" = {
|
||||
skip-verify = true;
|
||||
skip-verify-locked = true;
|
||||
skip-verify-remote = true;
|
||||
};
|
||||
# Require password immediately after screen saver begins
|
||||
"com.apple.screensaver" = {
|
||||
askForPassword = 1;
|
||||
askForPasswordDelay = 0;
|
||||
};
|
||||
};
|
||||
|
||||
CustomSystemPreferences = {
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
# Settings that don't have an option in nix-darwin
|
||||
activationScripts.postActivation.text = ''
|
||||
echo "Allow apps from anywhere"
|
||||
SPCTL=$(spctl --status)
|
||||
if ! [ "$SPCTL" = "assessments disabled" ]; then
|
||||
sudo spctl --master-disable
|
||||
fi
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.presets.services.user;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.presets.services.user.enable = lib.mkEnableOption "macoS user settings";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users."${config.user}" = {
|
||||
# macOS user
|
||||
home = config.homePath;
|
||||
uid = 502;
|
||||
# shell = pkgs.fish; # Default shell
|
||||
};
|
||||
# This might fix the shell issues
|
||||
users.knownUsers = [ config.user ];
|
||||
|
||||
};
|
||||
}
|
26
platforms/nix-darwin/modules/nmasur/profiles/base.nix
Normal file
26
platforms/nix-darwin/modules/nmasur/profiles/base.nix
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.profiles.base;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.profiles.base.enable = lib.mkEnableOption "base macOS config";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
homebrew.brews = lib.mkDefault [
|
||||
"trash" # Delete files and folders to trash instead of rm
|
||||
];
|
||||
homebrew.casks = lib.mkDefault [
|
||||
"scroll-reverser" # Different scroll style for mouse vs. trackpad
|
||||
"notunes" # Don't launch Apple Music with the play button
|
||||
];
|
||||
|
||||
};
|
||||
}
|
22
platforms/nix-darwin/modules/nmasur/profiles/extra.nix
Normal file
22
platforms/nix-darwin/modules/nmasur/profiles/extra.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.profiles.gaming;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.profiles.gaming.enable = lib.mkEnableOption "extra config for macOS";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
homebrew.casks = lib.mkDefault [
|
||||
"keybase" # GUI on Nix not available for macOS
|
||||
];
|
||||
|
||||
};
|
||||
}
|
23
platforms/nix-darwin/modules/nmasur/profiles/gaming.nix
Normal file
23
platforms/nix-darwin/modules/nmasur/profiles/gaming.nix
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.profiles.gaming;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.profiles.gaming.enable = lib.mkEnableOption "gaming config for macOS";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
homebrew.casks = lib.mkDefault [
|
||||
"steam" # Not packaged for Nixon macOS
|
||||
"epic-games" # Not packaged for Nix
|
||||
];
|
||||
|
||||
};
|
||||
}
|
24
platforms/nix-darwin/modules/nmasur/profiles/work.nix
Normal file
24
platforms/nix-darwin/modules/nmasur/profiles/work.nix
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.nmasur.profiles.work;
|
||||
in
|
||||
|
||||
{
|
||||
|
||||
options.nmasur.profiles.work.enable = lib.mkEnableOption "work machine";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
homebrew.casks = [
|
||||
"1password" # 1Password will not launch from Nix on macOS
|
||||
# "gitify" # Git notifications in menu bar (downgrade manually from 4.6.1)
|
||||
# "logitech-g-hub" # Mouse and keyboard management
|
||||
"logitune" # Logitech webcam firmware
|
||||
"meetingbar" # Show meetings in menu bar
|
||||
];
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user