From 81c5a22fd95da8948f1682e995e835d20e1b6539 Mon Sep 17 00:00:00 2001 From: Kris Williams <115474+kriswill@users.noreply.github.com> Date: Sun, 24 May 2026 19:25:21 -0700 Subject: [PATCH 1/5] Refactor to flake-parts + import-tree (Dendritic pattern) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the bespoke flake plumbing (autoImport/mkDarwin/mkHomeManager) with a flake-parts top-level configuration where every file under ./modules is a flake-parts module auto-imported by import-tree. - flake.nix: minimal entry point — mkFlake (import-tree ./modules) - Each feature is flake.modules.{darwin,homeManager}.; per-feature kriswill..enable toggles preserved verbatim - modules/darwin.nix realises configurations.darwin into darwinConfigurations + toplevel checks; modules/home.nix wires home-manager as a darwin module - Hosts move to modules/hosts/*.nix (configurations.darwin.) - Pure helpers (mkProgramOption, kanagawa) kept in top-level lib/ (outside ./modules so import-tree skips them); yazi theme assets moved to _themes/ - Remove autoImport shims, old hosts/, dead overlays/default.nix Verified: all three darwinConfigurations build (cache-hit parity with main), kitten builds, nix fmt + deadnix clean, per-host toggles eval correctly. --- flake.lock | 50 +++ flake.nix | 61 +--- hosts/SOC-Kris-Williams/default.nix | 8 - hosts/k/default.nix | 6 - hosts/mini/default.nix | 5 - lib/default.nix | 70 +--- modules/darwin.nix | 45 +++ modules/darwin/alias-en0.nix | 22 ++ modules/darwin/core.nix | 87 +++++ modules/darwin/core/default.nix | 4 - modules/darwin/core/programs/default.nix | 4 - modules/darwin/core/programs/nh/default.nix | 21 -- modules/darwin/default.nix | 4 - modules/darwin/dnsmasq.nix | 18 + modules/darwin/ghostty.nix | 15 + modules/darwin/homebrew.nix | 47 +++ modules/darwin/macos-defaults.nix | 17 + modules/darwin/mixins/alias-en0.nix | 18 - modules/darwin/mixins/default.nix | 87 ----- modules/darwin/mixins/dnsmasq.nix | 14 - modules/darwin/mixins/ghostty.nix | 11 - modules/darwin/mixins/homebrew.nix | 43 --- modules/darwin/mixins/macos-defaults.nix | 13 - modules/darwin/nh.nix | 25 ++ modules/dev.nix | 23 ++ modules/flake-parts.nix | 9 + modules/home-manager/brave.nix | 36 +- modules/home-manager/core.nix | 184 +++++++++++ modules/home-manager/default.nix | 178 ---------- modules/home-manager/diffnav.nix | 108 +++--- modules/home-manager/direnv-nom.nix | 180 +++++----- modules/home-manager/fastfetch/default.nix | 308 +++++++++--------- modules/home-manager/firefox/default.nix | 166 +++++----- modules/home-manager/ghostty/default.nix | 44 +-- modules/home-manager/git.nix | 178 +++++----- modules/home-manager/glow/default.nix | 64 ++-- modules/home-manager/karabiner/default.nix | 36 +- modules/home-manager/kitty/default.nix | 64 ++-- modules/home-manager/neovide/default.nix | 32 +- modules/home-manager/neovim/default.nix | 208 ++++++------ modules/home-manager/oksh/default.nix | 60 ++-- .../home-manager/podman-desktop/default.nix | 44 +-- modules/home-manager/ssh.nix | 64 ++-- modules/home-manager/starship.nix | 26 +- modules/home-manager/tmux/default.nix | 54 +-- modules/home-manager/vscode.nix | 32 +- .../kanagawa-dragon/default.nix | 0 .../kanagawa-dragon/flavor.toml | 0 .../kanagawa-dragon/tmtheme.xml | 0 modules/home-manager/yazi/default.nix | 116 +++---- modules/home-manager/zk/default.nix | 36 +- modules/home-manager/zsh/default.nix | 88 ++--- modules/home.nix | 37 +++ modules/hosts/SOC-Kris-Williams.nix | 19 ++ modules/hosts/k.nix | 17 + modules/hosts/mini.nix | 15 + modules/lib.nix | 13 + modules/overlays.nix | 9 + modules/packages.nix | 12 + overlays/default.nix | 5 - 60 files changed, 1684 insertions(+), 1476 deletions(-) delete mode 100644 hosts/SOC-Kris-Williams/default.nix delete mode 100644 hosts/k/default.nix delete mode 100644 hosts/mini/default.nix create mode 100644 modules/darwin.nix create mode 100644 modules/darwin/alias-en0.nix create mode 100644 modules/darwin/core.nix delete mode 100644 modules/darwin/core/default.nix delete mode 100644 modules/darwin/core/programs/default.nix delete mode 100644 modules/darwin/core/programs/nh/default.nix delete mode 100644 modules/darwin/default.nix create mode 100644 modules/darwin/dnsmasq.nix create mode 100644 modules/darwin/ghostty.nix create mode 100644 modules/darwin/homebrew.nix create mode 100644 modules/darwin/macos-defaults.nix delete mode 100644 modules/darwin/mixins/alias-en0.nix delete mode 100644 modules/darwin/mixins/default.nix delete mode 100644 modules/darwin/mixins/dnsmasq.nix delete mode 100644 modules/darwin/mixins/ghostty.nix delete mode 100644 modules/darwin/mixins/homebrew.nix delete mode 100644 modules/darwin/mixins/macos-defaults.nix create mode 100644 modules/darwin/nh.nix create mode 100644 modules/dev.nix create mode 100644 modules/flake-parts.nix create mode 100644 modules/home-manager/core.nix delete mode 100644 modules/home-manager/default.nix rename modules/home-manager/yazi/{themes => _themes}/kanagawa-dragon/default.nix (100%) rename modules/home-manager/yazi/{themes => _themes}/kanagawa-dragon/flavor.toml (100%) rename modules/home-manager/yazi/{themes => _themes}/kanagawa-dragon/tmtheme.xml (100%) create mode 100644 modules/home.nix create mode 100644 modules/hosts/SOC-Kris-Williams.nix create mode 100644 modules/hosts/k.nix create mode 100644 modules/hosts/mini.nix create mode 100644 modules/lib.nix create mode 100644 modules/overlays.nix create mode 100644 modules/packages.nix delete mode 100644 overlays/default.nix diff --git a/flake.lock b/flake.lock index e1fb60f4..cde7dd4e 100644 --- a/flake.lock +++ b/flake.lock @@ -36,6 +36,24 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1778716662, + "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -56,6 +74,21 @@ "type": "github" } }, + "import-tree": { + "locked": { + "lastModified": 1778781969, + "narHash": "sha256-Jjuz5CmSkur8KvLDoGa+vylEp+RkQtv4mt/qcMznpH0=", + "owner": "denful", + "repo": "import-tree", + "rev": "d321337efd0f23a9eb14a42adb7b2c29313ab274", + "type": "github" + }, + "original": { + "owner": "denful", + "repo": "import-tree", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1779414690, @@ -72,11 +105,28 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1777168982, + "narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "root": { "inputs": { "darwin": "darwin", "faster-piper-yazi": "faster-piper-yazi", + "flake-parts": "flake-parts", "home-manager": "home-manager", + "import-tree": "import-tree", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 4173257f..0f388951 100644 --- a/flake.nix +++ b/flake.nix @@ -1,67 +1,12 @@ { description = "Kris' Apple Nix Configuration"; - outputs = - inputs@{ - self, - nixpkgs, - ... - }: - let - inherit (self) outputs; - # All of my macs are Apple ARM - system = "aarch64-darwin"; - pkgs = import nixpkgs { - inherit system; - }; - lib = nixpkgs.lib.extend ( - _: _: - import ./lib { - inherit self inputs outputs; - } - ); - in - { - inherit lib; - packages.${system} = { - kitten = pkgs.callPackage ./pkgs/kitten.nix { }; - iv = pkgs.callPackage ./pkgs/iv.nix { }; - }; - darwinConfigurations = { - k = lib.mkDarwin ./hosts/k "k"; - mini = lib.mkDarwin ./hosts/mini "k"; - SOC-Kris-Williams = lib.mkDarwin ./hosts/SOC-Kris-Williams "k"; - }; - devShells.${system}.default = pkgs.mkShell { - name = "dotfiles"; - packages = builtins.attrValues { - inherit (pkgs) - deadnix - statix - nixfmt-tree - just - ; - }; - shellHook = '' - PATH_add "$PWD/bin" - ''; - }; - overlays = import ./overlays { inherit inputs; }; - formatter.${system} = pkgs.nixfmt-tree; - darwinModules = rec { - kriswill = import ./modules/darwin { - inherit lib; - }; - default = kriswill; - }; - homeModules = rec { - kriswill = ./modules/home-manager; - default = kriswill; - }; - }; + outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } (inputs.import-tree ./modules); inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + import-tree.url = "github:denful/import-tree"; darwin = { url = "github:lnl7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/hosts/SOC-Kris-Williams/default.nix b/hosts/SOC-Kris-Williams/default.nix deleted file mode 100644 index 435a9aa5..00000000 --- a/hosts/SOC-Kris-Williams/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -# SOC-Kris-Williams - my work Apple M2 Pro, 32GB RAM -# hostname enforced by IT -# -{ - kriswill.alias-en0.enable = true; - kriswill.dnsmasq.enable = true; - home-manager.users.k.kriswill.podman-desktop.enable = true; -} diff --git a/hosts/k/default.nix b/hosts/k/default.nix deleted file mode 100644 index 9b651a0e..00000000 --- a/hosts/k/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -# k - my personal macbook pro M1 max, 64GB RAM -# -{ - kriswill.dnsmasq.enable = true; - home-manager.users.k.kriswill.podman-desktop.enable = true; -} diff --git a/hosts/mini/default.nix b/hosts/mini/default.nix deleted file mode 100644 index 1e2886e8..00000000 --- a/hosts/mini/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -# mini - my personal mac mini M1, 16GB RAM -# -{ - kriswill.dnsmasq.enable = true; -} diff --git a/lib/default.nix b/lib/default.nix index 704d23c3..24a5dd4e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,14 +1,8 @@ -{ - self, - outputs, - inputs, -}: +# Pure helpers merged onto nixpkgs lib (see modules/lib.nix). Kept outside +# ./modules so import-tree does not treat it as a flake-parts module. +{ lib }: let - inherit (outputs) lib; - inherit (inputs.darwin.lib) darwinSystem; inherit (lib) - filter - forEach mkEnableOption mkPackageOption optionalString @@ -17,63 +11,6 @@ in { kanagawa = import ./kanagawa.nix; - mkHomeManager = username: { - home-manager = { - backupFileExtension = "hm.bak"; - useUserPackages = true; - useGlobalPkgs = true; - users."${username}" = { - imports = [ outputs.homeModules.kriswill ]; - kriswill.enable = true; - home.stateVersion = "26.05"; - home.homeDirectory = lib.mkForce "/Users/${username}"; - manual = { - html.enable = false; - json.enable = false; - manpages.enable = false; - }; - }; - # sharedModules = [ inputs.mac-app-util.homeManagerModules.default ]; - extraSpecialArgs = { inherit inputs username; }; - }; - }; - - mkDarwin = - hostmodule: username: - darwinSystem { - specialArgs = { - inherit - self - inputs - outputs - lib - ; - }; - modules = [ - hostmodule - inputs.home-manager.darwinModules.home-manager - outputs.darwinModules.kriswill - (lib.mkHomeManager username) - { - kriswill.enable = true; - nixpkgs = { - hostPlatform = "aarch64-darwin"; - overlays = builtins.attrValues outputs.overlays; - }; - } - ]; - }; - - # read a directory and return a list of all filenames inside except any default.nix - # ripped from: https://github.com/EarthGman/nix-library/blob/main/lib/default.nix#L15 - autoImport = - dir: - let - fileNames = builtins.attrNames (builtins.readDir dir); - strippedFileNames = filter (name: name != "default.nix") fileNames; - in - forEach strippedFileNames (fileName: dir + /${fileName}); - mkProgramOption = { pkgs, @@ -86,5 +23,4 @@ in enable = mkEnableOption (programName + " " + optionalString (description != null) description); package = mkPackageOption pkgs packageName extraPackageArgs; }; - } diff --git a/modules/darwin.nix b/modules/darwin.nix new file mode 100644 index 00000000..88cd1e77 --- /dev/null +++ b/modules/darwin.nix @@ -0,0 +1,45 @@ +# Declares `configurations.darwin.` and realises each into a +# `darwinConfigurations.` flake output (plus a toplevel build check). +# Adapted from the mightyiam/dendritic example `nixos.nix`. +{ + lib, + config, + inputs, + ... +}: +{ + options.configurations.darwin = lib.mkOption { + type = lib.types.lazyAttrsOf ( + lib.types.submodule { + options.module = lib.mkOption { + type = lib.types.deferredModule; + }; + } + ); + default = { }; + description = "nix-darwin configurations, keyed by hostname."; + }; + + config.flake.darwinConfigurations = lib.flip lib.mapAttrs config.configurations.darwin ( + _name: + { module }: + inputs.darwin.lib.darwinSystem { + specialArgs = { + inherit inputs; + self = inputs.self; + outputs = inputs.self; + # The repo's extended lib (adds mkProgramOption, kanagawa), matching the + # `lib` that the old `mkDarwin` injected. + lib = config.kriswill.lib; + }; + modules = [ module ]; + } + ); + + config.flake.checks = lib.mkMerge ( + lib.mapAttrsToList (name: cfg: { + ${cfg.config.nixpkgs.hostPlatform.system}."configurations:darwin:${name}" = + cfg.config.system.build.toplevel; + }) config.flake.darwinConfigurations + ); +} diff --git a/modules/darwin/alias-en0.nix b/modules/darwin/alias-en0.nix new file mode 100644 index 00000000..9d2c2eae --- /dev/null +++ b/modules/darwin/alias-en0.nix @@ -0,0 +1,22 @@ +{ ... }: +{ + flake.modules.darwin.alias-en0 = + { lib, config, ... }: + { + options.kriswill.alias-en0.enable = lib.mkEnableOption "en0 local IP address alias - used for dev"; + config = lib.mkIf config.kriswill.alias-en0.enable { + launchd.daemons.alias-en0 = { + serviceConfig = { + Label = "com.local.alias.en0"; + ProgramArguments = [ + "/sbin/ifconfig" + "en0" + "alias" + "10.11.12.1/24" + ]; + RunAtLoad = true; + }; + }; + }; + }; +} diff --git a/modules/darwin/core.nix b/modules/darwin/core.nix new file mode 100644 index 00000000..14b40a75 --- /dev/null +++ b/modules/darwin/core.nix @@ -0,0 +1,87 @@ +# Core nix-darwin system configuration (was modules/darwin/mixins/default.nix). +# Declares the darwin-side `kriswill.enable` master toggle and the always-on +# system baseline. Sibling darwin features are now separate flake-parts modules +# auto-imported by import-tree, so the old `lib.autoImport` is gone. +{ ... }: +{ + flake.modules.darwin.core = + { + self, + pkgs, + lib, + ... + }: + { + options.kriswill.enable = lib.mkEnableOption "Kris' custom darwin modules"; + config = { + kriswill = { + homebrew.enable = lib.mkDefault true; + ghostty.enable = lib.mkDefault true; + macos-defaults.enable = lib.mkDefault true; + }; + system = { + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + stateVersion = 5; + # Set Git commit hash for darwin-version. + configurationRevision = self.rev or self.dirtyRev or null; + # + primaryUser = "k"; + }; + + environment = { + # $ nix-env -qaP | grep wget + systemPackages = [ + pkgs.iproute2mac # ip command (like linux) + pkgs.home-manager + pkgs.pstree + ]; + shellAliases = + let + nh = lib.getExe pkgs.nh; + in + { + nrs = "NH_NO_CHECKS=1 ${nh} darwin switch ~/src/dotfiles"; + nrt = "NH_NO_CHECKS=1 ${nh} darwin test ~/src/dotfiles"; + }; + etc."pam.d/sudo_local".text = '' + # Allow for touch ID to work for sudo, inside of tmux + auth optional ${pkgs.pam-reattach}/lib/pam/pam_reattach.so ignore_ssh + auth sufficient pam_tid.so + ''; + }; + + security.pam.services.sudo_local.touchIdAuth = true; + + # Disable documentation generation to avoid builtins.toFile warnings + # with custom module options + documentation.enable = false; + + # nix repl -f '' + # > nerd-fonts. + fonts.packages = builtins.attrValues { + inherit (pkgs.nerd-fonts) + victor-mono + sauce-code-pro + jetbrains-mono + ; + }; + + programs = { + fish.enable = true; + zsh.enable = true; + nh.enable = true; + }; + + users.users.k.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBxqhXoAlCKYNwsB1YrszftURThiCI94oeR0W9EDhrLy" + ]; + + # Cannot let nix-darwin control nix when using determinate + nix.enable = lib.mkForce false; + nixpkgs = { + config.allowUnfree = false; + }; + }; + }; +} diff --git a/modules/darwin/core/default.nix b/modules/darwin/core/default.nix deleted file mode 100644 index 8454ad77..00000000 --- a/modules/darwin/core/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ lib, ... }: -{ - imports = lib.autoImport ./.; -} diff --git a/modules/darwin/core/programs/default.nix b/modules/darwin/core/programs/default.nix deleted file mode 100644 index 8454ad77..00000000 --- a/modules/darwin/core/programs/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ lib, ... }: -{ - imports = lib.autoImport ./.; -} diff --git a/modules/darwin/core/programs/nh/default.nix b/modules/darwin/core/programs/nh/default.nix deleted file mode 100644 index f5ef156d..00000000 --- a/modules/darwin/core/programs/nh/default.nix +++ /dev/null @@ -1,21 +0,0 @@ -# This option is missing from nix-darwin config -{ - lib, - pkgs, - config, - ... -}: -let - inherit (lib) mkIf mkProgramOption; - cfg = config.programs.nh; -in -{ - options.programs.nh = mkProgramOption { - programName = "nh"; - description = "Nix Helper"; - inherit pkgs; - }; - config = mkIf cfg.enable { - environment.systemPackages = [ cfg.package ]; - }; -} diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix deleted file mode 100644 index 8454ad77..00000000 --- a/modules/darwin/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ lib, ... }: -{ - imports = lib.autoImport ./.; -} diff --git a/modules/darwin/dnsmasq.nix b/modules/darwin/dnsmasq.nix new file mode 100644 index 00000000..cc6306ff --- /dev/null +++ b/modules/darwin/dnsmasq.nix @@ -0,0 +1,18 @@ +{ ... }: +{ + flake.modules.darwin.dnsmasq = + { lib, config, ... }: + { + options.kriswill.dnsmasq.enable = lib.mkEnableOption "dnsmasq local DNS service"; + config = lib.mkIf config.kriswill.dnsmasq.enable { + services.dnsmasq = { + enable = true; + bind = "127.0.0.1"; + addresses = { + localhost = "127.0.0.1"; + p4c = "127.0.0.1"; + }; + }; + }; + }; +} diff --git a/modules/darwin/ghostty.nix b/modules/darwin/ghostty.nix new file mode 100644 index 00000000..0ae6d2e7 --- /dev/null +++ b/modules/darwin/ghostty.nix @@ -0,0 +1,15 @@ +{ ... }: +{ + flake.modules.darwin.ghostty = + { lib, config, ... }: + { + options.kriswill.ghostty.enable = lib.mkEnableOption "Ghostty terminal"; + config = lib.mkIf config.kriswill.ghostty.enable { + homebrew.casks = [ "ghostty" ]; + environment.variables.TERMINFO_DIRS = [ + "/Applications/Ghostty.app/Contents/Resources/terminfo" + "/usr/share/terminfo" + ]; + }; + }; +} diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix new file mode 100644 index 00000000..ecbc333a --- /dev/null +++ b/modules/darwin/homebrew.nix @@ -0,0 +1,47 @@ +{ ... }: +{ + flake.modules.darwin.homebrew = + { lib, config, ... }: + { + options.kriswill.homebrew.enable = lib.mkEnableOption "Kris' Homebrew stuff"; + config = lib.mkIf config.kriswill.homebrew.enable { + homebrew = { + enable = true; + global.brewfile = true; + onActivation = { + upgrade = true; + cleanup = "zap"; + autoUpdate = true; + }; + taps = [ + "steipete/tap" + "marcus/tap" + ]; + casks = [ + "rwts-pdfwriter" + "zerotier-one" + "1password-cli" + "karabiner-elements" + { + name = "chromium"; + args = { + no_quarantine = true; + }; + } + { + name = "launchcontrol"; + greedy = true; + } + ]; + brews = [ + "marcus/tap/td" + "marcus/tap/sidecar" + ]; + # SLOW! + # masApps = { + # "Xcode" = 497799835; + # }; + }; + }; + }; +} diff --git a/modules/darwin/macos-defaults.nix b/modules/darwin/macos-defaults.nix new file mode 100644 index 00000000..d4181584 --- /dev/null +++ b/modules/darwin/macos-defaults.nix @@ -0,0 +1,17 @@ +{ ... }: +{ + flake.modules.darwin.macos-defaults = + { lib, config, ... }: + { + options.kriswill.macos-defaults.enable = lib.mkEnableOption "Kris' macOS defaults"; + config = lib.mkIf config.kriswill.macos-defaults.enable { + system.defaults.NSGlobalDomain = { + # Disable "natural" scrolling (reverse scroll direction to traditional) + "com.apple.swipescrolldirection" = false; + # Enable Ctrl+Cmd+click anywhere to drag windows (like Linux) + NSWindowShouldDragOnGesture = true; + }; + system.defaults.dock.autohide = true; + }; + }; +} diff --git a/modules/darwin/mixins/alias-en0.nix b/modules/darwin/mixins/alias-en0.nix deleted file mode 100644 index 2ee3bd48..00000000 --- a/modules/darwin/mixins/alias-en0.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ lib, config, ... }: -{ - options.kriswill.alias-en0.enable = lib.mkEnableOption "en0 local IP address alias - used for dev"; - config = lib.mkIf config.kriswill.alias-en0.enable { - launchd.daemons.alias-en0 = { - serviceConfig = { - Label = "com.local.alias.en0"; - ProgramArguments = [ - "/sbin/ifconfig" - "en0" - "alias" - "10.11.12.1/24" - ]; - RunAtLoad = true; - }; - }; - }; -} diff --git a/modules/darwin/mixins/default.nix b/modules/darwin/mixins/default.nix deleted file mode 100644 index 044250a0..00000000 --- a/modules/darwin/mixins/default.nix +++ /dev/null @@ -1,87 +0,0 @@ -{ - self, - pkgs, - lib, - ... -}: -{ - imports = lib.autoImport ./.; - options.kriswill.enable = lib.mkEnableOption "Kris' custom darwin modules"; - config = { - kriswill = { - homebrew.enable = lib.mkDefault true; - ghostty.enable = lib.mkDefault true; - macos-defaults.enable = lib.mkDefault true; - }; - system = { - # Used for backwards compatibility, please read the changelog before changing. - # $ darwin-rebuild changelog - stateVersion = 5; - # Set Git commit hash for darwin-version. - configurationRevision = self.rev or self.dirtyRev or null; - # - primaryUser = "k"; - }; - - environment = { - # $ nix-env -qaP | grep wget - systemPackages = [ - pkgs.iproute2mac # ip command (like linux) - pkgs.home-manager - pkgs.pstree - ]; - # ++ [ - # inputs.fh.packages.${pkgs.stdenv.hostPlatform.system}.default - # inputs.ghostty.packages.aarch64-darwin.default - # ]; - shellAliases = - let - nh = lib.getExe pkgs.nh; - in - { - # drs = "sudo ${ - # inputs.darwin.packages.${pkgs.stdenv.hostPlatform.system}.darwin-rebuild - # }/bin/darwin-rebuild switch --flake ~/src/dotfiles |& ${lib.getExe pkgs.nix-output-monitor}"; - nrs = "NH_NO_CHECKS=1 ${nh} darwin switch ~/src/dotfiles"; - nrt = "NH_NO_CHECKS=1 ${nh} darwin test ~/src/dotfiles"; - }; - etc."pam.d/sudo_local".text = '' - # Allow for touch ID to work for sudo, inside of tmux - auth optional ${pkgs.pam-reattach}/lib/pam/pam_reattach.so ignore_ssh - auth sufficient pam_tid.so - ''; - }; - - security.pam.services.sudo_local.touchIdAuth = true; - - # Disable documentation generation to avoid builtins.toFile warnings - # with custom module options - documentation.enable = false; - - # nix repl -f '' - # > nerd-fonts. - fonts.packages = builtins.attrValues { - inherit (pkgs.nerd-fonts) - victor-mono - sauce-code-pro - jetbrains-mono - ; - }; - - programs = { - fish.enable = true; - zsh.enable = true; - nh.enable = true; - }; - - users.users.k.openssh.authorizedKeys.keys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBxqhXoAlCKYNwsB1YrszftURThiCI94oeR0W9EDhrLy" - ]; - - # Cannot let nix-darwin control nix when using determinate - nix.enable = lib.mkForce false; - nixpkgs = { - config.allowUnfree = false; - }; - }; -} diff --git a/modules/darwin/mixins/dnsmasq.nix b/modules/darwin/mixins/dnsmasq.nix deleted file mode 100644 index 280dbbe6..00000000 --- a/modules/darwin/mixins/dnsmasq.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ lib, config, ... }: -{ - options.kriswill.dnsmasq.enable = lib.mkEnableOption "dnsmasq local DNS service"; - config = lib.mkIf config.kriswill.dnsmasq.enable { - services.dnsmasq = { - enable = true; - bind = "127.0.0.1"; - addresses = { - localhost = "127.0.0.1"; - p4c = "127.0.0.1"; - }; - }; - }; -} diff --git a/modules/darwin/mixins/ghostty.nix b/modules/darwin/mixins/ghostty.nix deleted file mode 100644 index da634c4c..00000000 --- a/modules/darwin/mixins/ghostty.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ lib, config, ... }: -{ - options.kriswill.ghostty.enable = lib.mkEnableOption "Ghostty terminal"; - config = lib.mkIf config.kriswill.ghostty.enable { - homebrew.casks = [ "ghostty" ]; - environment.variables.TERMINFO_DIRS = [ - "/Applications/Ghostty.app/Contents/Resources/terminfo" - "/usr/share/terminfo" - ]; - }; -} diff --git a/modules/darwin/mixins/homebrew.nix b/modules/darwin/mixins/homebrew.nix deleted file mode 100644 index bc150941..00000000 --- a/modules/darwin/mixins/homebrew.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ lib, config, ... }: -{ - options.kriswill.homebrew.enable = lib.mkEnableOption "Kris' Homebrew stuff"; - config = lib.mkIf config.kriswill.homebrew.enable { - homebrew = { - enable = true; - global.brewfile = true; - onActivation = { - upgrade = true; - cleanup = "zap"; - autoUpdate = true; - }; - taps = [ - "steipete/tap" - "marcus/tap" - ]; - casks = [ - "rwts-pdfwriter" - "zerotier-one" - "1password-cli" - "karabiner-elements" - { - name = "chromium"; - args = { - no_quarantine = true; - }; - } - { - name = "launchcontrol"; - greedy = true; - } - ]; - brews = [ - "marcus/tap/td" - "marcus/tap/sidecar" - ]; - # SLOW! - # masApps = { - # "Xcode" = 497799835; - # }; - }; - }; -} diff --git a/modules/darwin/mixins/macos-defaults.nix b/modules/darwin/mixins/macos-defaults.nix deleted file mode 100644 index a74c9162..00000000 --- a/modules/darwin/mixins/macos-defaults.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ lib, config, ... }: -{ - options.kriswill.macos-defaults.enable = lib.mkEnableOption "Kris' macOS defaults"; - config = lib.mkIf config.kriswill.macos-defaults.enable { - system.defaults.NSGlobalDomain = { - # Disable "natural" scrolling (reverse scroll direction to traditional) - "com.apple.swipescrolldirection" = false; - # Enable Ctrl+Cmd+click anywhere to drag windows (like Linux) - NSWindowShouldDragOnGesture = true; - }; - system.defaults.dock.autohide = true; - }; -} diff --git a/modules/darwin/nh.nix b/modules/darwin/nh.nix new file mode 100644 index 00000000..9e2cf0ea --- /dev/null +++ b/modules/darwin/nh.nix @@ -0,0 +1,25 @@ +# This option is missing from nix-darwin config +{ ... }: +{ + flake.modules.darwin.nh = + { + lib, + pkgs, + config, + ... + }: + let + inherit (lib) mkIf mkProgramOption; + cfg = config.programs.nh; + in + { + options.programs.nh = mkProgramOption { + programName = "nh"; + description = "Nix Helper"; + inherit pkgs; + }; + config = mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + }; + }; +} diff --git a/modules/dev.nix b/modules/dev.nix new file mode 100644 index 00000000..e5eb9bac --- /dev/null +++ b/modules/dev.nix @@ -0,0 +1,23 @@ +# Development shell and formatter. +{ ... }: +{ + perSystem = + { pkgs, ... }: + { + formatter = pkgs.nixfmt-tree; + devShells.default = pkgs.mkShell { + name = "dotfiles"; + packages = builtins.attrValues { + inherit (pkgs) + deadnix + statix + nixfmt-tree + just + ; + }; + shellHook = '' + PATH_add "$PWD/bin" + ''; + }; + }; +} diff --git a/modules/flake-parts.nix b/modules/flake-parts.nix new file mode 100644 index 00000000..ab84105b --- /dev/null +++ b/modules/flake-parts.nix @@ -0,0 +1,9 @@ +# Top-level flake-parts wiring for the Dendritic pattern. +# `flakeModules.modules` provides the `flake.modules..` option +# (https://flake.parts/options/flake-parts-modules.html) into which every +# feature file merges its darwin / home-manager module. +{ inputs, ... }: +{ + imports = [ inputs.flake-parts.flakeModules.modules ]; + systems = [ "aarch64-darwin" ]; +} diff --git a/modules/home-manager/brave.nix b/modules/home-manager/brave.nix index 6d8d639f..def1896c 100644 --- a/modules/home-manager/brave.nix +++ b/modules/home-manager/brave.nix @@ -1,20 +1,24 @@ +{ ... }: { - lib, - config, - pkgs, - ... -}: + flake.modules.homeManager.brave = + { + lib, + config, + pkgs, + ... + }: -{ - options.kriswill.brave.enable = lib.mkEnableOption "Kris' Brave config"; - config = lib.mkIf config.kriswill.brave.enable { - programs.brave = { - enable = true; - package = pkgs.brave; - extensions = [ - { id = "aeblfdkhhhdcdjpifhhbdiojplfjncoa"; } # 1password - { id = "eimadpbcbfnmbkopoojfekhnkhdbieeh"; } # dark reader - ]; + { + options.kriswill.brave.enable = lib.mkEnableOption "Kris' Brave config"; + config = lib.mkIf config.kriswill.brave.enable { + programs.brave = { + enable = true; + package = pkgs.brave; + extensions = [ + { id = "aeblfdkhhhdcdjpifhhbdiojplfjncoa"; } # 1password + { id = "eimadpbcbfnmbkopoojfekhnkhdbieeh"; } # dark reader + ]; + }; + }; }; - }; } diff --git a/modules/home-manager/core.nix b/modules/home-manager/core.nix new file mode 100644 index 00000000..d817d5b7 --- /dev/null +++ b/modules/home-manager/core.nix @@ -0,0 +1,184 @@ +# Core home-manager configuration (was modules/home-manager/default.nix). +# Declares the home-manager-side `kriswill.enable` master toggle, flips the +# per-feature defaults, and carries the shared package set / inline programs. +{ ... }: +{ + flake.modules.homeManager.core = + { + lib, + config, + pkgs, + ... + }: + let + # Custom sqlite with loadable extension support for sqlite-vec and qmd + sqliteWithExtensions = pkgs.sqlite.overrideAttrs (old: { + env = (old.env or { }) // { + NIX_CFLAGS_COMPILE = (old.env.NIX_CFLAGS_COMPILE or "") + " -DSQLITE_ENABLE_LOAD_EXTENSION=1"; + }; + }); + in + { + options.kriswill.enable = lib.mkEnableOption "Kris' home module"; + config = lib.mkIf config.kriswill.enable { + kriswill = { + fastfetch.enable = lib.mkDefault true; + # firefox.enable = lib.mkDefault false; + kitty.enable = lib.mkDefault true; + neovim.enable = lib.mkDefault true; + neovide.enable = lib.mkDefault true; + tmux.enable = lib.mkDefault true; + ghostty.enable = lib.mkDefault true; + karabiner.enable = lib.mkDefault true; + # brave.enable = lib.mkDefault false; + zsh.enable = lib.mkDefault true; + oksh.enable = lib.mkDefault true; + direnv-nom.enable = lib.mkDefault true; + diffnav.enable = lib.mkDefault true; + git.enable = lib.mkDefault true; + ssh.enable = lib.mkDefault true; + starship.enable = lib.mkDefault true; + yazi.enable = lib.mkDefault true; + glow.enable = lib.mkDefault true; + zk.enable = lib.mkDefault true; + # vscode.enable = lib.mkDefault false; + }; + home.packages = with pkgs; [ + age # encryption tool + bun + btop + comma # https://github.com/nix-community/comma + fd # file finding + figlet # text to big fancy letters in ASCII + go # an awesome language + grc # generic text colorizer + gnupg # signature verifier + jq # json querying + just # better make + keycastr # keystroke visualizer + localsend # share files with other devices on the local network + # mactop + ncdu # analyze disk usage + nix-index # local database of nixpkgs + nix-output-monitor # better visual output for nix builds + nix-tree # analyze disk usage by nix packages + nodejs_24 + ripgrep # fast grep replacement + sqliteWithExtensions + sqlite-vec + # stoat-desktop + tldr # simplified man pages + tree # print directory trees + uv # one python tool to rule them all! + yamlfmt # format yaml + # You can also create simple shell scripts directly inside your + # configuration. For example, this adds a command 'my-hello' to your + # environment: + (writeShellScriptBin "my-hello" '' + echo "Hello, ${config.home.username}!" + '') + ]; + home.sessionVariables = + let + # Use home-manager's wrapped nvim so EDITOR-invoked callers (yazi, + # git commit, crontab, etc.) inherit programs.neovim.extraPackages + # on PATH. pkgs.neovim is the generic nixpkgs wrapper without our + # extraPackages — it runs nvim fine but LSP servers can't spawn. + neovim = lib.getExe config.programs.neovim.finalPackage; + in + { + EDITOR = neovim; + VISUAL = neovim; + MANPAGER = "${neovim} +Man!"; + }; + programs = { + bat.enable = lib.mkDefault true; + jq.enable = lib.mkDefault true; + nix-index.enable = lib.mkDefault true; + # obs-studio.enable = true; # not on mac + lazygit.enable = lib.mkDefault true; + rmpc.enable = lib.mkDefault true; + + hstr = { + enable = lib.mkDefault true; + enableZshIntegration = lib.mkDefault true; + }; + + direnv = { + enable = lib.mkDefault true; + nix-direnv.enable = lib.mkDefault true; + }; + + fzf = { + enable = lib.mkDefault true; + # enableZshIntegration = lib.mkDefault true; + + defaultCommand = "fd --type f"; + defaultOptions = [ + "--height 40%" + "--prompt ⟫" + ]; + + changeDirWidgetCommand = "fd --type d"; + changeDirWidgetOptions = [ + "--preview 'tree -C {} | head -200'" + ]; + }; + + htop = { + enable = lib.mkDefault true; + settings = { + sort_direction = true; + sort_key = "PERCENT_CPU"; + show_program_path = false; + }; + }; + + zoxide = { + enable = lib.mkDefault true; + enableZshIntegration = true; + options = [ + "--cmd" + "j" + ]; + }; + + }; + + # Transitional cleanup for the parked symlink-based GUI app exposure + # attempt (see attempt/mkalias-realbundle-symlinks). Removes bare + # ~/Applications/.app symlinks pointing into /nix/store, plus the + # manifest. Self-deletes once the manifest is gone — safe to remove this + # block after every host has activated once. Can be deleted alongside + # this comment in a future cleanup pass. + home.activation.cleanupLegacyAppBundleSymlinks = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + manifest="''${XDG_STATE_HOME:-$HOME/.local/state}/home-manager-app-bundles.list" + if [ -f "$manifest" ]; then + while IFS= read -r app_name; do + target="$HOME/Applications/$app_name" + if [ -L "$target" ] && readlink "$target" | grep -q '^/nix/store/'; then + rm -f "$target" + fi + done < "$manifest" + rm -f "$manifest" + fi + ''; + + # qmd (bun-installed, outside nix) hardcodes two Homebrew paths in + # its setCustomSQLite() call and ignores env vars. Point the + # Apple-Silicon path at our extension-enabled nix sqlite so qmd can + # dlopen it. Skip if a real Homebrew sqlite is already installed. + home.activation.linkSqliteForQmd = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + brew_lib=/opt/homebrew/opt/sqlite/lib + link=$brew_lib/libsqlite3.dylib + target=${sqliteWithExtensions.out}/lib/libsqlite3.dylib + if [ -e "$link" ] && [ ! -L "$link" ]; then + echo "qmd-sqlite-link: $link is a real file (Homebrew install?), leaving alone" >&2 + else + $DRY_RUN_CMD mkdir -p "$brew_lib" + $DRY_RUN_CMD ln -sfn "$target" "$link" + fi + ''; + }; + }; +} diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix deleted file mode 100644 index 598956dd..00000000 --- a/modules/home-manager/default.nix +++ /dev/null @@ -1,178 +0,0 @@ -{ - lib, - config, - pkgs, - ... -}: -let - # Custom sqlite with loadable extension support for sqlite-vec and qmd - sqliteWithExtensions = pkgs.sqlite.overrideAttrs (old: { - env = (old.env or { }) // { - NIX_CFLAGS_COMPILE = (old.env.NIX_CFLAGS_COMPILE or "") + " -DSQLITE_ENABLE_LOAD_EXTENSION=1"; - }; - }); -in -{ - imports = lib.autoImport ./.; - options.kriswill.enable = lib.mkEnableOption "Kris' home module"; - config = lib.mkIf config.kriswill.enable { - kriswill = { - fastfetch.enable = lib.mkDefault true; - # firefox.enable = lib.mkDefault false; - kitty.enable = lib.mkDefault true; - neovim.enable = lib.mkDefault true; - neovide.enable = lib.mkDefault true; - tmux.enable = lib.mkDefault true; - ghostty.enable = lib.mkDefault true; - karabiner.enable = lib.mkDefault true; - # brave.enable = lib.mkDefault false; - zsh.enable = lib.mkDefault true; - oksh.enable = lib.mkDefault true; - direnv-nom.enable = lib.mkDefault true; - diffnav.enable = lib.mkDefault true; - git.enable = lib.mkDefault true; - ssh.enable = lib.mkDefault true; - starship.enable = lib.mkDefault true; - yazi.enable = lib.mkDefault true; - glow.enable = lib.mkDefault true; - zk.enable = lib.mkDefault true; - # vscode.enable = lib.mkDefault false; - }; - home.packages = with pkgs; [ - age # encryption tool - bun - btop - comma # https://github.com/nix-community/comma - fd # file finding - figlet # text to big fancy letters in ASCII - go # an awesome language - grc # generic text colorizer - gnupg # signature verifier - jq # json querying - just # better make - keycastr # keystroke visualizer - localsend # share files with other devices on the local network - # mactop - ncdu # analyze disk usage - nix-index # local database of nixpkgs - nix-output-monitor # better visual output for nix builds - nix-tree # analyze disk usage by nix packages - nodejs_24 - ripgrep # fast grep replacement - sqliteWithExtensions - sqlite-vec - # stoat-desktop - tldr # simplified man pages - tree # print directory trees - uv # one python tool to rule them all! - yamlfmt # format yaml - # You can also create simple shell scripts directly inside your - # configuration. For example, this adds a command 'my-hello' to your - # environment: - (writeShellScriptBin "my-hello" '' - echo "Hello, ${config.home.username}!" - '') - ]; - home.sessionVariables = - let - # Use home-manager's wrapped nvim so EDITOR-invoked callers (yazi, - # git commit, crontab, etc.) inherit programs.neovim.extraPackages - # on PATH. pkgs.neovim is the generic nixpkgs wrapper without our - # extraPackages — it runs nvim fine but LSP servers can't spawn. - neovim = lib.getExe config.programs.neovim.finalPackage; - in - { - EDITOR = neovim; - VISUAL = neovim; - MANPAGER = "${neovim} +Man!"; - }; - programs = { - bat.enable = lib.mkDefault true; - jq.enable = lib.mkDefault true; - nix-index.enable = lib.mkDefault true; - # obs-studio.enable = true; # not on mac - lazygit.enable = lib.mkDefault true; - rmpc.enable = lib.mkDefault true; - - hstr = { - enable = lib.mkDefault true; - enableZshIntegration = lib.mkDefault true; - }; - - direnv = { - enable = lib.mkDefault true; - nix-direnv.enable = lib.mkDefault true; - }; - - fzf = { - enable = lib.mkDefault true; - # enableZshIntegration = lib.mkDefault true; - - defaultCommand = "fd --type f"; - defaultOptions = [ - "--height 40%" - "--prompt ⟫" - ]; - - changeDirWidgetCommand = "fd --type d"; - changeDirWidgetOptions = [ - "--preview 'tree -C {} | head -200'" - ]; - }; - - htop = { - enable = lib.mkDefault true; - settings = { - sort_direction = true; - sort_key = "PERCENT_CPU"; - show_program_path = false; - }; - }; - - zoxide = { - enable = lib.mkDefault true; - enableZshIntegration = true; - options = [ - "--cmd" - "j" - ]; - }; - - }; - - # Transitional cleanup for the parked symlink-based GUI app exposure - # attempt (see attempt/mkalias-realbundle-symlinks). Removes bare - # ~/Applications/.app symlinks pointing into /nix/store, plus the - # manifest. Self-deletes once the manifest is gone — safe to remove this - # block after every host has activated once. Can be deleted alongside - # this comment in a future cleanup pass. - home.activation.cleanupLegacyAppBundleSymlinks = lib.hm.dag.entryAfter [ "writeBoundary" ] '' - manifest="''${XDG_STATE_HOME:-$HOME/.local/state}/home-manager-app-bundles.list" - if [ -f "$manifest" ]; then - while IFS= read -r app_name; do - target="$HOME/Applications/$app_name" - if [ -L "$target" ] && readlink "$target" | grep -q '^/nix/store/'; then - rm -f "$target" - fi - done < "$manifest" - rm -f "$manifest" - fi - ''; - - # qmd (bun-installed, outside nix) hardcodes two Homebrew paths in - # its setCustomSQLite() call and ignores env vars. Point the - # Apple-Silicon path at our extension-enabled nix sqlite so qmd can - # dlopen it. Skip if a real Homebrew sqlite is already installed. - home.activation.linkSqliteForQmd = lib.hm.dag.entryAfter [ "writeBoundary" ] '' - brew_lib=/opt/homebrew/opt/sqlite/lib - link=$brew_lib/libsqlite3.dylib - target=${sqliteWithExtensions.out}/lib/libsqlite3.dylib - if [ -e "$link" ] && [ ! -L "$link" ]; then - echo "qmd-sqlite-link: $link is a real file (Homebrew install?), leaving alone" >&2 - else - $DRY_RUN_CMD mkdir -p "$brew_lib" - $DRY_RUN_CMD ln -sfn "$target" "$link" - fi - ''; - }; -} diff --git a/modules/home-manager/diffnav.nix b/modules/home-manager/diffnav.nix index d5c2d4b6..ef28f38b 100644 --- a/modules/home-manager/diffnav.nix +++ b/modules/home-manager/diffnav.nix @@ -1,64 +1,68 @@ +{ ... }: { - lib, - config, - pkgs, - ... -}: -let - inherit (lib) kanagawa; -in -{ - options.kriswill.diffnav.enable = lib.mkEnableOption "diffnav git diff pager"; + flake.modules.homeManager.diffnav = + { + lib, + config, + pkgs, + ... + }: + let + inherit (lib) kanagawa; + in + { + options.kriswill.diffnav.enable = lib.mkEnableOption "diffnav git diff pager"; - config = lib.mkIf config.kriswill.diffnav.enable { - home.packages = [ pkgs.diffnav ]; + config = lib.mkIf config.kriswill.diffnav.enable { + home.packages = [ pkgs.diffnav ]; - programs.delta = { - enable = true; - enableGitIntegration = false; - options = { - syntax-theme = "ansi"; - dark = true; - tabs = 2; + programs.delta = { + enable = true; + enableGitIntegration = false; + options = { + syntax-theme = "ansi"; + dark = true; + tabs = 2; - # File headers - file-style = "omit"; - file-decoration-style = "none"; + # File headers + file-style = "omit"; + file-decoration-style = "none"; - # Line numbers - line-numbers = true; - line-numbers-left-format = "{nm:>4} "; - line-numbers-right-format = "│ {np:>4} "; - line-numbers-left-style = "${kanagawa.sumiInk4} dim"; - line-numbers-right-style = "${kanagawa.sumiInk2} dim"; - line-numbers-zero-style = "${kanagawa.sumiInk4} dim"; - line-numbers-plus-style = "${kanagawa.sumiInk4} dim"; - line-numbers-minus-style = "${kanagawa.sumiInk4} dim"; + # Line numbers + line-numbers = true; + line-numbers-left-format = "{nm:>4} "; + line-numbers-right-format = "│ {np:>4} "; + line-numbers-left-style = "${kanagawa.sumiInk4} dim"; + line-numbers-right-style = "${kanagawa.sumiInk2} dim"; + line-numbers-zero-style = "${kanagawa.sumiInk4} dim"; + line-numbers-plus-style = "${kanagawa.sumiInk4} dim"; + line-numbers-minus-style = "${kanagawa.sumiInk4} dim"; - # Diff colors — very subtle tints on sumiInk1 - plus-style = "syntax \"${kanagawa.diffAddBg}\""; - plus-emph-style = "syntax \"${kanagawa.diffAddEmphBg}\""; - minus-style = "syntax \"${kanagawa.diffRemoveBg}\""; - minus-emph-style = "syntax \"${kanagawa.diffRemoveEmphBg}\""; + # Diff colors — very subtle tints on sumiInk1 + plus-style = "syntax \"${kanagawa.diffAddBg}\""; + plus-emph-style = "syntax \"${kanagawa.diffAddEmphBg}\""; + minus-style = "syntax \"${kanagawa.diffRemoveBg}\""; + minus-emph-style = "syntax \"${kanagawa.diffRemoveEmphBg}\""; - # Hunk headers - hunk-header-style = kanagawa.fujiGray; - hunk-header-file-style = "${kanagawa.fujiGray} dim"; - hunk-header-line-number-style = kanagawa.waveBlue1; - hunk-header-decoration-style = "${kanagawa.sumiInk2} ol ul"; + # Hunk headers + hunk-header-style = kanagawa.fujiGray; + hunk-header-file-style = "${kanagawa.fujiGray} dim"; + hunk-header-line-number-style = kanagawa.waveBlue1; + hunk-header-decoration-style = "${kanagawa.sumiInk2} ol ul"; - # Wrapping - wrap-left-symbol = " "; - wrap-right-symbol = " "; - wrap-right-prefix-symbol = " "; + # Wrapping + wrap-left-symbol = " "; + wrap-right-symbol = " "; + wrap-right-prefix-symbol = " "; - # Navigation — side-by-side and navigate are controlled by diffnav - }; - }; + # Navigation — side-by-side and navigate are controlled by diffnav + }; + }; - programs.git.settings.pager = { - diff = "diffnav"; - show = "diffnav"; + programs.git.settings.pager = { + diff = "diffnav"; + show = "diffnav"; + }; + }; }; - }; } diff --git a/modules/home-manager/direnv-nom.nix b/modules/home-manager/direnv-nom.nix index 3782a04a..cd926964 100644 --- a/modules/home-manager/direnv-nom.nix +++ b/modules/home-manager/direnv-nom.nix @@ -5,96 +5,100 @@ # as hm-nix-direnv.sh, so zz-nom-wrapper.sh loads after it and can redefine # _nix(). Only print-dev-env is wrapped (it triggers the actual build); other # subcommands like build and flake archive pass through unchanged. +{ ... }: { - lib, - config, - pkgs, - ... -}: -let - cfg = config.kriswill.direnv-nom; - nom = lib.getExe pkgs.nix-output-monitor; - readlink = "${pkgs.coreutils}/bin/readlink"; - diffCmd = - if cfg.diff == "nvd" then - "${lib.getExe pkgs.nvd} diff" - else if cfg.diff == "native" then - "nix store diff-closures" - else - null; -in -{ - options.kriswill.direnv-nom = { - enable = lib.mkEnableOption "nom integration for nix-direnv"; - diff = lib.mkOption { - type = lib.types.enum [ - "nvd" - "native" - "none" - ]; - default = "nvd"; - description = "Closure diff tool: nvd (nh-style formatted output), native (nix store diff-closures), or none to disable"; - }; - }; + flake.modules.homeManager.direnv-nom = + { + lib, + config, + pkgs, + ... + }: + let + cfg = config.kriswill.direnv-nom; + nom = lib.getExe pkgs.nix-output-monitor; + readlink = "${pkgs.coreutils}/bin/readlink"; + diffCmd = + if cfg.diff == "nvd" then + "${lib.getExe pkgs.nvd} diff" + else if cfg.diff == "native" then + "nix store diff-closures" + else + null; + in + { + options.kriswill.direnv-nom = { + enable = lib.mkEnableOption "nom integration for nix-direnv"; + diff = lib.mkOption { + type = lib.types.enum [ + "nvd" + "native" + "none" + ]; + default = "nvd"; + description = "Closure diff tool: nvd (nh-style formatted output), native (nix store diff-closures), or none to disable"; + }; + }; - config = - lib.mkIf (cfg.enable && config.programs.direnv.enable && config.programs.direnv.nix-direnv.enable) - { - programs.direnv.config.warn_timeout = "0s"; + config = + lib.mkIf (cfg.enable && config.programs.direnv.enable && config.programs.direnv.nix-direnv.enable) + { + programs.direnv.config.warn_timeout = "0s"; - xdg.configFile."direnv/lib/zz-nom-wrapper.sh".text = '' - # Wrap nix-direnv's _nix() to pipe build logs through nix-output-monitor. - # Loaded after hm-nix-direnv.sh (alphabetical: zz > hm). - if declare -f _nix > /dev/null 2>&1; then - eval "$(declare -f _nix | sed '1s/_nix/_nix_direnv_original/')" + xdg.configFile."direnv/lib/zz-nom-wrapper.sh".text = '' + # Wrap nix-direnv's _nix() to pipe build logs through nix-output-monitor. + # Loaded after hm-nix-direnv.sh (alphabetical: zz > hm). + if declare -f _nix > /dev/null 2>&1; then + eval "$(declare -f _nix | sed '1s/_nix/_nix_direnv_original/')" - _nix() { - case "''${1:-}" in - print-dev-env) - ${lib.optionalString (diffCmd != null) '' - # Capture old profile store path before the build - local _nom_old="" - local _nom_tmp_profile="" - local _nom_arg - local _nom_next_is_profile=0 - for _nom_arg in "$@"; do - if [[ $_nom_next_is_profile -eq 1 ]]; then - _nom_tmp_profile="$_nom_arg" - break - fi - [[ "$_nom_arg" == "--profile" ]] && _nom_next_is_profile=1 - done - if [[ -n "$_nom_tmp_profile" ]]; then - local _nom_layout_dir - _nom_layout_dir="$(dirname "$_nom_tmp_profile")" - for _nom_f in "$_nom_layout_dir"/flake-profile-*; do - [[ -e "$_nom_f" ]] || continue - [[ "$_nom_f" == *.rc ]] && continue - _nom_old="$(${readlink} -f "$_nom_f")" - break - done - fi - ''} - _nix_direnv_original --log-format internal-json -v "$@" 2> >("${nom}" --json) - local _nom_rc=$? - ${lib.optionalString (diffCmd != null) '' - # Show closure diff if build succeeded and profile changed - if [[ $_nom_rc -eq 0 && -n "$_nom_tmp_profile" && -e "$_nom_tmp_profile" ]]; then - local _nom_new - _nom_new="$(${readlink} -f "$_nom_tmp_profile")" - if [[ -n "$_nom_old" && -n "$_nom_new" && "$_nom_old" != "$_nom_new" ]]; then - ${diffCmd} "$_nom_old" "$_nom_new" >&2 || true - fi - fi - ''} - return "$_nom_rc" - ;; - *) - _nix_direnv_original "$@" - ;; - esac - } - fi - ''; - }; + _nix() { + case "''${1:-}" in + print-dev-env) + ${lib.optionalString (diffCmd != null) '' + # Capture old profile store path before the build + local _nom_old="" + local _nom_tmp_profile="" + local _nom_arg + local _nom_next_is_profile=0 + for _nom_arg in "$@"; do + if [[ $_nom_next_is_profile -eq 1 ]]; then + _nom_tmp_profile="$_nom_arg" + break + fi + [[ "$_nom_arg" == "--profile" ]] && _nom_next_is_profile=1 + done + if [[ -n "$_nom_tmp_profile" ]]; then + local _nom_layout_dir + _nom_layout_dir="$(dirname "$_nom_tmp_profile")" + for _nom_f in "$_nom_layout_dir"/flake-profile-*; do + [[ -e "$_nom_f" ]] || continue + [[ "$_nom_f" == *.rc ]] && continue + _nom_old="$(${readlink} -f "$_nom_f")" + break + done + fi + ''} + _nix_direnv_original --log-format internal-json -v "$@" 2> >("${nom}" --json) + local _nom_rc=$? + ${lib.optionalString (diffCmd != null) '' + # Show closure diff if build succeeded and profile changed + if [[ $_nom_rc -eq 0 && -n "$_nom_tmp_profile" && -e "$_nom_tmp_profile" ]]; then + local _nom_new + _nom_new="$(${readlink} -f "$_nom_tmp_profile")" + if [[ -n "$_nom_old" && -n "$_nom_new" && "$_nom_old" != "$_nom_new" ]]; then + ${diffCmd} "$_nom_old" "$_nom_new" >&2 || true + fi + fi + ''} + return "$_nom_rc" + ;; + *) + _nix_direnv_original "$@" + ;; + esac + } + fi + ''; + }; + }; } diff --git a/modules/home-manager/fastfetch/default.nix b/modules/home-manager/fastfetch/default.nix index 62059135..1ace810c 100644 --- a/modules/home-manager/fastfetch/default.nix +++ b/modules/home-manager/fastfetch/default.nix @@ -1,160 +1,164 @@ +{ ... }: { - pkgs, - lib, - config, - ... -}: + flake.modules.homeManager.fastfetch = + { + pkgs, + lib, + config, + ... + }: -{ - options.kriswill.fastfetch.enable = lib.mkEnableOption "Kris' Fastfetch"; - config = lib.mkIf config.kriswill.fastfetch.enable { - # remove home manager module if this is enabled - programs.fastfetch.enable = lib.mkForce false; - home.packages = [ pkgs.fastfetch ]; + { + options.kriswill.fastfetch.enable = lib.mkEnableOption "Kris' Fastfetch"; + config = lib.mkIf config.kriswill.fastfetch.enable { + # remove home manager module if this is enabled + programs.fastfetch.enable = lib.mkForce false; + home.packages = [ pkgs.fastfetch ]; - xdg.configFile."fastfetch/config.jsonc".text = # json - '' - { - "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", - "logo": { - "type": "kitty-icat", - "source": "${./apple-logo-medium.png}" - //"width": 30, - //"height": 18 - }, - "modules": [ - "title", - "separator", - { - "type": "os", - "key": " OS", - "keyColor": "yellow", - "format": "{2}" - }, - { - "type": "os", - "key": "├", // Just get your distro's logo off nerdfonts.com - "keyColor": "yellow", - "format": "{6}{?6} {?}{10} {8}" - }, - /* - { - "type": "kernel", - "key": "├", - "keyColor": "yellow" - }, - { - "type": "packages", - "key": "├󰏖", - "keyColor": "yellow" - }, - */ + xdg.configFile."fastfetch/config.jsonc".text = # json + '' { - "type": "shell", - "key": "└", - "keyColor": "yellow" - }, - "break", + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "logo": { + "type": "kitty-icat", + "source": "${./apple-logo-medium.png}" + //"width": 30, + //"height": 18 + }, + "modules": [ + "title", + "separator", + { + "type": "os", + "key": " OS", + "keyColor": "yellow", + "format": "{2}" + }, + { + "type": "os", + "key": "├", // Just get your distro's logo off nerdfonts.com + "keyColor": "yellow", + "format": "{6}{?6} {?}{10} {8}" + }, + /* + { + "type": "kernel", + "key": "├", + "keyColor": "yellow" + }, + { + "type": "packages", + "key": "├󰏖", + "keyColor": "yellow" + }, + */ + { + "type": "shell", + "key": "└", + "keyColor": "yellow" + }, + "break", - { - "type": "wm", - "key": " DE/WM", - "keyColor": "blue" - }, - /* - { - "type": "lm", - "key": "├󰧨", - "keyColor": "blue" - }, - { - "type": "wmtheme", - "key": "├󰉼", - "keyColor": "blue" - }, - { - "type": "icons", - "key": "├󰀻", - "keyColor": "blue" - }, - */ - { - "type": "terminal", - "key": "└", - "keyColor": "blue" - }, - /* - { - "type": "wallpaper", - "key": "└󰸉", - "keyColor": "blue" - }, - */ + { + "type": "wm", + "key": " DE/WM", + "keyColor": "blue" + }, + /* + { + "type": "lm", + "key": "├󰧨", + "keyColor": "blue" + }, + { + "type": "wmtheme", + "key": "├󰉼", + "keyColor": "blue" + }, + { + "type": "icons", + "key": "├󰀻", + "keyColor": "blue" + }, + */ + { + "type": "terminal", + "key": "└", + "keyColor": "blue" + }, + /* + { + "type": "wallpaper", + "key": "└󰸉", + "keyColor": "blue" + }, + */ - "break", - { - "type": "host", - "key": "󰌢 PC", - "keyColor": "green" - }, - { - "type": "cpu", - "key": "├", - "keyColor": "green" - }, - { - "type": "gpu", - "key": "├󰘚", - "keyColor": "green" - }, - { - "type": "disk", - "key": "├", - "keyColor": "green" - }, - { - "type": "memory", - "key": "└󰑭", - "keyColor": "green" - }, - /* - { - "type": "swap", - "key": "├󰓡", - "keyColor": "green" - }, - { - "type": "uptime", - "key": "├󰅐", - "keyColor": "green" - }, - { - "type": "display", - "key": "└󰍹", - "keyColor": "green" - }, - "break", - { - "type": "sound", - "key": " SOUND", - "keyColor": "cyan" - }, - { - "type": "player", - "key": "├󰥠", - "keyColor": "cyan" - }, - { - "type": "media", - "key": "└󰝚", - "keyColor": "cyan" - }, - */ + "break", + { + "type": "host", + "key": "󰌢 PC", + "keyColor": "green" + }, + { + "type": "cpu", + "key": "├", + "keyColor": "green" + }, + { + "type": "gpu", + "key": "├󰘚", + "keyColor": "green" + }, + { + "type": "disk", + "key": "├", + "keyColor": "green" + }, + { + "type": "memory", + "key": "└󰑭", + "keyColor": "green" + }, + /* + { + "type": "swap", + "key": "├󰓡", + "keyColor": "green" + }, + { + "type": "uptime", + "key": "├󰅐", + "keyColor": "green" + }, + { + "type": "display", + "key": "└󰍹", + "keyColor": "green" + }, + "break", + { + "type": "sound", + "key": " SOUND", + "keyColor": "cyan" + }, + { + "type": "player", + "key": "├󰥠", + "keyColor": "cyan" + }, + { + "type": "media", + "key": "└󰝚", + "keyColor": "cyan" + }, + */ - "break", - "colors" - ] - } - ''; - }; + "break", + "colors" + ] + } + ''; + }; + }; } diff --git a/modules/home-manager/firefox/default.nix b/modules/home-manager/firefox/default.nix index e5734f4e..38ff4f5f 100644 --- a/modules/home-manager/firefox/default.nix +++ b/modules/home-manager/firefox/default.nix @@ -1,100 +1,104 @@ +{ ... }: { - config, - lib, - pkgs, - ... -}: -let - user_js = "${./user.js}"; - inherit (pkgs.nur.repos.rycee) firefox-addons; -in -{ - options.kriswill.firefox.enable = lib.mkEnableOption "Kris' Firefox"; - config = lib.mkIf config.kriswill.firefox.enable { - home = { - file = { - ".mozilla/firefox/${config.home.username}/user.js".source = - config.lib.file.mkOutOfStoreSymlink user_js; - }; - }; - programs.firefox = { - enable = true; - profiles = { - "${config.home.username}" = { - id = 0; - extensions = with firefox-addons; [ - ublock-origin - onepassword-password-manager - darkreader - ]; - search = { - default = "Searx"; - force = true; - engines = { - "Searx" = { - urls = [ - { - template = "https://searx.tiekoetter.com/search"; - params = [ + flake.modules.homeManager.firefox = + { + config, + lib, + pkgs, + ... + }: + let + user_js = "${./user.js}"; + inherit (pkgs.nur.repos.rycee) firefox-addons; + in + { + options.kriswill.firefox.enable = lib.mkEnableOption "Kris' Firefox"; + config = lib.mkIf config.kriswill.firefox.enable { + home = { + file = { + ".mozilla/firefox/${config.home.username}/user.js".source = + config.lib.file.mkOutOfStoreSymlink user_js; + }; + }; + programs.firefox = { + enable = true; + profiles = { + "${config.home.username}" = { + id = 0; + extensions = with firefox-addons; [ + ublock-origin + onepassword-password-manager + darkreader + ]; + search = { + default = "Searx"; + force = true; + engines = { + "Searx" = { + urls = [ { - name = "q"; - value = "{searchTerms}"; + template = "https://searx.tiekoetter.com/search"; + params = [ + { + name = "q"; + value = "{searchTerms}"; + } + ]; } ]; - } - ]; - definedAliases = [ "@sx" ]; - }; - "Nix Packages" = { - urls = [ - { - template = "https://search.nixos.org/packages"; - params = [ + definedAliases = [ "@sx" ]; + }; + "Nix Packages" = { + urls = [ { - name = "type"; - value = "packages"; + template = "https://search.nixos.org/packages"; + params = [ + { + name = "type"; + value = "packages"; + } + { + name = "query"; + value = "{searchTerms}"; + } + ]; } + ]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = [ "@np" ]; + }; + "Home Manager Options" = { + urls = [ { - name = "query"; - value = "{searchTerms}"; + template = "https://mipmip.github.io/home-manager-option-search/"; + params = [ + { + name = "query"; + value = "{searchTerms}"; + } + ]; } ]; - } - ]; - icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - definedAliases = [ "@np" ]; - }; - "Home Manager Options" = { - urls = [ - { - template = "https://mipmip.github.io/home-manager-option-search/"; - params = [ + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = [ "@hm" ]; + }; + "NixOS Wiki" = { + urls = [ { - name = "query"; - value = "{searchTerms}"; + template = "https://nixos.wiki/index.php?search={searchTerms}"; } ]; - } - ]; - icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - definedAliases = [ "@hm" ]; - }; - "NixOS Wiki" = { - urls = [ - { - template = "https://nixos.wiki/index.php?search={searchTerms}"; - } - ]; - iconUpdateURL = "https://nixos.wiki/favicon.png"; - updateInterval = 24 * 60 * 60 * 1000; # every day - definedAliases = [ "@nw" ]; + iconUpdateURL = "https://nixos.wiki/favicon.png"; + updateInterval = 24 * 60 * 60 * 1000; # every day + definedAliases = [ "@nw" ]; + }; + "Bing".metaData.hidden = true; + "Google".metaData.alias = "@g"; # builtin engines only support specifying one additional alias + }; }; - "Bing".metaData.hidden = true; - "Google".metaData.alias = "@g"; # builtin engines only support specifying one additional alias }; }; }; }; }; - }; } diff --git a/modules/home-manager/ghostty/default.nix b/modules/home-manager/ghostty/default.nix index 7f8b617a..aa5f9d9b 100644 --- a/modules/home-manager/ghostty/default.nix +++ b/modules/home-manager/ghostty/default.nix @@ -1,23 +1,27 @@ +{ ... }: { - lib, - config, - ... -}: -{ - options.kriswill.ghostty.enable = lib.mkEnableOption "Kris' Ghostty"; - config = lib.mkIf config.kriswill.ghostty.enable ( - let - configDir = config.home.homeDirectory + "/src/dotfiles/config/ghostty"; - ln = config.lib.file.mkOutOfStoreSymlink; - in + flake.modules.homeManager.ghostty = + { + lib, + config, + ... + }: { - xdg.configFile = { - "ghostty/config".source = ln configDir + "/config"; - }; - # Symlink ghostty terminfo to ~/.terminfo so it's discoverable - # before TERMINFO_DIRS is set (fixes SSH sessions where the - # nix-darwin set-environment script runs before env vars are exported) - home.file.".terminfo".source = ln "/Applications/Ghostty.app/Contents/Resources/terminfo"; - } - ); + options.kriswill.ghostty.enable = lib.mkEnableOption "Kris' Ghostty"; + config = lib.mkIf config.kriswill.ghostty.enable ( + let + configDir = config.home.homeDirectory + "/src/dotfiles/config/ghostty"; + ln = config.lib.file.mkOutOfStoreSymlink; + in + { + xdg.configFile = { + "ghostty/config".source = ln configDir + "/config"; + }; + # Symlink ghostty terminfo to ~/.terminfo so it's discoverable + # before TERMINFO_DIRS is set (fixes SSH sessions where the + # nix-darwin set-environment script runs before env vars are exported) + home.file.".terminfo".source = ln "/Applications/Ghostty.app/Contents/Resources/terminfo"; + } + ); + }; } diff --git a/modules/home-manager/git.nix b/modules/home-manager/git.nix index 646839eb..e8734bf2 100644 --- a/modules/home-manager/git.nix +++ b/modules/home-manager/git.nix @@ -1,94 +1,98 @@ +{ ... }: { - lib, - config, - pkgs, - ... -}: - -{ - options.kriswill.git.enable = lib.mkEnableOption "Kris' git"; + flake.modules.homeManager.git = + { + lib, + config, + pkgs, + ... + }: - config = lib.mkIf config.kriswill.git.enable ( - let - rg = "${pkgs.ripgrep}/bin/rg"; - email = "115474+kriswill@users.noreply.github.com"; - sshPubKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBxqhXoAlCKYNwsB1YrszftURThiCI94oeR0W9EDhrLy"; - in { - home.packages = with pkgs; [ - git-crypt # git files encryption - tig # diff and commit view - ]; + options.kriswill.git.enable = lib.mkEnableOption "Kris' git"; + + config = lib.mkIf config.kriswill.git.enable ( + let + rg = "${pkgs.ripgrep}/bin/rg"; + email = "115474+kriswill@users.noreply.github.com"; + sshPubKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBxqhXoAlCKYNwsB1YrszftURThiCI94oeR0W9EDhrLy"; + in + { + home.packages = with pkgs; [ + git-crypt # git files encryption + tig # diff and commit view + ]; - programs.gh.enable = true; + programs.gh.enable = true; - xdg.configFile."git/allowed_signers".text = '' - ${email} ${sshPubKey} - ''; + xdg.configFile."git/allowed_signers".text = '' + ${email} ${sshPubKey} + ''; - programs.git = { - enable = true; - signing.format = null; - lfs.enable = true; - ignores = [ - "*.direnv" - "*.envrc" - ".DS_Store" - ".idea/" - ".claude" - "CLAUDE.md" - ".mcp.json" - ]; - settings = { - user = { - inherit email; - name = "Kris Williams"; - signingkey = sshPubKey; - }; - core.editor = "nvim"; - init.defaultBranch = "main"; - pull.rebase = false; - push.autoSetupRemote = true; - merge = { - conflictStyle = "zdiff3"; - tool = "vim_mergetool"; - }; - mergetool."vim_mergetool" = { - cmd = ''nvim -f -c "MergetoolStart" "$MERGED" "$BASE" "$LOCAL" "$REMOTE"''; - prompt = false; - }; - gpg.format = "ssh"; - gpg.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"; - gpg.ssh.allowedSignersFile = "~/.config/git/allowed_signers"; - commit.gpgsign = true; - tag.gpgsign = true; - url = { - "https://github.com/".insteadOf = "gh:"; - "ssh://git@github.com".pushInsteadOf = "gh:"; - "https://gitlab.com/".insteadOf = "gl:"; - "ssh://git@gitlab.com".pushInsteadOf = "gl:"; - }; - filter."normalize-podman-settings" = { - clean = ''${pkgs.jq}/bin/jq 'del(."window.bounds", ."titleBar.searchBar".remindAt, ."statusbarProviders.showProviders".remindAt)' ''; - smudge = "cat"; - }; - alias = { - amend = "commit --amend -m"; - fixup = "!f(){ git reset --soft HEAD~\${1} && git commit --amend -C HEAD; };f"; - # lines of code - loc = ''!f(){ git ls-files | ${rg} "\.''${1}" | xargs wc -l; };f''; - br = "branch"; - co = "checkout"; - st = "status"; - ls = "!git log --pretty=format:'%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]%Creset %G?' --color=always --decorate \"$@\" | sed 's/ G$/ 🔒/;s/ N$/ ➖/;s/ [UE]$/ 🔑/;s/ [BXYR]$/ ⚠️/' | less -RFX"; - ll = "!git log --pretty=format:'%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]%Creset %G?' --color=always --decorate --numstat \"$@\" | sed 's/ G$/ 🔒/;s/ N$/ ➖/;s/ [UE]$/ 🔑/;s/ [BXYR]$/ ⚠️/' | less -RFX"; - cm = "commit -m"; - ca = "commit -am"; - dc = "diff --cached"; - }; - }; - } - // (pkgs.sxm.git or { }); - } - ); + programs.git = { + enable = true; + signing.format = null; + lfs.enable = true; + ignores = [ + "*.direnv" + "*.envrc" + ".DS_Store" + ".idea/" + ".claude" + "CLAUDE.md" + ".mcp.json" + ]; + settings = { + user = { + inherit email; + name = "Kris Williams"; + signingkey = sshPubKey; + }; + core.editor = "nvim"; + init.defaultBranch = "main"; + pull.rebase = false; + push.autoSetupRemote = true; + merge = { + conflictStyle = "zdiff3"; + tool = "vim_mergetool"; + }; + mergetool."vim_mergetool" = { + cmd = ''nvim -f -c "MergetoolStart" "$MERGED" "$BASE" "$LOCAL" "$REMOTE"''; + prompt = false; + }; + gpg.format = "ssh"; + gpg.ssh.program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"; + gpg.ssh.allowedSignersFile = "~/.config/git/allowed_signers"; + commit.gpgsign = true; + tag.gpgsign = true; + url = { + "https://github.com/".insteadOf = "gh:"; + "ssh://git@github.com".pushInsteadOf = "gh:"; + "https://gitlab.com/".insteadOf = "gl:"; + "ssh://git@gitlab.com".pushInsteadOf = "gl:"; + }; + filter."normalize-podman-settings" = { + clean = ''${pkgs.jq}/bin/jq 'del(."window.bounds", ."titleBar.searchBar".remindAt, ."statusbarProviders.showProviders".remindAt)' ''; + smudge = "cat"; + }; + alias = { + amend = "commit --amend -m"; + fixup = "!f(){ git reset --soft HEAD~\${1} && git commit --amend -C HEAD; };f"; + # lines of code + loc = ''!f(){ git ls-files | ${rg} "\.''${1}" | xargs wc -l; };f''; + br = "branch"; + co = "checkout"; + st = "status"; + ls = "!git log --pretty=format:'%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]%Creset %G?' --color=always --decorate \"$@\" | sed 's/ G$/ 🔒/;s/ N$/ ➖/;s/ [UE]$/ 🔑/;s/ [BXYR]$/ ⚠️/' | less -RFX"; + ll = "!git log --pretty=format:'%C(yellow)%h%Cred%d %Creset%s%Cblue [%cn]%Creset %G?' --color=always --decorate --numstat \"$@\" | sed 's/ G$/ 🔒/;s/ N$/ ➖/;s/ [UE]$/ 🔑/;s/ [BXYR]$/ ⚠️/' | less -RFX"; + cm = "commit -m"; + ca = "commit -am"; + dc = "diff --cached"; + }; + }; + } + // (pkgs.sxm.git or { }); + } + ); + }; } diff --git a/modules/home-manager/glow/default.nix b/modules/home-manager/glow/default.nix index a9d51a86..638ad443 100644 --- a/modules/home-manager/glow/default.nix +++ b/modules/home-manager/glow/default.nix @@ -1,34 +1,38 @@ +{ ... }: { - pkgs, - config, - lib, - ... -}: -let - cfg = config.kriswill.glow; - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.modules) mkIf; - stylePath = "${config.home.homeDirectory}/Library/Preferences/glow/kanagawa-dragon.json"; -in -{ - options.kriswill.glow = { - enable = mkEnableOption "glow"; - stylePath = mkOption { - type = lib.types.str; - readOnly = true; - default = stylePath; - description = "Absolute path to the glow style JSON, for other modules to reference."; - }; - }; - config = mkIf cfg.enable { - home.packages = with pkgs; [ glow ]; + flake.modules.homeManager.glow = + { + pkgs, + config, + lib, + ... + }: + let + cfg = config.kriswill.glow; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf; + stylePath = "${config.home.homeDirectory}/Library/Preferences/glow/kanagawa-dragon.json"; + in + { + options.kriswill.glow = { + enable = mkEnableOption "glow"; + stylePath = mkOption { + type = lib.types.str; + readOnly = true; + default = stylePath; + description = "Absolute path to the glow style JSON, for other modules to reference."; + }; + }; + config = mkIf cfg.enable { + home.packages = with pkgs; [ glow ]; - home.file = { - "Library/Preferences/glow/kanagawa-dragon.json".source = ./kanagawa-dragon.json; - "Library/Preferences/glow/glow.yml".text = '' - ${builtins.readFile ./glow.yml} - style: "${stylePath}" - ''; + home.file = { + "Library/Preferences/glow/kanagawa-dragon.json".source = ./kanagawa-dragon.json; + "Library/Preferences/glow/glow.yml".text = '' + ${builtins.readFile ./glow.yml} + style: "${stylePath}" + ''; + }; + }; }; - }; } diff --git a/modules/home-manager/karabiner/default.nix b/modules/home-manager/karabiner/default.nix index 42e348a6..94578a8e 100644 --- a/modules/home-manager/karabiner/default.nix +++ b/modules/home-manager/karabiner/default.nix @@ -1,19 +1,23 @@ +{ ... }: { - lib, - config, - ... -}: -{ - options.kriswill.karabiner.enable = lib.mkEnableOption "Kris' Karabiner Elements"; - config = lib.mkIf config.kriswill.karabiner.enable ( - let - configDir = config.home.homeDirectory + "/src/dotfiles/config/karabiner"; - ln = config.lib.file.mkOutOfStoreSymlink; - in + flake.modules.homeManager.karabiner = + { + lib, + config, + ... + }: { - xdg.configFile = { - "karabiner/karabiner.json".source = ln (configDir + "/karabiner.json"); - }; - } - ); + options.kriswill.karabiner.enable = lib.mkEnableOption "Kris' Karabiner Elements"; + config = lib.mkIf config.kriswill.karabiner.enable ( + let + configDir = config.home.homeDirectory + "/src/dotfiles/config/karabiner"; + ln = config.lib.file.mkOutOfStoreSymlink; + in + { + xdg.configFile = { + "karabiner/karabiner.json".source = ln (configDir + "/karabiner.json"); + }; + } + ); + }; } diff --git a/modules/home-manager/kitty/default.nix b/modules/home-manager/kitty/default.nix index 10ce20b7..7144b521 100644 --- a/modules/home-manager/kitty/default.nix +++ b/modules/home-manager/kitty/default.nix @@ -1,34 +1,38 @@ -{ lib, config, ... }: +{ ... }: { - options.kriswill.kitty.enable = lib.mkEnableOption "Kris' kitty"; - config = lib.mkIf config.kriswill.kitty.enable { - programs.kitty = { - enable = true; - font = { - name = "JetBrainsMono Nerd Font Mono"; - size = 16.0; + flake.modules.homeManager.kitty = + { lib, config, ... }: + { + options.kriswill.kitty.enable = lib.mkEnableOption "Kris' kitty"; + config = lib.mkIf config.kriswill.kitty.enable { + programs.kitty = { + enable = true; + font = { + name = "JetBrainsMono Nerd Font Mono"; + size = 16.0; + }; + settings = { + update_check_interval = 0; + # fade | slant | separator | powerline | custom | hidden + tab_bar_style = "powerline"; + # angled | slanted | round + tab_powerline_style = "slanted"; + placement_strategy = "top-left"; + window_margin_width = "0"; + window_padding_width = "5"; + hide_window_decorations = "titlebar-only"; + cursor_blink_interval = 0; + macos_show_window_title_in = "none"; + }; + shellIntegration = { + mode = "enabled"; + enableZshIntegration = true; + }; + extraConfig = '' + include theme.conf + ''; + }; + xdg.configFile."kitty/theme.conf".source = ./kanagawa.conf; }; - settings = { - update_check_interval = 0; - # fade | slant | separator | powerline | custom | hidden - tab_bar_style = "powerline"; - # angled | slanted | round - tab_powerline_style = "slanted"; - placement_strategy = "top-left"; - window_margin_width = "0"; - window_padding_width = "5"; - hide_window_decorations = "titlebar-only"; - cursor_blink_interval = 0; - macos_show_window_title_in = "none"; - }; - shellIntegration = { - mode = "enabled"; - enableZshIntegration = true; - }; - extraConfig = '' - include theme.conf - ''; }; - xdg.configFile."kitty/theme.conf".source = ./kanagawa.conf; - }; } diff --git a/modules/home-manager/neovide/default.nix b/modules/home-manager/neovide/default.nix index 150c6e5a..c86a5fe0 100644 --- a/modules/home-manager/neovide/default.nix +++ b/modules/home-manager/neovide/default.nix @@ -1,18 +1,22 @@ +{ ... }: { - config, - lib, - pkgs, - ... -}: + flake.modules.homeManager.neovide = + { + config, + lib, + pkgs, + ... + }: -{ - options.kriswill.neovide.enable = lib.mkEnableOption "Kris' neovide"; - config = lib.mkIf config.kriswill.neovide.enable { - home.packages = [ pkgs.neovide ]; + { + options.kriswill.neovide.enable = lib.mkEnableOption "Kris' neovide"; + config = lib.mkIf config.kriswill.neovide.enable { + home.packages = [ pkgs.neovide ]; - # Point neovide at home-manager's wrapped nvim so it inherits - # programs.neovim.extraPackages on PATH (LSP servers, formatters, etc.). - # pkgs.neovide alone would spawn a bare nvim without our extras. - home.sessionVariables.NEOVIDE_NEOVIM_BIN = lib.getExe config.programs.neovim.finalPackage; - }; + # Point neovide at home-manager's wrapped nvim so it inherits + # programs.neovim.extraPackages on PATH (LSP servers, formatters, etc.). + # pkgs.neovide alone would spawn a bare nvim without our extras. + home.sessionVariables.NEOVIDE_NEOVIM_BIN = lib.getExe config.programs.neovim.finalPackage; + }; + }; } diff --git a/modules/home-manager/neovim/default.nix b/modules/home-manager/neovim/default.nix index 41603597..3be00534 100644 --- a/modules/home-manager/neovim/default.nix +++ b/modules/home-manager/neovim/default.nix @@ -1,108 +1,112 @@ +{ ... }: { - config, - lib, - pkgs, - ... -}: + flake.modules.homeManager.neovim = + { + config, + lib, + pkgs, + ... + }: -{ - options.kriswill.neovim.enable = lib.mkEnableOption "Kris' neovim"; - config = lib.mkIf config.kriswill.neovim.enable { - programs.neovim = { - enable = true; - package = pkgs.neovim-unwrapped; - viAlias = true; - vimAlias = true; - withRuby = false; - withPython3 = false; + { + options.kriswill.neovim.enable = lib.mkEnableOption "Kris' neovim"; + config = lib.mkIf config.kriswill.neovim.enable { + programs.neovim = { + enable = true; + package = pkgs.neovim-unwrapped; + viAlias = true; + vimAlias = true; + withRuby = false; + withPython3 = false; - extraPackages = - let - ## Formatters ────────────────────────────────────────────── - formatters = builtins.attrValues { - inherit (pkgs) - biome # JS / TS / JSON (replaces prettier_d for these) - black # Python - gofumpt # stricter gofmt - isort # Python - libxml2 # provides xmllint for XML - nixfmt - prettierd # HTML / markdown via efm - rustfmt # Rust - shfmt - stylua # Lua - yamlfmt # YAML - ; - jsregexp = pkgs.luajitPackages.jsregexp; # luasnip - }; - ## LSP servers ───────────────────────────────────────────── - lsp-servers = builtins.attrValues { - inherit (pkgs) - bash-language-server # Bash - buf # bufls - docker-compose-language-service # Docker Compose - dockerfile-language-server # Dockerfile - efm-langserver # generic LSP that wraps CLI linters (see linters) - go # golang - go-tools - gopls # Go - lua-language-server # Lua (lua_ls) - lua5_1 - luarocks - zk # Markdown LSP (Go-based, replaces marksman which requires .NET/Swift) - nil - tofu-ls # opentofu/terraform - pyright - rust-analyzer # Rust - vscode-langservers-extracted # json, HTML, CSS, ESLint - vtsls # LSP wrapper for typescript extension of vscode - yaml-language-server # YAML (yamlls) - ; - typescript = pkgs.typescript; - }; - ## Linters (invoked by efm-langserver) ───────────────────── - linters = builtins.attrValues { - inherit (pkgs) - gitlint # gitcommit - hadolint # Dockerfile - rumdl # markdown - shellcheck # sh / bash / zsh - yamllint # yaml - ; - }; - ## Tools ─────────────────────────────────────────────────── - tools = builtins.attrValues { - inherit (pkgs) - cargo - cmake - delve # golang debugger `dlv` - fswatch # file watcher - replaces libuv.fs_event in neovim v0.10 - git - gnumake - ghostscript # needed by snacks to render PDFs with the `gs` command - imagemagick - mermaid-cli # mmdc - nodejs - sqlite - tree-sitter - wget - ; - }; - in - formatters ++ lsp-servers ++ linters ++ tools; - }; + extraPackages = + let + ## Formatters ────────────────────────────────────────────── + formatters = builtins.attrValues { + inherit (pkgs) + biome # JS / TS / JSON (replaces prettier_d for these) + black # Python + gofumpt # stricter gofmt + isort # Python + libxml2 # provides xmllint for XML + nixfmt + prettierd # HTML / markdown via efm + rustfmt # Rust + shfmt + stylua # Lua + yamlfmt # YAML + ; + jsregexp = pkgs.luajitPackages.jsregexp; # luasnip + }; + ## LSP servers ───────────────────────────────────────────── + lsp-servers = builtins.attrValues { + inherit (pkgs) + bash-language-server # Bash + buf # bufls + docker-compose-language-service # Docker Compose + dockerfile-language-server # Dockerfile + efm-langserver # generic LSP that wraps CLI linters (see linters) + go # golang + go-tools + gopls # Go + lua-language-server # Lua (lua_ls) + lua5_1 + luarocks + zk # Markdown LSP (Go-based, replaces marksman which requires .NET/Swift) + nil + tofu-ls # opentofu/terraform + pyright + rust-analyzer # Rust + vscode-langservers-extracted # json, HTML, CSS, ESLint + vtsls # LSP wrapper for typescript extension of vscode + yaml-language-server # YAML (yamlls) + ; + typescript = pkgs.typescript; + }; + ## Linters (invoked by efm-langserver) ───────────────────── + linters = builtins.attrValues { + inherit (pkgs) + gitlint # gitcommit + hadolint # Dockerfile + rumdl # markdown + shellcheck # sh / bash / zsh + yamllint # yaml + ; + }; + ## Tools ─────────────────────────────────────────────────── + tools = builtins.attrValues { + inherit (pkgs) + cargo + cmake + delve # golang debugger `dlv` + fswatch # file watcher - replaces libuv.fs_event in neovim v0.10 + git + gnumake + ghostscript # needed by snacks to render PDFs with the `gs` command + imagemagick + mermaid-cli # mmdc + nodejs + sqlite + tree-sitter + wget + ; + }; + in + formatters ++ lsp-servers ++ linters ++ tools; + }; - xdg.configFile = - let - # used to link files from /config/nvim to ~/.config/nvim - nvimDir = config.home.homeDirectory + "/src/dotfiles/config/nvim"; - ln = config.lib.file.mkOutOfStoreSymlink; - in - { - "nvim/lua".source = ln nvimDir + "/lua"; - "nvim/lsp".source = ln nvimDir + "/lsp"; - "nvim/ftplugin".source = ln nvimDir + "/ftplugin"; - "nvim/init.lua".source = ln nvimDir + "/init.lua"; + xdg.configFile = + let + # used to link files from /config/nvim to ~/.config/nvim + nvimDir = config.home.homeDirectory + "/src/dotfiles/config/nvim"; + ln = config.lib.file.mkOutOfStoreSymlink; + in + { + "nvim/lua".source = ln nvimDir + "/lua"; + "nvim/lsp".source = ln nvimDir + "/lsp"; + "nvim/ftplugin".source = ln nvimDir + "/ftplugin"; + "nvim/init.lua".source = ln nvimDir + "/init.lua"; + }; }; - }; + }; } diff --git a/modules/home-manager/oksh/default.nix b/modules/home-manager/oksh/default.nix index 0760adbb..b847be52 100644 --- a/modules/home-manager/oksh/default.nix +++ b/modules/home-manager/oksh/default.nix @@ -1,35 +1,39 @@ +{ ... }: { - lib, - config, - pkgs, - ... -}: -let - cfg = config.kriswill.oksh; + flake.modules.homeManager.oksh = + { + lib, + config, + pkgs, + ... + }: + let + cfg = config.kriswill.oksh; - # oksh-specific starship init script, packaged as a derivation so the - # kshrc can source it from a stable nix-store path instead of a - # hand-maintained working-copy checkout. - starshipInit = pkgs.writeTextFile { - name = "starship-init-oksh.sh"; - text = builtins.readFile ./starship-init.sh; - }; -in -{ - options.kriswill.oksh.enable = lib.mkEnableOption "kris' oksh setup"; + # oksh-specific starship init script, packaged as a derivation so the + # kshrc can source it from a stable nix-store path instead of a + # hand-maintained working-copy checkout. + starshipInit = pkgs.writeTextFile { + name = "starship-init-oksh.sh"; + text = builtins.readFile ./starship-init.sh; + }; + in + { + options.kriswill.oksh.enable = lib.mkEnableOption "kris' oksh setup"; - config = lib.mkIf cfg.enable { - home.packages = [ pkgs.oksh ]; + config = lib.mkIf cfg.enable { + home.packages = [ pkgs.oksh ]; - # $ENV is sourced by oksh on interactive start (POSIX behavior). - home.sessionVariables.ENV = "$HOME/.kshrc"; + # $ENV is sourced by oksh on interactive start (POSIX behavior). + home.sessionVariables.ENV = "$HOME/.kshrc"; - home.file.".kshrc".source = config.lib.file.mkOutOfStoreSymlink ( - "${config.home.homeDirectory}/src/dotfiles/config/oksh/kshrc" - ); + home.file.".kshrc".source = config.lib.file.mkOutOfStoreSymlink ( + "${config.home.homeDirectory}/src/dotfiles/config/oksh/kshrc" + ); - # Install the starship-oksh init script at a stable path so kshrc - # can source it without relying on a working-copy checkout. - home.file.".config/oksh/starship-init.sh".source = starshipInit; - }; + # Install the starship-oksh init script at a stable path so kshrc + # can source it without relying on a working-copy checkout. + home.file.".config/oksh/starship-init.sh".source = starshipInit; + }; + }; } diff --git a/modules/home-manager/podman-desktop/default.nix b/modules/home-manager/podman-desktop/default.nix index 67ded476..8f43b696 100644 --- a/modules/home-manager/podman-desktop/default.nix +++ b/modules/home-manager/podman-desktop/default.nix @@ -1,24 +1,28 @@ +{ ... }: { - config, - lib, - pkgs, - ... -}: -{ - options.kriswill.podman-desktop.enable = lib.mkEnableOption "Podman Desktop"; - config = lib.mkIf config.kriswill.podman-desktop.enable { - home.packages = [ - pkgs.podman-desktop - pkgs.podman - pkgs.k9s - ]; + flake.modules.homeManager.podman-desktop = + { + config, + lib, + pkgs, + ... + }: + { + options.kriswill.podman-desktop.enable = lib.mkEnableOption "Podman Desktop"; + config = lib.mkIf config.kriswill.podman-desktop.enable { + home.packages = [ + pkgs.podman-desktop + pkgs.podman + pkgs.k9s + ]; - xdg.configFile."containers/containers.conf".source = config.lib.file.mkOutOfStoreSymlink ( - config.home.homeDirectory + "/src/dotfiles/config/containers/containers.conf" - ); + xdg.configFile."containers/containers.conf".source = config.lib.file.mkOutOfStoreSymlink ( + config.home.homeDirectory + "/src/dotfiles/config/containers/containers.conf" + ); - xdg.dataFile."containers/podman-desktop/configuration/settings.json".source = - config.lib.file.mkOutOfStoreSymlink - (config.home.homeDirectory + "/src/dotfiles/config/containers/podman-desktop-settings.json"); - }; + xdg.dataFile."containers/podman-desktop/configuration/settings.json".source = + config.lib.file.mkOutOfStoreSymlink + (config.home.homeDirectory + "/src/dotfiles/config/containers/podman-desktop-settings.json"); + }; + }; } diff --git a/modules/home-manager/ssh.nix b/modules/home-manager/ssh.nix index 74e3c3df..f80b519c 100644 --- a/modules/home-manager/ssh.nix +++ b/modules/home-manager/ssh.nix @@ -1,33 +1,37 @@ +{ ... }: { - lib, - config, - pkgs, - ... -}: -{ - options.kriswill.ssh.enable = lib.mkEnableOption "kris' ssh"; - config = lib.mkIf config.kriswill.ssh.enable ( - let - inherit (pkgs.stdenv) isDarwin; - linux-extra-config = '' - IdentityAgent ~/.1password/agent.sock - ''; - darwin-extra-config = '' - IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" - ''; - in + flake.modules.homeManager.ssh = + { + lib, + config, + pkgs, + ... + }: { - programs.ssh = { - enable = true; - includes = [ "${config.home.homeDirectory}/.ssh/config.d/*" ]; - settings."*".ForwardAgent = true; - extraConfig = if isDarwin then darwin-extra-config else linux-extra-config; - enableDefaultConfig = false; - }; - #sops.secrets.hosts = { - # sopsFile = ../../secrets/ssh.yaml; - # path = "${config.home.homeDirectory}/.ssh/config.d/ssh-hosts-internal"; - #}; - } - ); + options.kriswill.ssh.enable = lib.mkEnableOption "kris' ssh"; + config = lib.mkIf config.kriswill.ssh.enable ( + let + inherit (pkgs.stdenv) isDarwin; + linux-extra-config = '' + IdentityAgent ~/.1password/agent.sock + ''; + darwin-extra-config = '' + IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" + ''; + in + { + programs.ssh = { + enable = true; + includes = [ "${config.home.homeDirectory}/.ssh/config.d/*" ]; + settings."*".ForwardAgent = true; + extraConfig = if isDarwin then darwin-extra-config else linux-extra-config; + enableDefaultConfig = false; + }; + #sops.secrets.hosts = { + # sopsFile = ../../secrets/ssh.yaml; + # path = "${config.home.homeDirectory}/.ssh/config.d/ssh-hosts-internal"; + #}; + } + ); + }; } diff --git a/modules/home-manager/starship.nix b/modules/home-manager/starship.nix index 0e33b012..f6a89190 100644 --- a/modules/home-manager/starship.nix +++ b/modules/home-manager/starship.nix @@ -1,15 +1,19 @@ -{ lib, config, ... }: +{ ... }: { - options.kriswill.starship.enable = lib.mkEnableOption "kris' starship"; - config = lib.mkIf config.kriswill.starship.enable { - programs.starship = { - enable = true; - settings = { - # add_newline = false; - aws.disabled = true; - gcloud.disabled = true; - # line_break.disabled = true; + flake.modules.homeManager.starship = + { lib, config, ... }: + { + options.kriswill.starship.enable = lib.mkEnableOption "kris' starship"; + config = lib.mkIf config.kriswill.starship.enable { + programs.starship = { + enable = true; + settings = { + # add_newline = false; + aws.disabled = true; + gcloud.disabled = true; + # line_break.disabled = true; + }; + }; }; }; - }; } diff --git a/modules/home-manager/tmux/default.nix b/modules/home-manager/tmux/default.nix index 55894615..133faa07 100644 --- a/modules/home-manager/tmux/default.nix +++ b/modules/home-manager/tmux/default.nix @@ -1,28 +1,32 @@ +{ ... }: { - lib, - config, - pkgs, - ... -}: -{ - options.kriswill.tmux.enable = lib.mkEnableOption "Kris' tmux"; - config = lib.mkIf config.kriswill.tmux.enable ( - let - configDir = config.home.homeDirectory + "/src/dotfiles/config/tmux"; - ln = config.lib.file.mkOutOfStoreSymlink; - whichKey = pkgs.tmuxPlugins.tmux-which-key; - in + flake.modules.homeManager.tmux = + { + lib, + config, + pkgs, + ... + }: { - home.packages = [ pkgs.tmux ]; - xdg.configFile = { - "tmux/tmux.conf".source = ln configDir + "/tmux.conf"; - "tmux/plugins.conf".text = '' - set -g @tmux-which-key-xdg-enable 1 - run-shell 'mkdir -p ~/.local/share/tmux/plugins/tmux-which-key && touch ~/.local/share/tmux/plugins/tmux-which-key/init.tmux' - run-shell ${whichKey.rtp} - ''; - "tmux/plugins/tmux-which-key/config.yaml".source = ln configDir + "/config.yaml"; - }; - } - ); + options.kriswill.tmux.enable = lib.mkEnableOption "Kris' tmux"; + config = lib.mkIf config.kriswill.tmux.enable ( + let + configDir = config.home.homeDirectory + "/src/dotfiles/config/tmux"; + ln = config.lib.file.mkOutOfStoreSymlink; + whichKey = pkgs.tmuxPlugins.tmux-which-key; + in + { + home.packages = [ pkgs.tmux ]; + xdg.configFile = { + "tmux/tmux.conf".source = ln configDir + "/tmux.conf"; + "tmux/plugins.conf".text = '' + set -g @tmux-which-key-xdg-enable 1 + run-shell 'mkdir -p ~/.local/share/tmux/plugins/tmux-which-key && touch ~/.local/share/tmux/plugins/tmux-which-key/init.tmux' + run-shell ${whichKey.rtp} + ''; + "tmux/plugins/tmux-which-key/config.yaml".source = ln configDir + "/config.yaml"; + }; + } + ); + }; } diff --git a/modules/home-manager/vscode.nix b/modules/home-manager/vscode.nix index c9a6687d..bd525de5 100644 --- a/modules/home-manager/vscode.nix +++ b/modules/home-manager/vscode.nix @@ -1,17 +1,21 @@ -{ lib, config, ... }: +{ ... }: { - options.kriswill.vscode.enable = lib.mkEnableOption "kris' vscode"; - config = lib.mkIf config.kriswill.vscode.enable { - programs.vscode = { - enable = true; - # package= pkgs.vscode; - #package = (pkgs.vscode.override { isInsiders = true; }).overrideAttrs (oldAttrs: rec { - # src = (builtins.fetchTarball { - # url = "https://update.code.visualstudio.com/latest/linux-x64/insider"; - # sha256 = "1lqran4qxczi1vdbchkdgzhh6iq9c7srci30qvr4gwhfxckfw0hk"; - # }); - # version = "latest"; - #}); + flake.modules.homeManager.vscode = + { lib, config, ... }: + { + options.kriswill.vscode.enable = lib.mkEnableOption "kris' vscode"; + config = lib.mkIf config.kriswill.vscode.enable { + programs.vscode = { + enable = true; + # package= pkgs.vscode; + #package = (pkgs.vscode.override { isInsiders = true; }).overrideAttrs (oldAttrs: rec { + # src = (builtins.fetchTarball { + # url = "https://update.code.visualstudio.com/latest/linux-x64/insider"; + # sha256 = "1lqran4qxczi1vdbchkdgzhh6iq9c7srci30qvr4gwhfxckfw0hk"; + # }); + # version = "latest"; + #}); + }; + }; }; - }; } diff --git a/modules/home-manager/yazi/themes/kanagawa-dragon/default.nix b/modules/home-manager/yazi/_themes/kanagawa-dragon/default.nix similarity index 100% rename from modules/home-manager/yazi/themes/kanagawa-dragon/default.nix rename to modules/home-manager/yazi/_themes/kanagawa-dragon/default.nix diff --git a/modules/home-manager/yazi/themes/kanagawa-dragon/flavor.toml b/modules/home-manager/yazi/_themes/kanagawa-dragon/flavor.toml similarity index 100% rename from modules/home-manager/yazi/themes/kanagawa-dragon/flavor.toml rename to modules/home-manager/yazi/_themes/kanagawa-dragon/flavor.toml diff --git a/modules/home-manager/yazi/themes/kanagawa-dragon/tmtheme.xml b/modules/home-manager/yazi/_themes/kanagawa-dragon/tmtheme.xml similarity index 100% rename from modules/home-manager/yazi/themes/kanagawa-dragon/tmtheme.xml rename to modules/home-manager/yazi/_themes/kanagawa-dragon/tmtheme.xml diff --git a/modules/home-manager/yazi/default.nix b/modules/home-manager/yazi/default.nix index 9f5741ee..8e729379 100644 --- a/modules/home-manager/yazi/default.nix +++ b/modules/home-manager/yazi/default.nix @@ -1,62 +1,66 @@ +{ ... }: { - lib, - config, - pkgs, - inputs, - ... -}: -{ - options.kriswill.yazi.enable = lib.mkEnableOption "yazi"; - config = lib.mkIf config.kriswill.yazi.enable { - programs.yazi = { - enable = lib.mkDefault true; - shellWrapperName = "y"; - enableZshIntegration = true; - plugins = { - inherit (pkgs.yaziPlugins) git; - faster-piper = inputs.faster-piper-yazi; - }; - initLua = '' - require("git"):setup() - ''; + flake.modules.homeManager.yazi = + { + lib, + config, + pkgs, + inputs, + ... + }: + { + options.kriswill.yazi.enable = lib.mkEnableOption "yazi"; + config = lib.mkIf config.kriswill.yazi.enable { + programs.yazi = { + enable = lib.mkDefault true; + shellWrapperName = "y"; + enableZshIntegration = true; + plugins = { + inherit (pkgs.yaziPlugins) git; + faster-piper = inputs.faster-piper-yazi; + }; + initLua = '' + require("git"):setup() + ''; - flavors = { - kanagawa-dragon = import ./themes/kanagawa-dragon { inherit lib; }; - }; - theme = { - flavor.dark = "kanagawa-dragon"; - }; - settings = { - mgr.ratio = [ - 1 - 2 - 3 - ]; - plugin = { - prepend_fetchers = [ - { - group = "git"; - url = "*"; - run = "git"; - } - { - group = "git"; - url = "*/"; - run = "git"; - } - ]; - prepend_previewers = [ - { - url = "*.md"; - run = ''faster-piper -- CLICOLOR_FORCE=1 glow -w=$w -s="${config.kriswill.glow.stylePath}" "$1"''; - } - { - url = "*.(py|sh|go|ts|css|yaml|yml|toml|html|conf|json|csv)"; - run = "bat"; - } - ]; + flavors = { + kanagawa-dragon = import ./_themes/kanagawa-dragon { inherit lib; }; + }; + theme = { + flavor.dark = "kanagawa-dragon"; + }; + settings = { + mgr.ratio = [ + 1 + 2 + 3 + ]; + plugin = { + prepend_fetchers = [ + { + group = "git"; + url = "*"; + run = "git"; + } + { + group = "git"; + url = "*/"; + run = "git"; + } + ]; + prepend_previewers = [ + { + url = "*.md"; + run = ''faster-piper -- CLICOLOR_FORCE=1 glow -w=$w -s="${config.kriswill.glow.stylePath}" "$1"''; + } + { + url = "*.(py|sh|go|ts|css|yaml|yml|toml|html|conf|json|csv)"; + run = "bat"; + } + ]; + }; + }; }; }; }; - }; } diff --git a/modules/home-manager/zk/default.nix b/modules/home-manager/zk/default.nix index 52a343d3..410095c5 100644 --- a/modules/home-manager/zk/default.nix +++ b/modules/home-manager/zk/default.nix @@ -1,18 +1,22 @@ +{ ... }: { - config, - lib, - ... -}: -let - cfg = config.kriswill.zk; - inherit (lib.options) mkEnableOption; - inherit (lib.modules) mkIf; -in -{ - options.kriswill.zk = { - enable = mkEnableOption "zk"; - }; - config = mkIf cfg.enable { - programs.zk.enable = true; - }; + flake.modules.homeManager.zk = + { + config, + lib, + ... + }: + let + cfg = config.kriswill.zk; + inherit (lib.options) mkEnableOption; + inherit (lib.modules) mkIf; + in + { + options.kriswill.zk = { + enable = mkEnableOption "zk"; + }; + config = mkIf cfg.enable { + programs.zk.enable = true; + }; + }; } diff --git a/modules/home-manager/zsh/default.nix b/modules/home-manager/zsh/default.nix index f90885dc..d3487842 100644 --- a/modules/home-manager/zsh/default.nix +++ b/modules/home-manager/zsh/default.nix @@ -1,48 +1,52 @@ +{ ... }: { - lib, - config, - pkgs, - ... -}: + flake.modules.homeManager.zsh = + { + lib, + config, + pkgs, + ... + }: -{ - options.kriswill.zsh.enable = lib.mkEnableOption "kris' zsh"; - config = lib.mkIf config.kriswill.zsh.enable { - programs.zsh = { - enable = true; - autosuggestion.enable = true; - enableCompletion = true; - syntaxHighlighting = { - enable = true; - }; - history = { - size = 100000; - save = 10000000; - }; + { + options.kriswill.zsh.enable = lib.mkEnableOption "kris' zsh"; + config = lib.mkIf config.kriswill.zsh.enable { + programs.zsh = { + enable = true; + autosuggestion.enable = true; + enableCompletion = true; + syntaxHighlighting = { + enable = true; + }; + history = { + size = 100000; + save = 10000000; + }; - shellAliases = { - ls = "${lib.getExe pkgs.eza} --icons --hyperlink"; - ld = "ls -D"; - ll = "ls -lhF"; - la = "ls -lahF"; - l = "la"; - t = "ls -T -I '.git'"; - cat = "bat"; - ".." = "cd ..;"; - "..." = ".. .."; - ff = "${lib.getExe pkgs.fastfetch}"; - gv = "NVIM_APPNAME=gman nvim"; - claude-yolo = "claude --dangerously-skip-permissions"; - cyolo = "claude --dangerously-skip-permissions"; - }; + shellAliases = { + ls = "${lib.getExe pkgs.eza} --icons --hyperlink"; + ld = "ls -D"; + ll = "ls -lhF"; + la = "ls -lahF"; + l = "la"; + t = "ls -T -I '.git'"; + cat = "bat"; + ".." = "cd ..;"; + "..." = ".. .."; + ff = "${lib.getExe pkgs.fastfetch}"; + gv = "NVIM_APPNAME=gman nvim"; + claude-yolo = "claude --dangerously-skip-permissions"; + cyolo = "claude --dangerously-skip-permissions"; + }; - initContent = builtins.readFile ./initExtra.sh; - # initExtra = '' - # # Zsh run-help function - # autoload -Uz run-help - # (( ''${+aliases[run-help]} )) && unalias run-help - # alias help=run-help - # ''; + initContent = builtins.readFile ./initExtra.sh; + # initExtra = '' + # # Zsh run-help function + # autoload -Uz run-help + # (( ''${+aliases[run-help]} )) && unalias run-help + # alias help=run-help + # ''; + }; + }; }; - }; } diff --git a/modules/home.nix b/modules/home.nix new file mode 100644 index 00000000..a991eebd --- /dev/null +++ b/modules/home.nix @@ -0,0 +1,37 @@ +# Wires home-manager into nix-darwin as a darwin module (so every host picks it +# up via `builtins.attrValues config.flake.modules.darwin`). The user's +# home-manager configuration imports every `flake.modules.homeManager.*` module +# accumulated across the tree. +{ config, inputs, ... }: +{ + flake.modules.darwin.home-manager = + { lib, ... }: + { + imports = [ inputs.home-manager.darwinModules.home-manager ]; + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + backupFileExtension = "hm.bak"; + # NB: do not pass `lib` here. home-manager derives the user-eval lib + # from the darwin system's lib (which `modules/darwin.nix` already sets + # to the extended lib carrying `kanagawa`/`mkProgramOption`) and adds its + # own `hm` extensions on top. Overriding it would drop `lib.hm.*`. + extraSpecialArgs = { + inherit inputs; + username = "k"; + }; + users.k = { + imports = builtins.attrValues config.flake.modules.homeManager; + kriswill.enable = true; + home.username = "k"; + home.stateVersion = "26.05"; + home.homeDirectory = lib.mkForce "/Users/k"; + manual = { + html.enable = false; + json.enable = false; + manpages.enable = false; + }; + }; + }; + }; +} diff --git a/modules/hosts/SOC-Kris-Williams.nix b/modules/hosts/SOC-Kris-Williams.nix new file mode 100644 index 00000000..9e40b372 --- /dev/null +++ b/modules/hosts/SOC-Kris-Williams.nix @@ -0,0 +1,19 @@ +# SOC-Kris-Williams - my work Apple M2 Pro, 32GB RAM +# hostname enforced by IT +{ config, ... }: +{ + configurations.darwin.SOC-Kris-Williams.module = { + imports = builtins.attrValues config.flake.modules.darwin; + + kriswill = { + enable = true; + alias-en0.enable = true; + dnsmasq.enable = true; + }; + + nixpkgs.hostPlatform = "aarch64-darwin"; + nixpkgs.overlays = builtins.attrValues config.flake.overlays; + + home-manager.users.k.kriswill.podman-desktop.enable = true; + }; +} diff --git a/modules/hosts/k.nix b/modules/hosts/k.nix new file mode 100644 index 00000000..1b9803b5 --- /dev/null +++ b/modules/hosts/k.nix @@ -0,0 +1,17 @@ +# k - my personal macbook pro M1 max, 64GB RAM +{ config, ... }: +{ + configurations.darwin.k.module = { + imports = builtins.attrValues config.flake.modules.darwin; + + kriswill = { + enable = true; + dnsmasq.enable = true; + }; + + nixpkgs.hostPlatform = "aarch64-darwin"; + nixpkgs.overlays = builtins.attrValues config.flake.overlays; + + home-manager.users.k.kriswill.podman-desktop.enable = true; + }; +} diff --git a/modules/hosts/mini.nix b/modules/hosts/mini.nix new file mode 100644 index 00000000..7b6273d2 --- /dev/null +++ b/modules/hosts/mini.nix @@ -0,0 +1,15 @@ +# mini - my personal mac mini M1, 16GB RAM +{ config, ... }: +{ + configurations.darwin.mini.module = { + imports = builtins.attrValues config.flake.modules.darwin; + + kriswill = { + enable = true; + dnsmasq.enable = true; + }; + + nixpkgs.hostPlatform = "aarch64-darwin"; + nixpkgs.overlays = builtins.attrValues config.flake.overlays; + }; +} diff --git a/modules/lib.nix b/modules/lib.nix new file mode 100644 index 00000000..5e7c9af9 --- /dev/null +++ b/modules/lib.nix @@ -0,0 +1,13 @@ +# Exposes the nixpkgs lib extended with this repo's pure helpers +# (`mkProgramOption`, `kanagawa`) as a top-level option, so both the darwin and +# home-manager evaluations can receive it via specialArgs / extraSpecialArgs. +{ lib, inputs, ... }: +{ + options.kriswill.lib = lib.mkOption { + type = lib.types.raw; + readOnly = true; + description = "nixpkgs lib extended with repo helpers (mkProgramOption, kanagawa)."; + }; + + config.kriswill.lib = inputs.nixpkgs.lib.extend (final: _: import ../lib { lib = final; }); +} diff --git a/modules/overlays.nix b/modules/overlays.nix new file mode 100644 index 00000000..d4813fef --- /dev/null +++ b/modules/overlays.nix @@ -0,0 +1,9 @@ +# Nixpkgs overlays, exposed as flake outputs and consumed by the host modules +# via `nixpkgs.overlays = builtins.attrValues config.flake.overlays`. +{ ... }: +{ + flake.overlays = { + kitten = import ../overlays/kitten.nix; + direnv = import ../overlays/direnv.nix; + }; +} diff --git a/modules/packages.nix b/modules/packages.nix new file mode 100644 index 00000000..d1fdd1f4 --- /dev/null +++ b/modules/packages.nix @@ -0,0 +1,12 @@ +# Custom package outputs (also surfaced into nix-darwin via ./overlays.nix). +{ ... }: +{ + perSystem = + { pkgs, ... }: + { + packages = { + kitten = pkgs.callPackage ../pkgs/kitten.nix { }; + iv = pkgs.callPackage ../pkgs/iv.nix { }; + }; + }; +} diff --git a/overlays/default.nix b/overlays/default.nix deleted file mode 100644 index f8b0e2e5..00000000 --- a/overlays/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ inputs }: -{ - kitten = import ./kitten.nix; - direnv = import ./direnv.nix; -} From 6a16763e416853d886252c0e54476a0cb0b2edf2 Mon Sep 17 00:00:00 2001 From: Kris Williams <115474+kriswill@users.noreply.github.com> Date: Sun, 24 May 2026 22:21:04 -0700 Subject: [PATCH 2/5] modules: drop vestigial { ... }: wrapper from arg-less modules Every file under modules/ is auto-imported as a flake-parts module, and a module may be a bare attrset or a function. These 32 files destructured no module args, so the leading `{ ... }:` bound nothing and was a pure no-op. Removing it leaves the attrset directly. nix fmt also normalized the direnv overlay's overrideAttrs to multi-line. --- modules/darwin/alias-en0.nix | 1 - modules/darwin/core.nix | 1 - modules/darwin/dnsmasq.nix | 1 - modules/darwin/ghostty.nix | 1 - modules/darwin/homebrew.nix | 1 - modules/darwin/macos-defaults.nix | 1 - modules/darwin/nh.nix | 1 - modules/dev.nix | 1 - modules/home-manager/brave.nix | 1 - modules/home-manager/core.nix | 1 - modules/home-manager/diffnav.nix | 1 - modules/home-manager/direnv-nom.nix | 1 - modules/home-manager/fastfetch/default.nix | 1 - modules/home-manager/firefox/default.nix | 1 - modules/home-manager/ghostty/default.nix | 1 - modules/home-manager/git.nix | 1 - modules/home-manager/glow/default.nix | 1 - modules/home-manager/karabiner/default.nix | 1 - modules/home-manager/kitty/default.nix | 1 - modules/home-manager/neovide/default.nix | 1 - modules/home-manager/neovim/default.nix | 1 - modules/home-manager/oksh/default.nix | 1 - modules/home-manager/podman-desktop/default.nix | 1 - modules/home-manager/ssh.nix | 1 - modules/home-manager/starship.nix | 1 - modules/home-manager/tmux/default.nix | 1 - modules/home-manager/vscode.nix | 1 - modules/home-manager/yazi/default.nix | 1 - modules/home-manager/zk/default.nix | 1 - modules/home-manager/zsh/default.nix | 1 - modules/overlays.nix | 1 - modules/packages.nix | 1 - overlays/direnv.nix | 4 +++- 33 files changed, 3 insertions(+), 33 deletions(-) diff --git a/modules/darwin/alias-en0.nix b/modules/darwin/alias-en0.nix index 9d2c2eae..8ad23244 100644 --- a/modules/darwin/alias-en0.nix +++ b/modules/darwin/alias-en0.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.darwin.alias-en0 = { lib, config, ... }: diff --git a/modules/darwin/core.nix b/modules/darwin/core.nix index 14b40a75..d6109ddd 100644 --- a/modules/darwin/core.nix +++ b/modules/darwin/core.nix @@ -2,7 +2,6 @@ # Declares the darwin-side `kriswill.enable` master toggle and the always-on # system baseline. Sibling darwin features are now separate flake-parts modules # auto-imported by import-tree, so the old `lib.autoImport` is gone. -{ ... }: { flake.modules.darwin.core = { diff --git a/modules/darwin/dnsmasq.nix b/modules/darwin/dnsmasq.nix index cc6306ff..d4e8c791 100644 --- a/modules/darwin/dnsmasq.nix +++ b/modules/darwin/dnsmasq.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.darwin.dnsmasq = { lib, config, ... }: diff --git a/modules/darwin/ghostty.nix b/modules/darwin/ghostty.nix index 0ae6d2e7..f7504af8 100644 --- a/modules/darwin/ghostty.nix +++ b/modules/darwin/ghostty.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.darwin.ghostty = { lib, config, ... }: diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index ecbc333a..698be051 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.darwin.homebrew = { lib, config, ... }: diff --git a/modules/darwin/macos-defaults.nix b/modules/darwin/macos-defaults.nix index d4181584..44606038 100644 --- a/modules/darwin/macos-defaults.nix +++ b/modules/darwin/macos-defaults.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.darwin.macos-defaults = { lib, config, ... }: diff --git a/modules/darwin/nh.nix b/modules/darwin/nh.nix index 9e2cf0ea..dc27bc0d 100644 --- a/modules/darwin/nh.nix +++ b/modules/darwin/nh.nix @@ -1,5 +1,4 @@ # This option is missing from nix-darwin config -{ ... }: { flake.modules.darwin.nh = { diff --git a/modules/dev.nix b/modules/dev.nix index e5eb9bac..fd003525 100644 --- a/modules/dev.nix +++ b/modules/dev.nix @@ -1,5 +1,4 @@ # Development shell and formatter. -{ ... }: { perSystem = { pkgs, ... }: diff --git a/modules/home-manager/brave.nix b/modules/home-manager/brave.nix index def1896c..8243311b 100644 --- a/modules/home-manager/brave.nix +++ b/modules/home-manager/brave.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.brave = { diff --git a/modules/home-manager/core.nix b/modules/home-manager/core.nix index d817d5b7..ba7f0bec 100644 --- a/modules/home-manager/core.nix +++ b/modules/home-manager/core.nix @@ -1,7 +1,6 @@ # Core home-manager configuration (was modules/home-manager/default.nix). # Declares the home-manager-side `kriswill.enable` master toggle, flips the # per-feature defaults, and carries the shared package set / inline programs. -{ ... }: { flake.modules.homeManager.core = { diff --git a/modules/home-manager/diffnav.nix b/modules/home-manager/diffnav.nix index ef28f38b..e3c5e47c 100644 --- a/modules/home-manager/diffnav.nix +++ b/modules/home-manager/diffnav.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.diffnav = { diff --git a/modules/home-manager/direnv-nom.nix b/modules/home-manager/direnv-nom.nix index cd926964..e67e5e69 100644 --- a/modules/home-manager/direnv-nom.nix +++ b/modules/home-manager/direnv-nom.nix @@ -5,7 +5,6 @@ # as hm-nix-direnv.sh, so zz-nom-wrapper.sh loads after it and can redefine # _nix(). Only print-dev-env is wrapped (it triggers the actual build); other # subcommands like build and flake archive pass through unchanged. -{ ... }: { flake.modules.homeManager.direnv-nom = { diff --git a/modules/home-manager/fastfetch/default.nix b/modules/home-manager/fastfetch/default.nix index 1ace810c..9abed750 100644 --- a/modules/home-manager/fastfetch/default.nix +++ b/modules/home-manager/fastfetch/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.fastfetch = { diff --git a/modules/home-manager/firefox/default.nix b/modules/home-manager/firefox/default.nix index 38ff4f5f..b4f15f3b 100644 --- a/modules/home-manager/firefox/default.nix +++ b/modules/home-manager/firefox/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.firefox = { diff --git a/modules/home-manager/ghostty/default.nix b/modules/home-manager/ghostty/default.nix index aa5f9d9b..85504c78 100644 --- a/modules/home-manager/ghostty/default.nix +++ b/modules/home-manager/ghostty/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.ghostty = { diff --git a/modules/home-manager/git.nix b/modules/home-manager/git.nix index e8734bf2..e3092a53 100644 --- a/modules/home-manager/git.nix +++ b/modules/home-manager/git.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.git = { diff --git a/modules/home-manager/glow/default.nix b/modules/home-manager/glow/default.nix index 638ad443..a02baf96 100644 --- a/modules/home-manager/glow/default.nix +++ b/modules/home-manager/glow/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.glow = { diff --git a/modules/home-manager/karabiner/default.nix b/modules/home-manager/karabiner/default.nix index 94578a8e..bcb5c00d 100644 --- a/modules/home-manager/karabiner/default.nix +++ b/modules/home-manager/karabiner/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.karabiner = { diff --git a/modules/home-manager/kitty/default.nix b/modules/home-manager/kitty/default.nix index 7144b521..17480816 100644 --- a/modules/home-manager/kitty/default.nix +++ b/modules/home-manager/kitty/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.kitty = { lib, config, ... }: diff --git a/modules/home-manager/neovide/default.nix b/modules/home-manager/neovide/default.nix index c86a5fe0..1c7fa660 100644 --- a/modules/home-manager/neovide/default.nix +++ b/modules/home-manager/neovide/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.neovide = { diff --git a/modules/home-manager/neovim/default.nix b/modules/home-manager/neovim/default.nix index 3be00534..1e57425e 100644 --- a/modules/home-manager/neovim/default.nix +++ b/modules/home-manager/neovim/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.neovim = { diff --git a/modules/home-manager/oksh/default.nix b/modules/home-manager/oksh/default.nix index b847be52..dcbe642d 100644 --- a/modules/home-manager/oksh/default.nix +++ b/modules/home-manager/oksh/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.oksh = { diff --git a/modules/home-manager/podman-desktop/default.nix b/modules/home-manager/podman-desktop/default.nix index 8f43b696..45458879 100644 --- a/modules/home-manager/podman-desktop/default.nix +++ b/modules/home-manager/podman-desktop/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.podman-desktop = { diff --git a/modules/home-manager/ssh.nix b/modules/home-manager/ssh.nix index f80b519c..1120f006 100644 --- a/modules/home-manager/ssh.nix +++ b/modules/home-manager/ssh.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.ssh = { diff --git a/modules/home-manager/starship.nix b/modules/home-manager/starship.nix index f6a89190..88e041a7 100644 --- a/modules/home-manager/starship.nix +++ b/modules/home-manager/starship.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.starship = { lib, config, ... }: diff --git a/modules/home-manager/tmux/default.nix b/modules/home-manager/tmux/default.nix index 133faa07..2f19f156 100644 --- a/modules/home-manager/tmux/default.nix +++ b/modules/home-manager/tmux/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.tmux = { diff --git a/modules/home-manager/vscode.nix b/modules/home-manager/vscode.nix index bd525de5..755ce06c 100644 --- a/modules/home-manager/vscode.nix +++ b/modules/home-manager/vscode.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.vscode = { lib, config, ... }: diff --git a/modules/home-manager/yazi/default.nix b/modules/home-manager/yazi/default.nix index 8e729379..3979ecb2 100644 --- a/modules/home-manager/yazi/default.nix +++ b/modules/home-manager/yazi/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.yazi = { diff --git a/modules/home-manager/zk/default.nix b/modules/home-manager/zk/default.nix index 410095c5..3e80a80d 100644 --- a/modules/home-manager/zk/default.nix +++ b/modules/home-manager/zk/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.zk = { diff --git a/modules/home-manager/zsh/default.nix b/modules/home-manager/zsh/default.nix index d3487842..df8c505b 100644 --- a/modules/home-manager/zsh/default.nix +++ b/modules/home-manager/zsh/default.nix @@ -1,4 +1,3 @@ -{ ... }: { flake.modules.homeManager.zsh = { diff --git a/modules/overlays.nix b/modules/overlays.nix index d4813fef..31a5ead5 100644 --- a/modules/overlays.nix +++ b/modules/overlays.nix @@ -1,6 +1,5 @@ # Nixpkgs overlays, exposed as flake outputs and consumed by the host modules # via `nixpkgs.overlays = builtins.attrValues config.flake.overlays`. -{ ... }: { flake.overlays = { kitten = import ../overlays/kitten.nix; diff --git a/modules/packages.nix b/modules/packages.nix index d1fdd1f4..47d30601 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -1,5 +1,4 @@ # Custom package outputs (also surfaced into nix-darwin via ./overlays.nix). -{ ... }: { perSystem = { pkgs, ... }: diff --git a/overlays/direnv.nix b/overlays/direnv.nix index f170f3a5..8948904d 100644 --- a/overlays/direnv.nix +++ b/overlays/direnv.nix @@ -5,5 +5,7 @@ _final: prev: { # (0% CPU, no children, stuck in a pipe read), adding many minutes to any # rebuild whenever cache.nixos.org doesn't yet have a prebuilt direnv for our # nixpkgs rev. Skip checks locally — upstream + Hydra already run them. - direnv = prev.direnv.overrideAttrs (_: { doCheck = false; }); + direnv = prev.direnv.overrideAttrs (_: { + doCheck = false; + }); } From 6bd74e8c51946a94fa99e2484c486bb359995694 Mon Sep 17 00:00:00 2001 From: Kris Williams <115474+kriswill@users.noreply.github.com> Date: Sun, 24 May 2026 22:26:06 -0700 Subject: [PATCH 3/5] modules: flatten single-file module dirs to name.nix Directories under modules/home-manager/ that held only a default.nix with no supporting files (zk, podman-desktop, neovide, tmux, neovim, karabiner, ghostty) are now flat .nix files. Dirs are reserved for modules that bundle adjacent config (firefox/user.js, kitty/*.conf, yazi/_themes, etc.). All symlink sources are homeDirectory-based absolutes, so moving the files up one level is safe. Also removed leftover empty mixins/ dirs from the refactor. --- modules/home-manager/{ghostty/default.nix => ghostty.nix} | 0 modules/home-manager/{karabiner/default.nix => karabiner.nix} | 0 modules/home-manager/{neovide/default.nix => neovide.nix} | 0 modules/home-manager/{neovim/default.nix => neovim.nix} | 0 .../{podman-desktop/default.nix => podman-desktop.nix} | 0 modules/home-manager/{tmux/default.nix => tmux.nix} | 0 modules/home-manager/{zk/default.nix => zk.nix} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename modules/home-manager/{ghostty/default.nix => ghostty.nix} (100%) rename modules/home-manager/{karabiner/default.nix => karabiner.nix} (100%) rename modules/home-manager/{neovide/default.nix => neovide.nix} (100%) rename modules/home-manager/{neovim/default.nix => neovim.nix} (100%) rename modules/home-manager/{podman-desktop/default.nix => podman-desktop.nix} (100%) rename modules/home-manager/{tmux/default.nix => tmux.nix} (100%) rename modules/home-manager/{zk/default.nix => zk.nix} (100%) diff --git a/modules/home-manager/ghostty/default.nix b/modules/home-manager/ghostty.nix similarity index 100% rename from modules/home-manager/ghostty/default.nix rename to modules/home-manager/ghostty.nix diff --git a/modules/home-manager/karabiner/default.nix b/modules/home-manager/karabiner.nix similarity index 100% rename from modules/home-manager/karabiner/default.nix rename to modules/home-manager/karabiner.nix diff --git a/modules/home-manager/neovide/default.nix b/modules/home-manager/neovide.nix similarity index 100% rename from modules/home-manager/neovide/default.nix rename to modules/home-manager/neovide.nix diff --git a/modules/home-manager/neovim/default.nix b/modules/home-manager/neovim.nix similarity index 100% rename from modules/home-manager/neovim/default.nix rename to modules/home-manager/neovim.nix diff --git a/modules/home-manager/podman-desktop/default.nix b/modules/home-manager/podman-desktop.nix similarity index 100% rename from modules/home-manager/podman-desktop/default.nix rename to modules/home-manager/podman-desktop.nix diff --git a/modules/home-manager/tmux/default.nix b/modules/home-manager/tmux.nix similarity index 100% rename from modules/home-manager/tmux/default.nix rename to modules/home-manager/tmux.nix diff --git a/modules/home-manager/zk/default.nix b/modules/home-manager/zk.nix similarity index 100% rename from modules/home-manager/zk/default.nix rename to modules/home-manager/zk.nix From 24d88bb6af09b58d8fc1c8ddf28b117c1ec0304c Mon Sep 17 00:00:00 2001 From: Kris Williams <115474+kriswill@users.noreply.github.com> Date: Sun, 24 May 2026 22:38:24 -0700 Subject: [PATCH 4/5] docs(AGENTS.md): replace autoImport/mkDarwin refs with flake-parts + import-tree The Dendritic refactor dropped lib.autoImport, mkDarwin, and mkHomeManager; discovery is now flake-parts + import-tree over ./modules. Update the overview, file-organization tree, custom-lib section, module-add and package-add steps, the module-pattern reference (nh path), and unfree handling to match. --- AGENTS.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ab3b4735..94ccb293 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,7 @@ ## Overview Nix-based dotfiles for macOS (nix-darwin + home-manager). Primary configs: Neovim (Lua), Tmux, Zsh, CLI tools. -Platform: aarch64-darwin (Apple Silicon only). Flake-based with custom modular structure using `lib.autoImport`. +Platform: aarch64-darwin (Apple Silicon only). Flake-based, using flake-parts + `import-tree` (the Dendritic pattern): every `.nix` file under `modules/` is auto-discovered as a flake-parts module. ## MANDATORY: Use td for Task Management @@ -39,12 +39,12 @@ Use td usage -q after first read. ## Code Style - Nix -- **Module pattern:** `options` with `kriswill..enable` + `config` with `lib.mkIf`. See `modules/darwin/core/programs/nh/default.nix` for reference. +- **Module pattern:** wrap in `flake.modules.{darwin,homeManager}. = { ... }: { options … config … }`; `options` with `kriswill..enable` + `config` with `lib.mkIf`. See `modules/darwin/nh.nix` for reference. - **Imports:** Use `inherit` for cleaner destructuring - **Package lists:** Use `builtins.attrValues { inherit (pkgs) ...; }` pattern - **Options:** `lib.mkEnableOption`, `lib.mkProgramOption` (custom), `lib.mkDefault` - **Symlinks:** Use `config.lib.file.mkOutOfStoreSymlink` (see neovim module) -- **Unfree packages:** Add to `allowUnfreePredicate` in `flake.nix` +- **Unfree packages:** Repo sets `nixpkgs.config.allowUnfree = false` in `modules/darwin/core.nix`; to permit a specific unfree package add a `nixpkgs.config.allowUnfreePredicate` there ## Code Style - Lua (Neovim) @@ -72,47 +72,49 @@ Use td usage -q after first read. - **Module options:** `kriswill..enable` (e.g., `kriswill.neovim.enable`) - **Packages:** kebab-case (e.g., `kitten`, `iv`, `tofu-ls`) -- **Nix functions:** camelCase (e.g., `mkDarwin`, `autoImport`, `mkProgramOption`) +- **Nix functions:** camelCase (e.g., `mkProgramOption`, `kanagawa`) - **Files:** kebab-case for multi-word (e.g., `alias-en0.nix`, `update-opencode.sh`) - **Hosts:** Descriptive names (e.g., `k`, `SOC-Kris-Williams`) ## File Organization ``` -├── modules/ -│ ├── darwin/ # nix-darwin system modules (uses lib.autoImport) -│ │ ├── core/ # Essential system configuration -│ │ └── mixins/ # Optional features (homebrew, aliases) -│ └── home-manager/ # User-level tool configs (neovim, tmux, zsh, git, etc.) +├── modules/ # Every .nix here is auto-imported as a flake-parts module +│ ├── flake-parts.nix # systems list + flake-parts plumbing +│ ├── darwin.nix # realises `configurations.darwin.` → darwinConfigurations +│ ├── home.nix # wires home-manager into nix-darwin +│ ├── lib.nix, packages.nix, overlays.nix, dev.nix +│ ├── darwin/ # nix-darwin system feature modules (core, homebrew, ghostty, …) +│ ├── home-manager/ # User-level tool configs (neovim, tmux, zsh, git, …) +│ └── hosts/ # Per-host config (k, mini, SOC-Kris-Williams) ├── config/ # Actual config files (symlinked to XDG locations) │ ├── nvim/ # Neovim Lua configuration │ └── tmux/ # Tmux configuration ├── pkgs/ # Custom package definitions (*.nix files or subdirectories) ├── overlays/ # Nixpkgs overlays (makes custom packages available) -├── hosts/ # Host-specific configurations -├── lib/ # Custom library functions (autoImport, mkDarwin, etc.) +├── lib/ # Pure lib helpers (mkProgramOption, kanagawa) — outside modules/ so import-tree skips them └── scripts/ # Helper scripts for package updates ``` ## Custom Library Functions -Located in `lib/default.nix`: `autoImport` (directory-based module loading), `mkDarwin`, `mkHomeManager`, `mkProgramOption`. See file for API details. +Pure helpers live in `lib/default.nix`: `mkProgramOption` and `kanagawa`. They're merged onto `nixpkgs.lib` in `modules/lib.nix` (exposed as `config.kriswill.lib`) and handed to the darwin/home-manager evaluations via specialArgs, so modules reach them as `lib.mkProgramOption` / `lib.kanagawa`. Module auto-discovery and the old `mkDarwin`/`mkHomeManager`/`autoImport` builders are gone — flake-parts + `import-tree ./modules` (wired in `flake.nix`) handles discovery, and `modules/{darwin,home}.nix` realise the configurations. ## Common Patterns **Adding a New Module:** -1. Create file in `modules/darwin/` or `modules/home-manager/` -2. Follow module pattern (see Code Style - Nix above) -3. File is auto-discovered via `lib.autoImport` in parent `default.nix` +1. Create a `.nix` file in `modules/darwin/` or `modules/home-manager/` (a bare `.nix`; only use a directory when bundling adjacent config files) +2. Define `flake.modules.darwin.` or `flake.modules.homeManager.` following the module pattern (see Code Style - Nix above) +3. File is auto-discovered by `import-tree` — no manual import needed (prefix a path component with `_` to exclude it, e.g. `yazi/_themes/`) 4. **Must `git add` new files before `nix build`** — flakes only see git-tracked files **Adding a Custom Package:** -1. Create `pkgs//package.nix` -2. Add to `packages.${system}` in `flake.nix` -3. Create overlay in `overlays/.nix` -4. If unfree: add to `allowUnfreePredicate` in `flake.nix` +1. Create `pkgs/.nix` (or `pkgs//package.nix`) +2. Add ` = pkgs.callPackage ../pkgs/.nix { };` to `perSystem.packages` in `modules/packages.nix` +3. To make it available to hosts, create `overlays/.nix` and register it in `modules/overlays.nix` (`flake.overlays.`) +4. If unfree: add a `nixpkgs.config.allowUnfreePredicate` entry in `modules/darwin/core.nix` **Symlinked Configs:** From 170e7f2bcc3ba45e2d35c2a8c3ce3562b4439f11 Mon Sep 17 00:00:00 2001 From: Kris Williams <115474+kriswill@users.noreply.github.com> Date: Sun, 24 May 2026 22:47:20 -0700 Subject: [PATCH 5/5] nix flake upate CHANGED [U.] chafa 1.18.1, 1.18.1-bin -> 1.18.2, 1.18.2-bin [U.] kitty 0.46.2, 0.46.2-terminfo -> 0.47.0, 0.47.0-terminfo SIZE: 11.1 GiB -> 11.1 GiB DIFF: 3.26 MiB > Activating configuration --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index cde7dd4e..40924b88 100644 --- a/flake.lock +++ b/flake.lock @@ -61,11 +61,11 @@ ] }, "locked": { - "lastModified": 1779336838, - "narHash": "sha256-n1+l78hJRABp4cQHKeD0BVByT0vZLPqd09Tvoq8Q+d8=", + "lastModified": 1779678629, + "narHash": "sha256-gHcIFg0mm+KFsg7iZQt67kni3+qR5U3PhEC9P7vKlZ4=", "owner": "nix-community", "repo": "home-manager", - "rev": "928d72376949e222ea4f07b44828a55b0136422e", + "rev": "612bbe3b405ad5f71d7bf9edecc04b678a061652", "type": "github" }, "original": { @@ -91,11 +91,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1779414690, - "narHash": "sha256-gOTcX/9MZVMUE0Xvb4IEcv+0TQJkZFNEnL757ljU360=", + "lastModified": 1779536132, + "narHash": "sha256-q+fF42iv/geEbHfgSzy3tS0FF/EyD6XTZ98E6yxiBO8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6dedf69f94d03cbe7bdde106f2d4c23ae2a853bf", + "rev": "3d8f0f3f72a6cd4d93d0ad13203f2ea1cb7e1456", "type": "github" }, "original": {