From e6167c2f864556ba98232a97edb02d0771ef22ca Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Tue, 16 Dec 2025 19:53:10 +0100 Subject: [PATCH] improved system setup --- home/personal.nix | 4 ++ hosts/personal/default.nix | 128 +-------------------------------- hosts/work/default.nix | 129 +--------------------------------- modules/darwin/system.nix | 140 +++++++++++++++++++++++++++++++++++++ modules/home/apps.nix | 9 +++ modules/home/git.nix | 56 ++++++++------- 6 files changed, 184 insertions(+), 282 deletions(-) create mode 100644 modules/darwin/system.nix diff --git a/home/personal.nix b/home/personal.nix index 60eb787..182e469 100644 --- a/home/personal.nix +++ b/home/personal.nix @@ -70,6 +70,10 @@ username = "morten"; passwordFile = "/Users/alice/Library/Application Support/jellyfin-tui/pass"; }; + + zen-browser = { + enable = true; + }; }; # Personal-only packages diff --git a/hosts/personal/default.nix b/hosts/personal/default.nix index c9fde21..a117d8d 100644 --- a/hosts/personal/default.nix +++ b/hosts/personal/default.nix @@ -11,136 +11,10 @@ }: { # Import darwin modules imports = [ + ../../modules/darwin/system.nix ../../modules/darwin/homebrew.nix ]; - # Nix configuration - nix = { - settings = { - # Enable flakes and new nix command - experimental-features = ["nix-command" "flakes"]; - # Avoid unwanted garbage collection when using nix-direnv - keep-outputs = true; - keep-derivations = true; - }; - }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - system = { - primaryUser = username; - keyboard = { - enableKeyMapping = true; - remapCapsLockToControl = true; - }; - startup.chime = false; - - defaults = { - spaces.spans-displays = false; - loginwindow = { - GuestEnabled = false; - DisableConsoleAccess = true; - }; - - - dock = { - autohide = true; - autohide-delay = 0.0; - autohide-time-modifier = 0.0; - orientation = "bottom"; - dashboard-in-overlay = true; - largesize = 85; - tilesize = 50; - magnification = true; - launchanim = false; - mru-spaces = false; - show-recents = false; - show-process-indicators = false; - static-only = true; - }; - - finder = { - AppleShowAllExtensions = true; - AppleShowAllFiles = true; - CreateDesktop = false; - FXDefaultSearchScope = "SCcf"; # current folder - QuitMenuItem = true; - }; - - NSGlobalDomain = { - NSAutomaticSpellingCorrectionEnabled = false; - NSAutomaticCapitalizationEnabled = false; - NSAutomaticPeriodSubstitutionEnabled = false; - NSAutomaticDashSubstitutionEnabled = false; - NSAutomaticQuoteSubstitutionEnabled = false; - NSAutomaticWindowAnimationsEnabled = false; - NSDocumentSaveNewDocumentsToCloud = false; - ApplePressAndHoldEnabled = false; - - KeyRepeat = 2; - InitialKeyRepeat = 10; - # Enable subpixel font rendering on non-Apple LCDs - # Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501 - AppleFontSmoothing = 2; - # Finder: show all filename extensions - AppleShowAllExtensions = true; - }; - CustomUserPreferences = { - LaunchServices = { - # Whether to enable quarantine for downloaded applications - LSQuarantine = false; - }; - trackpad = { - Clicking = true; - TrackpadRightClick = true; - }; - "com.apple.systempreferences" = { - # Disable Resume system-wide - NSQuitAlwaysKeepsWindows = false; - }; - "com.apple.desktopservices" = { - # Avoid creating .DS_Store files on network or USB volumes - DSDontWriteNetworkStores = true; - DSDontWriteUSBStores = true; - }; - "com.apple.screensaver" = { - # Require password immediately after sleep or screen saver begins - askForPassword = 1; - askForPasswordDelay = 0; - }; - "com.apple.AdLib" = { - # Don't fucking track me... - allowApplePersonalizedAdvertising = false; - }; - "com.apple.BluetoothAudioAgent" = { - # Increase sound quality for Bluetooth headphones/headsets - "Apple Bitpool Min (editable)" = -40; - }; - "com.apple.dashboard" = { - # Disable Dashboard - mcx-disabled = true; - }; - alf = { - # Enables Firewall - globalstate = 1; - # Enable logging of requests - loggingenabled = 1; - # Drops incoming requests via ICMP such as ping requests - stealthenabled = 1; - }; - }; - }; - }; - - users.users.${username} = { - name = username; - home = "/Users/${username}"; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFaIAP/ZJ7+7jeR44e1yIJjfQAB6MN351LDKJAXVF62P" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILAzuPy7D/54GxMq9Zhz0CUjaDnEQ6RkQ/yqVYl7U55k" - ]; - }; # System-level programs programs = { diff --git a/hosts/work/default.nix b/hosts/work/default.nix index fdcb1cd..0e4805b 100644 --- a/hosts/work/default.nix +++ b/hosts/work/default.nix @@ -11,137 +11,10 @@ }: { # Import darwin modules imports = [ + ../../modules/darwin/system.nix ../../modules/darwin/homebrew.nix ]; - # Nix configuration - nix = { - settings = { - # Enable flakes and new nix command - experimental-features = ["nix-command" "flakes"]; - # Avoid unwanted garbage collection when using nix-direnv - keep-outputs = true; - keep-derivations = true; - }; - }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - system = { - primaryUser = username; - keyboard = { - enableKeyMapping = true; - remapCapsLockToControl = true; - }; - startup.chime = false; - - defaults = { - spaces.spans-displays = false; - loginwindow = { - GuestEnabled = false; - DisableConsoleAccess = true; - }; - - - dock = { - autohide = true; - autohide-delay = 0.0; - autohide-time-modifier = 0.0; - orientation = "bottom"; - dashboard-in-overlay = true; - largesize = 85; - tilesize = 50; - magnification = true; - launchanim = false; - mru-spaces = false; - show-recents = false; - show-process-indicators = false; - static-only = true; - }; - - finder = { - AppleShowAllExtensions = true; - AppleShowAllFiles = true; - CreateDesktop = false; - FXDefaultSearchScope = "SCcf"; # current folder - QuitMenuItem = true; - }; - - NSGlobalDomain = { - NSAutomaticSpellingCorrectionEnabled = false; - NSAutomaticCapitalizationEnabled = false; - NSAutomaticPeriodSubstitutionEnabled = false; - NSAutomaticDashSubstitutionEnabled = false; - NSAutomaticQuoteSubstitutionEnabled = false; - NSAutomaticWindowAnimationsEnabled = false; - NSDocumentSaveNewDocumentsToCloud = false; - ApplePressAndHoldEnabled = false; - - KeyRepeat = 2; - InitialKeyRepeat = 10; - # Enable subpixel font rendering on non-Apple LCDs - # Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501 - AppleFontSmoothing = 2; - # Finder: show all filename extensions - AppleShowAllExtensions = true; - }; - CustomUserPreferences = { - LaunchServices = { - # Whether to enable quarantine for downloaded applications - LSQuarantine = false; - }; - trackpad = { - Clicking = true; - TrackpadRightClick = true; - }; - "com.apple.systempreferences" = { - # Disable Resume system-wide - NSQuitAlwaysKeepsWindows = false; - }; - "com.apple.desktopservices" = { - # Avoid creating .DS_Store files on network or USB volumes - DSDontWriteNetworkStores = true; - DSDontWriteUSBStores = true; - }; - "com.apple.screensaver" = { - # Require password immediately after sleep or screen saver begins - askForPassword = 1; - askForPasswordDelay = 0; - }; - "com.apple.AdLib" = { - # Don't fucking track me... - allowApplePersonalizedAdvertising = false; - }; - "com.apple.BluetoothAudioAgent" = { - # Increase sound quality for Bluetooth headphones/headsets - "Apple Bitpool Min (editable)" = -40; - }; - "com.apple.dashboard" = { - # Disable Dashboard - mcx-disabled = true; - }; - alf = { - # Enables Firewall - globalstate = 1; - # Enable logging of requests - loggingenabled = 1; - # Drops incoming requests via ICMP such as ping requests - stealthenabled = 1; - }; - }; - }; - }; - - users.users.${username} = { - name = username; - home = "/Users/${username}"; - openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFaIAP/ZJ7+7jeR44e1yIJjfQAB6MN351LDKJAXVF62P" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILAzuPy7D/54GxMq9Zhz0CUjaDnEQ6RkQ/yqVYl7U55k" - ]; - }; - # System-level programs programs = { # Enable zsh as it's the default macOS shell diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix new file mode 100644 index 0000000..b4290a2 --- /dev/null +++ b/modules/darwin/system.nix @@ -0,0 +1,140 @@ +# It sets up system-level configuration and integrates with home-manager. +{ + config, + pkgs, + lib, + username, + ... +}: { + # Nix configuration + nix = { + settings = { + # Enable flakes and new nix command + experimental-features = ["nix-command" "flakes"]; + # Avoid unwanted garbage collection when using nix-direnv + keep-outputs = true; + keep-derivations = true; + }; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + system = { + primaryUser = username; + keyboard = { + enableKeyMapping = true; + remapCapsLockToControl = true; + }; + startup.chime = false; + + defaults = { + spaces.spans-displays = false; + loginwindow = { + GuestEnabled = false; + DisableConsoleAccess = true; + }; + + + dock = { + autohide = true; + autohide-delay = 0.0; + autohide-time-modifier = 0.0; + orientation = "bottom"; + dashboard-in-overlay = true; + largesize = 85; + tilesize = 50; + magnification = true; + launchanim = false; + mru-spaces = false; + show-recents = false; + show-process-indicators = false; + static-only = true; + }; + + finder = { + AppleShowAllExtensions = true; + AppleShowAllFiles = true; + CreateDesktop = false; + FXDefaultSearchScope = "SCcf"; # current folder + QuitMenuItem = true; + }; + + NSGlobalDomain = { + NSAutomaticSpellingCorrectionEnabled = false; + NSAutomaticCapitalizationEnabled = false; + NSAutomaticPeriodSubstitutionEnabled = false; + NSAutomaticDashSubstitutionEnabled = false; + NSAutomaticQuoteSubstitutionEnabled = false; + NSAutomaticWindowAnimationsEnabled = false; + NSDocumentSaveNewDocumentsToCloud = false; + ApplePressAndHoldEnabled = false; + + KeyRepeat = 2; + InitialKeyRepeat = 10; + # Enable subpixel font rendering on non-Apple LCDs + # Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501 + AppleFontSmoothing = 2; + # Finder: show all filename extensions + AppleShowAllExtensions = true; + }; + CustomUserPreferences = { + LaunchServices = { + # Whether to enable quarantine for downloaded applications + LSQuarantine = false; + }; + trackpad = { + Clicking = true; + TrackpadRightClick = true; + }; + "com.apple.systempreferences" = { + # Disable Resume system-wide + NSQuitAlwaysKeepsWindows = false; + }; + "com.apple.desktopservices" = { + # Avoid creating .DS_Store files on network or USB volumes + DSDontWriteNetworkStores = true; + DSDontWriteUSBStores = true; + }; + "com.apple.screensaver" = { + # Require password immediately after sleep or screen saver begins + askForPassword = 1; + askForPasswordDelay = 0; + }; + "com.apple.AdLib" = { + # Don't fucking track me... + allowApplePersonalizedAdvertising = false; + }; + "com.apple.BluetoothAudioAgent" = { + # Increase sound quality for Bluetooth headphones/headsets + "Apple Bitpool Min (editable)" = -40; + }; + "com.apple.dashboard" = { + # Disable Dashboard + mcx-disabled = true; + }; + alf = { + # Enables Firewall + globalstate = 1; + # Enable logging of requests + loggingenabled = 1; + # Drops incoming requests via ICMP such as ping requests + stealthenabled = 1; + }; + }; + }; + }; + + users.users.${username} = { + name = username; + home = "/Users/${username}"; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFaIAP/ZJ7+7jeR44e1yIJjfQAB6MN351LDKJAXVF62P" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILAzuPy7D/54GxMq9Zhz0CUjaDnEQ6RkQ/yqVYl7U55k" + ]; + }; + + # Used for backwards compatibility, read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 5; +} diff --git a/modules/home/apps.nix b/modules/home/apps.nix index 846fc70..f9b402e 100644 --- a/modules/home/apps.nix +++ b/modules/home/apps.nix @@ -21,6 +21,15 @@ in { }; }; + zen-browser = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable Zen Browser configuration (macOS only)"; + }; + }; + + jellyfin-tui = { enable = lib.mkOption { type = lib.types.bool; diff --git a/modules/home/git.nix b/modules/home/git.nix index f55f939..b8fe3fe 100644 --- a/modules/home/git.nix +++ b/modules/home/git.nix @@ -80,18 +80,26 @@ in { programs.git = { enable = true; - # User configuration - userName = cfg.userName; - userEmail = cfg.userEmail; - # Signing configuration with 1Password signing = { key = cfg.signingKey; signByDefault = true; }; - # Extra configuration - extraConfig = { + # Conditional includes for project-specific configurations + includes = map (inc: { + condition = inc.condition; + path = inc.path; + }) cfg.includes; + + # All git settings using the new unified settings option + settings = { + # User configuration + user = { + name = cfg.userName; + email = cfg.userEmail; + }; + # Core settings (pager is set by programs.delta) core = { hooksPath = "/dev/null"; @@ -144,29 +152,23 @@ in { "difftool \"nvimdiff\"" = { cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""; }; - }; - # Aliases - aliases = { - graph = "log --graph --color --pretty=format:\"%C(yellow)%H%C(green)%d%C(reset)%n%x20%cd%n%x20%cn%C(blue)%x20(%ce)%x20%C(cyan)[gpg:%GK%x20%G?]%C(reset)%n%x20%s%n\""; - ll = "log --oneline"; - st = "status -sb"; - cm = "commit -m"; - append = "commit --amend --no-edit"; - sobmodules = "submodule update --init --recursive"; - df = "difftool -t nvimdiff -y"; - last = "log -1 --stat"; - br = "branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate"; - brr = "branch --remote --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate"; - undo = "reset HEAD~1 --mixed"; - unstage = "reset HEAD --"; + # Aliases + alias = { + graph = "log --graph --color --pretty=format:\"%C(yellow)%H%C(green)%d%C(reset)%n%x20%cd%n%x20%cn%C(blue)%x20(%ce)%x20%C(cyan)[gpg:%GK%x20%G?]%C(reset)%n%x20%s%n\""; + ll = "log --oneline"; + st = "status -sb"; + cm = "commit -m"; + append = "commit --amend --no-edit"; + sobmodules = "submodule update --init --recursive"; + df = "difftool -t nvimdiff -y"; + last = "log -1 --stat"; + br = "branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate"; + brr = "branch --remote --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate"; + undo = "reset HEAD~1 --mixed"; + unstage = "reset HEAD --"; + }; }; - - # Conditional includes for project-specific configurations - includes = map (inc: { - condition = inc.condition; - path = inc.path; - }) cfg.includes; }; }; } \ No newline at end of file