From d1f446410a44624e136a8c168c5ef6422a033275 Mon Sep 17 00:00:00 2001 From: Dennis Date: Sat, 6 Dec 2025 15:16:21 +0100 Subject: [PATCH] modularizes config --- flake.nix | 6 + home/darwin.nix | 10 +- hosts/dnsc-air/default.nix | 219 +++++------------------------------ modules/base/default.nix | 59 ++++++++++ modules/homebrew/default.nix | 42 +++++++ modules/macos/default.nix | 59 ++++++++++ modules/nvim/default.nix | 23 +++- 7 files changed, 229 insertions(+), 189 deletions(-) create mode 100644 modules/base/default.nix create mode 100644 modules/homebrew/default.nix create mode 100644 modules/macos/default.nix diff --git a/flake.nix b/flake.nix index 0255748..632eddc 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,12 @@ inherit (self) outputs; in { + # Custom nixosModules + nixosModules.base = import ./modules/base; + nixosModules.macos = import ./modules/macos; + nixosModules.homebrew = import ./modules/homebrew; + nixosModules.aerospace = import ./modules/aerospace; + nixosConfigurations.dnsc-machine = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs outputs; }; diff --git a/home/darwin.nix b/home/darwin.nix index 2683367..6dbcce5 100644 --- a/home/darwin.nix +++ b/home/darwin.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, ... }: { home.username = "dennis"; @@ -10,6 +10,14 @@ GOPATH = "$HOME/go"; }; + home.packages = with pkgs; [ + yt-dlp + fnm + devenv + zellij + zellij-switch + ]; + xdg.enable = true; imports = [ diff --git a/hosts/dnsc-air/default.nix b/hosts/dnsc-air/default.nix index 6dcb840..80efe4e 100644 --- a/hosts/dnsc-air/default.nix +++ b/hosts/dnsc-air/default.nix @@ -1,206 +1,64 @@ { inputs, outputs, - _lib, - _config, + lib, pkgs, ... }: { imports = [ inputs.home-manager.darwinModules.home-manager - ../../modules/aerospace + outputs.nixosModules.base + outputs.nixosModules.macos + outputs.nixosModules.homebrew + outputs.nixosModules.aerospace ]; - # Setting the user + # Device & user-specific settings networking.hostName = "dnsc-air"; networking.computerName = "dnsc-air"; - + system.defaults.smb.NetBIOSName = "dnsc-air"; users.users."dennis" = { home = "/Users/dennis"; description = "Dennis Schoepf"; }; - nix.settings.trusted-users = [ "dennis" ]; - nixpkgs = { - config = { - allowUnfree = true; - allowUnsupportedSystem = true; - }; - overlays = [ - inputs.zellij-switch.overlays.default - ]; - }; - - # System Packages - environment.systemPackages = with pkgs; [ - git - btop - fish - ripgrep - fzf - fd - sd - bat - neovim - just - tldr - fortune - stylua - typescript-language-server - vscode-langservers-extracted - astro-language-server - tailwindcss-language-server - lua-language-server - prettierd - eslint_d - atuin - nil - shellcheck - lazygit - ffmpeg - yt-dlp - zoxide - sqlite - tree-sitter - rsync - fnm - imagemagick - restic - devenv - zellij - zellij-switch + # Device specific overlays + # Overlays for all devices are defined + # in modules/default.nix + nixpkgs.overlays = [ + inputs.zellij-switch.overlays.default ]; - # Homebrew - nix-homebrew = { - enable = true; - # enableRosetta = true; - user = "dennis"; - autoMigrate = true; + # System Packages + environment.systemPackages = lib.mkAfter (with pkgs; [ ]); + + # Install additional homebrew apps + homebrew.masApps = { + Bitwarden = 1352778147; + "Wipr 2" = 1662217862; + "Yesterday For Old Reddit" = 1603279883; + "Final Cut Pro" = 424389933; }; - homebrew = { - user = "dennis"; - enable = true; + homebrew.brews = lib.mkAfter ([ + "harfbuzz" + "openexr" + "openjph" + "p11-kit" + "ca-certificates" + "gettext" + ]); - onActivation = { - autoUpdate = true; - upgrade = true; - cleanup = "zap"; - }; - - taps = [ - "homebrew/services" - "d12frosted/emacs-plus" - ]; - - masApps = { - Bitwarden = 1352778147; - "Wipr 2" = 1662217862; - "Yesterday For Old Reddit" = 1603279883; - "Final Cut Pro" = 424389933; - }; - - brews = [ - "harfbuzz" - "openexr" - "openjph" - "p11-kit" - "mas" - "go" - "ca-certificates" - "gettext" - ]; - - casks = [ - "chromium" - "font-victor-mono" - "font-victor-mono-nerd-font" - "vlc" - "wezterm" - "ghostty" - "hiddenbar" - "eurkey" - "karabiner-elements" - "wezterm" - "cyberduck" - "caffeine" - "tailscale-app" - "raycast" - "spotify" - "zen" - ]; - }; + homebrew.casks = lib.mkAfter ([ + "cyberduck" + ]); # Shells environment.shells = [ pkgs.fish ]; - programs.direnv.enable = true; - # System settings - system = { - primaryUser = "dennis"; - stateVersion = 5; - activationScripts.postActivation.text = '' - /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u - ''; - - defaults = { - smb.NetBIOSName = "dnsc-air"; - - NSGlobalDomain."com.apple.swipescrolldirection" = false; - - dock = { - autohide = true; - autohide-delay = 0.01; - autohide-time-modifier = 0.01; - expose-group-apps = true; - launchanim = false; - minimize-to-application = true; - orientation = "right"; - show-recents = false; - persistent-apps = [ - "/Applications/Zen.app" - "/Applications/WezTerm.app" - "/System/Applications/System Settings.app/" - ]; - persistent-others = [ - "/Users/dennis/Downloads" - ]; - }; - - finder = { - AppleShowAllExtensions = true; - CreateDesktop = false; - FXEnableExtensionChangeWarning = false; - FXPreferredViewStyle = "clmv"; - ShowPathbar = true; - ShowStatusBar = true; - }; - - loginwindow = { - LoginwindowText = "λ dnsc-air (powered by nix-darwin)"; - }; - - menuExtraClock = { - Show24Hour = true; - ShowDate = 0; - }; - - screencapture = { - location = "/Users/dennis/Downloads"; - target = "file"; - }; - - spaces.spans-displays = false; - }; - }; - - # Add ability to used TouchID for sudo authentication - security.pam.services.sudo_local.touchIdAuth = true; - # Home Manager Setup home-manager = { extraSpecialArgs = { inherit inputs outputs; }; @@ -210,17 +68,4 @@ dennis = import ../../home/darwin.nix; }; }; - - # Nix settings - # Enable new Nix CLI and flakes - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - - nix.package = pkgs.nix; - nix.gc = { - automatic = true; - options = "--delete-older-than 1w"; - }; } diff --git a/modules/base/default.nix b/modules/base/default.nix new file mode 100644 index 0000000..a06bdda --- /dev/null +++ b/modules/base/default.nix @@ -0,0 +1,59 @@ +{ + pkgs, + inputs, + ... +}: + +{ + nix = { + channel.enable = false; + package = pkgs.nix; + nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; + settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + }; + gc = { + automatic = true; + dates = "weekly"; + options = "delete-older-than 7d"; + persistent = false; + }; + optimise = { + automatic = true; + dates = [ "weekly" ]; + }; + }; + + nixpkgs = { + config = { + allowUnfree = true; + allowUnsupportedSystem = true; + }; + }; + + environment.systemPackages = with pkgs; [ + git + btop + fish + ripgrep + fzf + fd + sd + bat + neovim + just + tldr + fortune + ffmpeg + zoxide + sqlite + rsync + restic + imagemagick + sqlite + fortune + ]; +} diff --git a/modules/homebrew/default.nix b/modules/homebrew/default.nix new file mode 100644 index 0000000..db33b15 --- /dev/null +++ b/modules/homebrew/default.nix @@ -0,0 +1,42 @@ +{ + nix-homebrew = { + enable = true; + user = "dennis"; + autoMigrate = true; + }; + + homebrew = { + user = "dennis"; + enable = true; + + onActivation = { + autoUpdate = true; + upgrade = true; + cleanup = "zap"; + }; + + taps = [ + "homebrew/services" + ]; + + brews = [ + "go" + "mas" + ]; + + casks = [ + "font-victor-mono" + "font-victor-mono-nerd-font" + "vlc" + "ghostty" + "hiddenbar" + "eurkey" + "karabiner-elements" + "caffeine" + "raycast" + "spotify" + "zen" + "tailscale-app" + ]; + }; +} diff --git a/modules/macos/default.nix b/modules/macos/default.nix new file mode 100644 index 0000000..0fd4045 --- /dev/null +++ b/modules/macos/default.nix @@ -0,0 +1,59 @@ +{ + system = { + primaryUser = "dennis"; + stateVersion = 5; + activationScripts.postActivation.text = '' + /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u + ''; + + defaults = { + NSGlobalDomain."com.apple.swipescrolldirection" = false; + + dock = { + autohide = true; + autohide-delay = 0.01; + autohide-time-modifier = 0.01; + expose-group-apps = true; + launchanim = false; + minimize-to-application = true; + orientation = "right"; + show-recents = false; + persistent-apps = [ + "/Applications/Zen.app" + "/Applications/Ghostty.app" + "/System/Applications/System Settings.app/" + ]; + persistent-others = [ + "/Users/dennis/Downloads" + ]; + }; + + finder = { + AppleShowAllExtensions = true; + CreateDesktop = false; + FXEnableExtensionChangeWarning = false; + FXPreferredViewStyle = "clmv"; + ShowPathbar = true; + ShowStatusBar = true; + }; + + loginwindow = { + LoginwindowText = "(λ) powered by nix-darwin"; + }; + + menuExtraClock = { + Show24Hour = true; + ShowDate = 0; + }; + + screencapture = { + location = "/Users/dennis/Downloads"; + target = "file"; + }; + + spaces.spans-displays = false; + }; + }; + + security.pam.services.sudo_local.touchIdAuth = true; +} diff --git a/modules/nvim/default.nix b/modules/nvim/default.nix index 1e04d15..205cd65 100644 --- a/modules/nvim/default.nix +++ b/modules/nvim/default.nix @@ -1,8 +1,29 @@ -{ config, ... }: +{ + pkgs, + config, + lib, + ... +}: { xdg.configFile."nvim" = { # mkOutOfStoreSymlink needs an absolute path, otherwise it does not work: https://github.com/nix-community/home-manager/issues/676#issuecomment-1595795685 source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/dev/nix-config/modules/nvim/config"; }; + + home.packages = lib.mkAfter ( + with pkgs; + [ + stylua + typescript-language-server + vscode-langservers-extracted + astro-language-server + tailwindcss-language-server + lua-language-server + prettierd + eslint_d + nil + tree-sitter + ] + ); }