From 07c39081bba3b6ae19adb952c5f6eb6afb24ee3f Mon Sep 17 00:00:00 2001 From: Christoph Schmatzler Date: Thu, 11 Dec 2025 20:07:46 +0000 Subject: [PATCH] refactor more --- hosts/chidi/default.nix | 42 +++++++++ hosts/jason/default.nix | 47 +++++++++- hosts/michael/default.nix | 17 ++-- hosts/tahani/default.nix | 26 +++--- modules/darwin-home.nix | 22 ----- modules/darwin-packages.nix | 10 --- modules/darwin.nix | 52 +---------- modules/{darwin-dock.nix => dock.nix} | 17 +++- modules/{darwin-ghostty.nix => ghostty.nix} | 0 modules/home.nix | 36 +++----- modules/{darwin-homebrew.nix => homebrew.nix} | 0 modules/nixos-packages.nix | 6 -- modules/nixos.nix | 22 +---- modules/packages.nix | 88 +++++++++++-------- .../{darwin-wallpaper.nix => wallpaper.nix} | 0 15 files changed, 190 insertions(+), 195 deletions(-) delete mode 100644 modules/darwin-home.nix delete mode 100644 modules/darwin-packages.nix rename modules/{darwin-dock.nix => dock.nix} (77%) rename modules/{darwin-ghostty.nix => ghostty.nix} (100%) rename modules/{darwin-homebrew.nix => homebrew.nix} (100%) delete mode 100644 modules/nixos-packages.nix rename modules/{darwin-wallpaper.nix => wallpaper.nix} (100%) diff --git a/hosts/chidi/default.nix b/hosts/chidi/default.nix index 51ea7f7..ebb4d4c 100644 --- a/hosts/chidi/default.nix +++ b/hosts/chidi/default.nix @@ -1,10 +1,20 @@ { + inputs, pkgs, user, + constants, ... }: { imports = [ + ../../modules/core.nix ../../modules/darwin.nix + ../../modules/darwin-syncthing.nix + ../../modules/darwin-system.nix + ../../modules/dock.nix + ../../modules/homebrew.nix + ../../modules/syncthing.nix + ../../modules/tailscale.nix + inputs.sops-nix.darwinModules.sops ]; networking.hostName = "chidi"; @@ -18,6 +28,38 @@ }; home-manager.users.${user} = { + pkgs, + lib, + ... + }: { + _module.args = {inherit user constants inputs;}; + imports = [ + inputs.nixvim.homeModules.nixvim + ../../modules/atuin.nix + ../../modules/bash.nix + ../../modules/bat.nix + ../../modules/direnv.nix + ../../modules/eza.nix + ../../modules/fish.nix + ../../modules/fzf.nix + ../../modules/ghostty.nix + ../../modules/git.nix + ../../modules/home.nix + ../../modules/jjui.nix + ../../modules/jujutsu.nix + ../../modules/lazygit.nix + ../../modules/mise.nix + ../../modules/neovim + ../../modules/opencode.nix + ../../modules/ripgrep.nix + ../../modules/ssh.nix + ../../modules/starship.nix + ../../modules/zellij.nix + ../../modules/zk.nix + ../../modules/zoxide.nix + ../../modules/zsh.nix + ]; + fonts.fontconfig.enable = true; programs.git.settings.user.email = "christoph@tuist.dev"; }; diff --git a/hosts/jason/default.nix b/hosts/jason/default.nix index 5c534a9..cafed46 100644 --- a/hosts/jason/default.nix +++ b/hosts/jason/default.nix @@ -1,6 +1,18 @@ -{user, ...}: { +{ + inputs, + user, + ... +}: { imports = [ + ../../modules/core.nix ../../modules/darwin.nix + ../../modules/darwin-syncthing.nix + ../../modules/darwin-system.nix + ../../modules/dock.nix + ../../modules/homebrew.nix + ../../modules/syncthing.nix + ../../modules/tailscale.nix + inputs.sops-nix.darwinModules.sops ]; networking.hostName = "jason"; @@ -31,6 +43,39 @@ }; home-manager.users.${user} = { + pkgs, + lib, + constants, + ... + }: { + _module.args = {inherit user constants inputs;}; + imports = [ + inputs.nixvim.homeModules.nixvim + ../../modules/atuin.nix + ../../modules/bash.nix + ../../modules/bat.nix + ../../modules/direnv.nix + ../../modules/eza.nix + ../../modules/fish.nix + ../../modules/fzf.nix + ../../modules/ghostty.nix + ../../modules/git.nix + ../../modules/home.nix + ../../modules/jjui.nix + ../../modules/jujutsu.nix + ../../modules/lazygit.nix + ../../modules/mise.nix + ../../modules/neovim + ../../modules/opencode.nix + ../../modules/ripgrep.nix + ../../modules/ssh.nix + ../../modules/starship.nix + ../../modules/zellij.nix + ../../modules/zk.nix + ../../modules/zoxide.nix + ../../modules/zsh.nix + ]; + fonts.fontconfig.enable = true; programs.git.settings.user.email = "christoph@schmatzler.com"; }; } diff --git a/hosts/michael/default.nix b/hosts/michael/default.nix index 5debcdd..3042ca0 100644 --- a/hosts/michael/default.nix +++ b/hosts/michael/default.nix @@ -12,12 +12,19 @@ (modulesPath + "/profiles/qemu-guest.nix") ./disk-config.nix ./hardware-configuration.nix + ../../modules/core.nix ../../modules/nixos.nix inputs.disko.nixosModules.disko ]; home-manager.users.${user} = { + pkgs, + lib, + ... + }: { + _module.args = {inherit user constants inputs;}; imports = [ + inputs.nixvim.homeModules.nixvim ../../modules/bash.nix ../../modules/bat.nix ../../modules/direnv.nix @@ -25,6 +32,7 @@ ../../modules/fish.nix ../../modules/fzf.nix ../../modules/git.nix + ../../modules/home.nix ../../modules/jjui.nix ../../modules/jujutsu.nix ../../modules/lazygit.nix @@ -34,15 +42,6 @@ ../../modules/starship.nix ../../modules/zoxide.nix ]; - - programs.home-manager.enable = true; - - home = { - packages = - (pkgs.callPackage ../../modules/packages.nix {inherit inputs;}) - ++ (pkgs.callPackage ../../modules/nixos-packages.nix {}); - stateVersion = constants.stateVersions.homeManager; - }; }; networking.firewall.allowedTCPPorts = [80 443]; diff --git a/hosts/tahani/default.nix b/hosts/tahani/default.nix index 770fec4..71313eb 100644 --- a/hosts/tahani/default.nix +++ b/hosts/tahani/default.nix @@ -8,12 +8,21 @@ ... }: { imports = [ + ../../modules/core.nix ../../modules/nixos.nix ../../modules/syncthing.nix + ../../modules/tailscale.nix + inputs.sops-nix.nixosModules.sops ]; home-manager.users.${user} = { + pkgs, + lib, + ... + }: { + _module.args = {inherit user constants inputs;}; imports = [ + inputs.nixvim.homeModules.nixvim ../../modules/atuin.nix ../../modules/bash.nix ../../modules/bat.nix @@ -22,6 +31,7 @@ ../../modules/fish.nix ../../modules/fzf.nix ../../modules/git.nix + ../../modules/home.nix ../../modules/jjui.nix ../../modules/jujutsu.nix ../../modules/lazygit.nix @@ -37,18 +47,10 @@ ../../modules/zsh.nix ]; - programs.home-manager.enable = true; - - home = { - packages = - (pkgs.callPackage ../../modules/packages.nix {inherit inputs;}) - ++ (pkgs.callPackage ../../modules/nixos-packages.nix {}) - ++ [ - inputs.beads.packages.${pkgs.system}.default - inputs.nix-ai-tools.packages.${pkgs.system}.amp - ]; - stateVersion = constants.stateVersions.homeManager; - }; + home.packages = [ + inputs.beads.packages.${pkgs.system}.default + inputs.nix-ai-tools.packages.${pkgs.system}.amp + ]; programs.git.settings.user.email = "christoph@schmatzler.com"; }; diff --git a/modules/darwin-home.nix b/modules/darwin-home.nix deleted file mode 100644 index 72775b8..0000000 --- a/modules/darwin-home.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ - pkgs, - lib, - ... -}: let - setWallpaperScript = import ./darwin-wallpaper.nix {inherit pkgs;}; -in { - imports = [ - ./darwin-ghostty.nix - ]; - - home = { - packages = pkgs.callPackage ./darwin-packages.nix {}; - activation = { - "setWallpaper" = - lib.hm.dag.entryAfter ["revealHomeLibraryDirectory"] '' - echo "[+] Setting wallpaper" - ${setWallpaperScript}/bin/set-wallpaper-script - ''; - }; - }; -} diff --git a/modules/darwin-packages.nix b/modules/darwin-packages.nix deleted file mode 100644 index 04923a9..0000000 --- a/modules/darwin-packages.nix +++ /dev/null @@ -1,10 +0,0 @@ -{pkgs}: -with pkgs; [ - _1password-gui - dockutil - mas - raycast - tailscale - # whatsapp-for-mac - xcodes -] diff --git a/modules/darwin.nix b/modules/darwin.nix index 12dc474..d02f691 100644 --- a/modules/darwin.nix +++ b/modules/darwin.nix @@ -1,22 +1,9 @@ { - config, constants, - inputs, pkgs, user, ... }: { - imports = [ - ./core.nix - ./syncthing.nix - ./tailscale.nix - ./darwin-dock.nix - ./darwin-homebrew.nix - ./darwin-syncthing.nix - ./darwin-system.nix - inputs.sops-nix.darwinModules.sops - ]; - system = { primaryUser = user; stateVersion = constants.stateVersions.darwin; @@ -38,42 +25,5 @@ shell = pkgs.fish; }; - home-manager = { - useGlobalPkgs = true; - users.${user} = { - pkgs, - config, - lib, - ... - }: { - _module.args = {inherit user constants inputs;}; - imports = [ - inputs.nixvim.homeModules.nixvim - ./home.nix - ./darwin-home.nix - ]; - fonts.fontconfig.enable = true; - }; - }; - - local = { - dock = { - enable = true; - username = user; - entries = [ - {path = "/Applications/Helium.app/";} - {path = "${config.users.users.${user}.home}/Applications/Home Manager Apps/Ghostty.app/";} - {path = "/System/Applications/Calendar.app/";} - {path = "/System/Applications/Mail.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"; - } - ]; - }; - }; + home-manager.useGlobalPkgs = true; } diff --git a/modules/darwin-dock.nix b/modules/dock.nix similarity index 77% rename from modules/darwin-dock.nix rename to modules/dock.nix index 7b4bc77..f5ff66d 100644 --- a/modules/darwin-dock.nix +++ b/modules/dock.nix @@ -2,6 +2,7 @@ config, pkgs, lib, + user, ... }: with lib; let @@ -36,13 +37,27 @@ in { }; }; }); - readOnly = true; + default = [ + {path = "/Applications/Helium.app/";} + {path = "${config.users.users.${user}.home}/Applications/Home Manager Apps/Ghostty.app/";} + {path = "/System/Applications/Calendar.app/";} + {path = "/System/Applications/Mail.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"; + } + ]; }; username = mkOption { description = "Username to apply the dock settings to"; type = types.str; + default = user; }; }; }; diff --git a/modules/darwin-ghostty.nix b/modules/ghostty.nix similarity index 100% rename from modules/darwin-ghostty.nix rename to modules/ghostty.nix diff --git a/modules/home.nix b/modules/home.nix index 933c76c..7185084 100644 --- a/modules/home.nix +++ b/modules/home.nix @@ -1,37 +1,23 @@ { pkgs, + lib, constants, inputs, ... -}: { - imports = [ - ./atuin.nix - ./bash.nix - ./bat.nix - ./direnv.nix - ./eza.nix - ./fish.nix - ./fzf.nix - ./git.nix - ./jjui.nix - ./jujutsu.nix - ./lazygit.nix - ./mise.nix - ./neovim - ./opencode.nix - ./ripgrep.nix - ./ssh.nix - ./starship.nix - ./zellij.nix - ./zk.nix - ./zoxide.nix - ./zsh.nix - ]; - +}: let + setWallpaperScript = import ./wallpaper.nix {inherit pkgs;}; +in { programs.home-manager.enable = true; home = { packages = pkgs.callPackage ./packages.nix {inherit inputs;}; stateVersion = constants.stateVersions.homeManager; + activation = lib.mkIf pkgs.stdenv.isDarwin { + "setWallpaper" = + lib.hm.dag.entryAfter ["revealHomeLibraryDirectory"] '' + echo "[+] Setting wallpaper" + ${setWallpaperScript}/bin/set-wallpaper-script + ''; + }; }; } diff --git a/modules/darwin-homebrew.nix b/modules/homebrew.nix similarity index 100% rename from modules/darwin-homebrew.nix rename to modules/homebrew.nix diff --git a/modules/nixos-packages.nix b/modules/nixos-packages.nix deleted file mode 100644 index 3601623..0000000 --- a/modules/nixos-packages.nix +++ /dev/null @@ -1,6 +0,0 @@ -{pkgs}: -with pkgs; [ - gcc15 - lm_sensors - ghostty.terminfo -] diff --git a/modules/nixos.nix b/modules/nixos.nix index 753e26b..914d120 100644 --- a/modules/nixos.nix +++ b/modules/nixos.nix @@ -1,16 +1,9 @@ { pkgs, - inputs, user, constants, ... }: { - imports = [ - ./core.nix - ./tailscale.nix - inputs.sops-nix.nixosModules.sops - ]; - security.sudo.enable = true; system.stateVersion = constants.stateVersions.nixos; @@ -61,18 +54,5 @@ }; }; - home-manager = { - useGlobalPkgs = true; - users.${user} = { - pkgs, - config, - lib, - ... - }: { - _module.args = {inherit user constants inputs;}; - imports = [ - inputs.nixvim.homeModules.nixvim - ]; - }; - }; + home-manager.useGlobalPkgs = true; } diff --git a/modules/packages.nix b/modules/packages.nix index 1bca5ca..beb2dd8 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -3,40 +3,54 @@ inputs, ... }: -with pkgs; [ - (callPackage ./open-project.nix {}) - age - alejandra - ast-grep - bun - delta - devenv - dig - docker - docker-compose - fastfetch - fd - gh - git - gnumake - gnupg - hledger - htop - hyperfine - jq - killall - lsof - nurl - openssh - postgresql_17 - sd - sops - sqlite - tokei - tree - tree-sitter - unzip - vivid - ov - zip -] +with pkgs; + [ + (callPackage ./open-project.nix {}) + age + alejandra + ast-grep + bun + delta + devenv + dig + docker + docker-compose + fastfetch + fd + gh + git + gnumake + gnupg + hledger + htop + hyperfine + jq + killall + lsof + nurl + openssh + postgresql_17 + sd + sops + sqlite + tokei + tree + tree-sitter + unzip + vivid + ov + zip + ] + ++ lib.optionals stdenv.isDarwin [ + _1password-gui + dockutil + mas + raycast + tailscale + xcodes + ] + ++ lib.optionals stdenv.isLinux [ + gcc15 + lm_sensors + ghostty.terminfo + ] diff --git a/modules/darwin-wallpaper.nix b/modules/wallpaper.nix similarity index 100% rename from modules/darwin-wallpaper.nix rename to modules/wallpaper.nix