From f9614371a38cb9f5c1cf0cf588e6cafa0c0cd183 Mon Sep 17 00:00:00 2001 From: 0xrsydn Date: Fri, 30 Jan 2026 15:59:48 +0700 Subject: [PATCH] refactor: nix fmt classic to nix fmt --- AGENTS.md | 2 +- flake.nix | 178 +++++++---- hosts/desktop.nix | 13 +- hosts/dev-vm.nix | 3 +- modules/darwin/devtools.nix | 13 +- modules/darwin/home/default.nix | 8 +- .../home/programs/aerospace/default.nix | 3 +- .../darwin/home/programs/aerospace/modes.nix | 54 +++- .../home/programs/aerospace/user-settings.nix | 3 +- .../home/programs/aerospace/workspaces.nix | 25 +- modules/darwin/home/programs/ghostty.nix | 3 +- modules/darwin/homebrew.nix | 10 +- modules/darwin/system.nix | 27 +- modules/home/base.nix | 13 +- modules/home/devtools/ai-tools.nix | 90 +++--- modules/home/devtools/default.nix | 10 +- modules/home/devtools/direnv.nix | 6 +- modules/home/devtools/languages.nix | 49 ++- modules/home/devtools/try.nix | 18 +- modules/home/programs/fastfetch/default.nix | 285 +++++++++--------- modules/home/programs/helix.nix | 15 +- modules/home/programs/neovim.nix | 24 +- modules/home/secrets.nix | 59 ++-- modules/home/shell/fish.nix | 8 +- modules/home/shell/nushell.nix | 57 ++-- modules/home/shell/starship/default.nix | 3 +- modules/home/shell/tmux.nix | 10 +- modules/nixos/audio.nix | 3 +- modules/nixos/bluetooth.nix | 3 +- modules/nixos/containerization.nix | 83 +++-- modules/nixos/desktops/apps/browsers.nix | 3 +- modules/nixos/desktops/apps/terminals.nix | 8 +- modules/nixos/desktops/base.nix | 3 +- modules/nixos/desktops/gaming.nix | 18 +- .../nixos/desktops/hardware-configuration.nix | 24 +- modules/nixos/desktops/hyprland/default.nix | 25 +- modules/nixos/desktops/plasma.nix | 34 ++- modules/nixos/desktops/themes/catppuccin.nix | 8 +- modules/nixos/desktops/themes/default.nix | 8 +- modules/nixos/fonts.nix | 16 +- modules/nixos/graphics.nix | 3 +- modules/nixos/home/default.nix | 8 +- modules/nixos/network.nix | 3 +- modules/nixos/ssh.nix | 3 +- modules/nixos/system.nix | 20 +- modules/nixos/users.nix | 14 +- modules/nixos/virtualization.nix | 10 +- packages/default.nix | 11 +- shells/README.md | 2 +- shells/ai-agent.nix | 7 +- shells/ai-notebook.nix | 36 ++- shells/default.nix | 23 +- shells/effect-ts.nix | 3 +- shells/go.nix | 8 +- shells/jupyter-notebook.nix | 23 +- shells/python-uv.nix | 13 +- shells/rust.nix | 8 +- 57 files changed, 925 insertions(+), 495 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 869522f..dc3795a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ Custom packages live in `packages/` and are exported via `packages/default.nix`. ## Build, Test, and Development Commands -Use `nix develop` to enter the project shell with `git`, `nixfmt-classic`, and SOPS ready. Run `nix fmt` before committing to format all Nix sources. `XDG_CACHE_HOME=$PWD/.cache nix flake check` validates every host without polluting the global cache. For macOS changes, run `darwin-rebuild --dry-run --flake .#macbook-pro` and follow with `darwin-rebuild switch --flake .#macbook-pro`. Validate the Linux VM closure via `nix build .#nixosConfigurations.dev-vm.config.system.build.toplevel`. +Use `nix develop` to enter the project shell with `git`, `nixfmt`, and SOPS ready. Run `nix fmt` before committing to format all Nix sources. `XDG_CACHE_HOME=$PWD/.cache nix flake check` validates every host without polluting the global cache. For macOS changes, run `darwin-rebuild --dry-run --flake .#macbook-pro` and follow with `darwin-rebuild switch --flake .#macbook-pro`. Validate the Linux VM closure via `nix build .#nixosConfigurations.dev-vm.config.system.build.toplevel`. ## AI Agent Workflow with Beads diff --git a/flake.nix b/flake.nix index 5db5dc4..2e689de 100644 --- a/flake.nix +++ b/flake.nix @@ -18,8 +18,7 @@ llm-agents.url = "github:numtide/llm-agents.nix"; # Pinned llm-agents for Claude Code 2.0.64 (uses its own nixpkgs for compatibility) - llm-agents-pinned.url = - "github:numtide/llm-agents.nix/4a12b5bef5a82b71da765603df5192c511a60cc2"; + llm-agents-pinned.url = "github:numtide/llm-agents.nix/4a12b5bef5a82b71da765603df5192c511a60cc2"; sops-nix.url = "github:Mic92/sops-nix"; sops-nix.inputs.nixpkgs.follows = "nixpkgs"; @@ -30,14 +29,32 @@ try.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = inputs@{ self, nixpkgs, darwin, home-manager, ghostty, llm-agents - , llm-agents-pinned, sops-nix, chaotic, try, ... }: + outputs = + inputs@{ + self, + nixpkgs, + darwin, + home-manager, + ghostty, + llm-agents, + llm-agents-pinned, + sops-nix, + chaotic, + try, + ... + }: let inherit (nixpkgs.lib) genAttrs; lib = nixpkgs.lib; - darwinSystems = [ "aarch64-darwin" "x86_64-darwin" ]; - linuxSystems = [ "x86_64-linux" "aarch64-linux" ]; + darwinSystems = [ + "aarch64-darwin" + "x86_64-darwin" + ]; + linuxSystems = [ + "x86_64-linux" + "aarch64-linux" + ]; systems = darwinSystems ++ linuxSystems; forEachSystem = f: genAttrs systems (system: f system); @@ -48,7 +65,8 @@ # - chaotic: removed - only needed for NixOS, was causing nix to rebuild with failing tests overlaysList = [ ]; - mkPkgs = system: + mkPkgs = + system: import nixpkgs { inherit system; overlays = overlaysList; @@ -56,62 +74,93 @@ }; sharedDarwinModules = [ ./modules/darwin/system.nix ]; - sharedNixosModules = - [ ./modules/nixos/system.nix chaotic.nixosModules.default ]; + sharedNixosModules = [ + ./modules/nixos/system.nix + chaotic.nixosModules.default + ]; user = "rasyidanakbar"; - mkDarwin = { system ? "aarch64-darwin", extraModules ? [ ] - , homeFile ? ./modules/darwin/home/default.nix, }: + mkDarwin = + { + system ? "aarch64-darwin", + extraModules ? [ ], + homeFile ? ./modules/darwin/home/default.nix, + }: let pkgs = mkPkgs system; customPkgs = import ./packages { inherit pkgs lib llm-agents; }; - in darwin.lib.darwinSystem { + in + darwin.lib.darwinSystem { inherit pkgs; system = pkgs.stdenv.hostPlatform.system; specialArgs = { inherit inputs overlaysList user; }; - modules = sharedDarwinModules ++ extraModules ++ [ - home-manager.darwinModules.home-manager - { - nix.registry.self.flake = self; - nixpkgs.overlays = overlaysList; + modules = + sharedDarwinModules + ++ extraModules + ++ [ + home-manager.darwinModules.home-manager + { + nix.registry.self.flake = self; + nixpkgs.overlays = overlaysList; - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.backupFileExtension = "backup"; - home-manager.extraSpecialArgs = { - inherit inputs user try customPkgs; - }; - home-manager.users.${user} = import homeFile; - } - ]; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.backupFileExtension = "backup"; + home-manager.extraSpecialArgs = { + inherit + inputs + user + try + customPkgs + ; + }; + home-manager.users.${user} = import homeFile; + } + ]; }; - mkNixos = { system ? "x86_64-linux", extraModules ? [ ] - , homeFile ? ./modules/nixos/home/default.nix, }: + mkNixos = + { + system ? "x86_64-linux", + extraModules ? [ ], + homeFile ? ./modules/nixos/home/default.nix, + }: let pkgs = mkPkgs system; customPkgs = import ./packages { inherit pkgs lib llm-agents; }; - in lib.nixosSystem { + in + lib.nixosSystem { inherit pkgs; system = pkgs.stdenv.hostPlatform.system; specialArgs = { inherit inputs overlaysList user; }; - modules = sharedNixosModules ++ extraModules ++ [ - home-manager.nixosModules.home-manager - { - nix.registry.self.flake = self; - nixpkgs.overlays = overlaysList; + modules = + sharedNixosModules + ++ extraModules + ++ [ + home-manager.nixosModules.home-manager + { + nix.registry.self.flake = self; + nixpkgs.overlays = overlaysList; - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.extraSpecialArgs = { - inherit inputs user try customPkgs; - }; - home-manager.users.${user} = import homeFile; - } - ]; + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { + inherit + inputs + user + try + customPkgs + ; + }; + home-manager.users.${user} = import homeFile; + } + ]; }; - in { - darwinConfigurations = { macbook-pro = mkDarwin { }; }; + in + { + darwinConfigurations = { + macbook-pro = mkDarwin { }; + }; nixosConfigurations = { # Temporarily disabled for testing # dev-vm = mkNixos { @@ -128,24 +177,30 @@ # }; }; - devShells = forEachSystem (system: + devShells = forEachSystem ( + system: let pkgs = mkPkgs system; - python = if builtins.hasAttr "python312" pkgs then - pkgs.python312 - else - pkgs.python3; + python = if builtins.hasAttr "python312" pkgs then pkgs.python312 else pkgs.python3; # Custom packages customPkgs = import ./packages { inherit pkgs lib llm-agents; }; # Common arguments passed to all devshell imports - shellArgs = { inherit pkgs lib python customPkgs; }; + shellArgs = { + inherit + pkgs + lib + python + customPkgs + ; + }; # Import all shells from shells/ directory importShell = name: import (./shells + "/${name}.nix") shellArgs; - in { + in + { default = importShell "default"; python-uv = importShell "python-uv"; ai-notebook = importShell "ai-notebook"; @@ -155,20 +210,29 @@ rust = importShell "rust"; ai-agent = importShell "ai-agent"; effect-ts = importShell "effect-ts"; - }); + } + ); - formatter = forEachSystem (system: (mkPkgs system).nixfmt-classic); + formatter = forEachSystem (system: (mkPkgs system).nixfmt); - packages = forEachSystem (system: + packages = forEachSystem ( + system: let pkgs = mkPkgs system; customPkgs = import ./packages { inherit pkgs lib llm-agents; }; - in customPkgs // { inherit (pkgs) git; }); + in + customPkgs // { inherit (pkgs) git; } + ); - checks = forEachSystem (system: + checks = forEachSystem ( + system: let pkgs = mkPkgs system; customPkgs = import ./packages { inherit pkgs lib llm-agents; }; - in { inherit (customPkgs) opencode; }); + in + { + inherit (customPkgs) opencode; + } + ); }; } diff --git a/hosts/desktop.nix b/hosts/desktop.nix index c08ce7f..661d91c 100644 --- a/hosts/desktop.nix +++ b/hosts/desktop.nix @@ -1,12 +1,11 @@ { lib, pkgs, ... }: let - hardwareConfigPath = builtins.toString ./. - + "/../modules/nixos/desktops/hardware-configuration.nix"; - hardwareModule = if builtins.pathExists hardwareConfigPath then - import hardwareConfigPath - else - (_: { }); -in { + hardwareConfigPath = + builtins.toString ./. + "/../modules/nixos/desktops/hardware-configuration.nix"; + hardwareModule = + if builtins.pathExists hardwareConfigPath then import hardwareConfigPath else (_: { }); +in +{ # Unified desktop configuration for gaming and development # Includes both KDE Plasma and Hyprland - switch at login screen diff --git a/hosts/dev-vm.nix b/hosts/dev-vm.nix index ef17893..bc638b4 100644 --- a/hosts/dev-vm.nix +++ b/hosts/dev-vm.nix @@ -1,4 +1,5 @@ -{ lib, pkgs, ... }: { +{ lib, pkgs, ... }: +{ networking.hostName = "dev-vm"; # Set the baseline NixOS release used for stateful data; bump on rebuilds. system.stateVersion = lib.mkDefault "24.05"; diff --git a/modules/darwin/devtools.nix b/modules/darwin/devtools.nix index 6b94a53..50070ab 100644 --- a/modules/darwin/devtools.nix +++ b/modules/darwin/devtools.nix @@ -1,8 +1,14 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let inherit (lib) mkIf mkOption types; cfg = config.rsydn.systemPackages; -in { +in +{ options.rsydn.systemPackages = { enable = mkOption { type = types.bool; @@ -13,8 +19,7 @@ in { packages = mkOption { type = types.listOf types.package; default = with pkgs; [ tailscale ]; - description = - "System packages that must be available globally across macOS."; + description = "System packages that must be available globally across macOS."; }; }; diff --git a/modules/darwin/home/default.nix b/modules/darwin/home/default.nix index c7a5b6c..0a42ffa 100644 --- a/modules/darwin/home/default.nix +++ b/modules/darwin/home/default.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ # Import shared cross-platform home configuration imports = [ ../../home/base.nix diff --git a/modules/darwin/home/programs/aerospace/default.nix b/modules/darwin/home/programs/aerospace/default.nix index f703f69..1781110 100644 --- a/modules/darwin/home/programs/aerospace/default.nix +++ b/modules/darwin/home/programs/aerospace/default.nix @@ -7,7 +7,8 @@ let }; userSettings = import ./user-settings.nix { modes = modes; }; -in { +in +{ programs.aerospace = { enable = true; package = pkgs.aerospace; diff --git a/modules/darwin/home/programs/aerospace/modes.nix b/modules/darwin/home/programs/aerospace/modes.nix index a681221..d80ae7d 100644 --- a/modules/darwin/home/programs/aerospace/modes.nix +++ b/modules/darwin/home/programs/aerospace/modes.nix @@ -1,4 +1,5 @@ -{ workspaceFocusBindings, workspaceSendBindings }: { +{ workspaceFocusBindings, workspaceSendBindings }: +{ main.binding = { "alt-h" = "focus left"; "alt-j" = "focus down"; @@ -27,7 +28,9 @@ "alt-r" = "mode resize"; "alt-f" = "mode float"; "alt-shift-semicolon" = "mode service"; - } // workspaceFocusBindings // workspaceSendBindings; + } + // workspaceFocusBindings + // workspaceSendBindings; float.binding = { enter = ''exec-and-forget open -na "Ghostty" && aerospace layout floating''; @@ -36,8 +39,11 @@ "layout floating" "mode main" ]; - g = - [ ''exec-and-forget open -na "Ghostty"'' "layout floating" "mode main" ]; + g = [ + ''exec-and-forget open -na "Ghostty"'' + "layout floating" + "mode main" + ]; esc = "mode main"; }; @@ -52,13 +58,37 @@ }; service.binding = { - esc = [ "reload-config" "mode main" ]; - r = [ "flatten-workspace-tree" "mode main" ]; - f = [ "layout floating tiling" "mode main" ]; - backspace = [ "close-all-windows-but-current" "mode main" ]; - h = [ "join-with left" "mode main" ]; - j = [ "join-with down" "mode main" ]; - k = [ "join-with up" "mode main" ]; - l = [ "join-with right" "mode main" ]; + esc = [ + "reload-config" + "mode main" + ]; + r = [ + "flatten-workspace-tree" + "mode main" + ]; + f = [ + "layout floating tiling" + "mode main" + ]; + backspace = [ + "close-all-windows-but-current" + "mode main" + ]; + h = [ + "join-with left" + "mode main" + ]; + j = [ + "join-with down" + "mode main" + ]; + k = [ + "join-with up" + "mode main" + ]; + l = [ + "join-with right" + "mode main" + ]; }; } diff --git a/modules/darwin/home/programs/aerospace/user-settings.nix b/modules/darwin/home/programs/aerospace/user-settings.nix index 4cd1e9a..fdd01b7 100644 --- a/modules/darwin/home/programs/aerospace/user-settings.nix +++ b/modules/darwin/home/programs/aerospace/user-settings.nix @@ -1,4 +1,5 @@ -{ modes }: { +{ modes }: +{ enable-normalization-flatten-containers = true; enable-normalization-opposite-orientation-for-nested-containers = true; default-root-container-layout = "tiles"; diff --git a/modules/darwin/home/programs/aerospace/workspaces.nix b/modules/darwin/home/programs/aerospace/workspaces.nix index e3e6dd3..25a0e8f 100644 --- a/modules/darwin/home/programs/aerospace/workspaces.nix +++ b/modules/darwin/home/programs/aerospace/workspaces.nix @@ -4,13 +4,20 @@ let workspaceNumbers = map toString (lib.range 1 9); - workspaceFocusBindings = listToAttrs (map (ws: { - name = "alt-${ws}"; - value = "workspace ${ws}"; - }) workspaceNumbers); + workspaceFocusBindings = listToAttrs ( + map (ws: { + name = "alt-${ws}"; + value = "workspace ${ws}"; + }) workspaceNumbers + ); - workspaceSendBindings = listToAttrs (map (ws: { - name = "alt-shift-${ws}"; - value = "move-node-to-workspace ${ws}"; - }) workspaceNumbers); -in { inherit workspaceNumbers workspaceFocusBindings workspaceSendBindings; } + workspaceSendBindings = listToAttrs ( + map (ws: { + name = "alt-shift-${ws}"; + value = "move-node-to-workspace ${ws}"; + }) workspaceNumbers + ); +in +{ + inherit workspaceNumbers workspaceFocusBindings workspaceSendBindings; +} diff --git a/modules/darwin/home/programs/ghostty.nix b/modules/darwin/home/programs/ghostty.nix index 2f37bd7..030d588 100644 --- a/modules/darwin/home/programs/ghostty.nix +++ b/modules/darwin/home/programs/ghostty.nix @@ -1,4 +1,5 @@ -{ config, ... }: { +{ config, ... }: +{ programs.ghostty = { enable = true; package = null; diff --git a/modules/darwin/homebrew.nix b/modules/darwin/homebrew.nix index 5ba0aa1..617ad8b 100644 --- a/modules/darwin/homebrew.nix +++ b/modules/darwin/homebrew.nix @@ -2,7 +2,8 @@ let inherit (lib) mkIf mkOption types; cfg = config.rsydn.homebrew; -in { +in +{ options.rsydn.homebrew = { enable = mkOption { type = types.bool; @@ -16,7 +17,12 @@ in { }; brews = mkOption { type = types.listOf types.str; - default = [ "curl" "yt-dlp" "infisical" "mole" ]; + default = [ + "curl" + "yt-dlp" + "infisical" + "mole" + ]; description = "Homebrew formulae to install."; }; casks = mkOption { diff --git a/modules/darwin/system.nix b/modules/darwin/system.nix index 9f972b2..a108e1f 100644 --- a/modules/darwin/system.nix +++ b/modules/darwin/system.nix @@ -1,5 +1,15 @@ -{ config, pkgs, lib, user, ... }: { - imports = [ ./homebrew.nix ./devtools.nix ]; +{ + config, + pkgs, + lib, + user, + ... +}: +{ + imports = [ + ./homebrew.nix + ./devtools.nix + ]; nix = { # Use default nix version from nixpkgs (don't pin to avoid rebuild issues) @@ -8,12 +18,14 @@ keep-outputs = true ''; settings = { - experimental-features = [ "nix-command" "flakes" ]; + experimental-features = [ + "nix-command" + "flakes" + ]; warn-dirty = false; # Numtide binary cache for llm-agents.nix packages extra-substituters = [ "https://cache.numtide.com" ]; - extra-trusted-public-keys = - [ "numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ber8L+2z9FqRZJ+KBKGE4NNsT0=" ]; + extra-trusted-public-keys = [ "numtide.cachix.org-1:2ps1kLBUWjxIneOy1Ber8L+2z9FqRZJ+KBKGE4NNsT0=" ]; }; optimise.automatic = true; gc = { @@ -27,7 +39,10 @@ }; }; - environment.shells = [ pkgs.nushell "/etc/profiles/per-user/${user}/bin/nu" ]; + environment.shells = [ + pkgs.nushell + "/etc/profiles/per-user/${user}/bin/nu" + ]; # Set XDG Base Directory environment variables globally # This ensures nushell and other XDG-compliant tools use ~/.config diff --git a/modules/home/base.nix b/modules/home/base.nix index dfaeb69..edc33e4 100644 --- a/modules/home/base.nix +++ b/modules/home/base.nix @@ -1,4 +1,10 @@ -{ pkgs, lib, customPkgs, ... }: { +{ + pkgs, + lib, + customPkgs, + ... +}: +{ imports = [ ./programs/fastfetch ./programs/helix.nix @@ -23,7 +29,10 @@ programs.git.enable = true; - home.packages = with pkgs; [ docker docker-compose ]; + home.packages = with pkgs; [ + docker + docker-compose + ]; rsydn.aiTools = { enable = lib.mkDefault true; diff --git a/modules/home/devtools/ai-tools.nix b/modules/home/devtools/ai-tools.nix index 72db168..da091fd 100644 --- a/modules/home/devtools/ai-tools.nix +++ b/modules/home/devtools/ai-tools.nix @@ -1,6 +1,18 @@ -{ config, lib, pkgs, inputs, ... }: +{ + config, + lib, + pkgs, + inputs, + ... +}: let - inherit (lib) mkEnableOption mkOption types mkIf escapeShellArg; + inherit (lib) + mkEnableOption + mkOption + types + mkIf + escapeShellArg + ; cfg = config.rsydn.aiTools; system = pkgs.stdenv.hostPlatform.system; @@ -10,48 +22,51 @@ let llmPkgsPinned = inputs.llm-agents-pinned.packages.${system}; # Z.AI Gateway wrapper for Claude Code - zaiWrapperPackages = let zaiCfg = cfg.zai; - in if zaiCfg.enable then + zaiWrapperPackages = let - claudeExe = lib.getExe llmPkgsPinned.claude-code; - commandName = zaiCfg.commandName; - baseUrl = zaiCfg.baseUrl; - model = zaiCfg.model; - tokenEnvVar = zaiCfg.tokenEnvVar; - in [ - (pkgs.writeShellApplication { - name = commandName; - text = '' - if [ -z "''${${tokenEnvVar}:-}" ]; then - echo "${commandName}: environment variable ${tokenEnvVar} is not set" >&2 - exit 1 - fi + zaiCfg = cfg.zai; + in + if zaiCfg.enable then + let + claudeExe = lib.getExe llmPkgsPinned.claude-code; + commandName = zaiCfg.commandName; + baseUrl = zaiCfg.baseUrl; + model = zaiCfg.model; + tokenEnvVar = zaiCfg.tokenEnvVar; + in + [ + (pkgs.writeShellApplication { + name = commandName; + text = '' + if [ -z "''${${tokenEnvVar}:-}" ]; then + echo "${commandName}: environment variable ${tokenEnvVar} is not set" >&2 + exit 1 + fi - export ANTHROPIC_BASE_URL=${escapeShellArg baseUrl} - export ANTHROPIC_AUTH_TOKEN="''${${tokenEnvVar}}" - export ANTHROPIC_MODEL=${escapeShellArg model} + export ANTHROPIC_BASE_URL=${escapeShellArg baseUrl} + export ANTHROPIC_AUTH_TOKEN="''${${tokenEnvVar}}" + export ANTHROPIC_MODEL=${escapeShellArg model} - exec ${claudeExe} "$@" - ''; - }) - ] - else - [ ]; + exec ${claudeExe} "$@" + ''; + }) + ] + else + [ ]; -in { +in +{ options.rsydn.aiTools = { enable = mkEnableOption "AI CLI tools from llm-agents.nix"; zai = mkOption { type = types.submodule { options = { - enable = mkEnableOption - "Expose the Z.AI Gateway wrapper command for Claude."; + enable = mkEnableOption "Expose the Z.AI Gateway wrapper command for Claude."; commandName = mkOption { type = types.str; default = "glm"; - description = - "Name of the wrapper command that launches Claude via Z.AI."; + description = "Name of the wrapper command that launches Claude via Z.AI."; }; baseUrl = mkOption { type = types.str; @@ -66,8 +81,7 @@ in { tokenEnvVar = mkOption { type = types.str; default = "ZAI_API_KEY"; - description = - "Environment variable that stores the Z.AI API token."; + description = "Environment variable that stores the Z.AI API token."; }; }; }; @@ -78,15 +92,13 @@ in { model = "glm-4.7"; tokenEnvVar = "ZAI_API_KEY"; }; - description = - "Configuration for the Claude wrapper that targets the Z.AI gateway."; + description = "Configuration for the Claude wrapper that targets the Z.AI gateway."; }; extraPackages = mkOption { type = types.listOf types.package; default = [ ]; - description = - "Additional AI tooling packages to add alongside the defaults."; + description = "Additional AI tooling packages to add alongside the defaults."; }; }; @@ -98,6 +110,8 @@ in { llmPkgs.ccstatusline # latest llmPkgs.ccusage # latest llmPkgs.codex - ] ++ zaiWrapperPackages ++ cfg.extraPackages; + ] + ++ zaiWrapperPackages + ++ cfg.extraPackages; }; } diff --git a/modules/home/devtools/default.nix b/modules/home/devtools/default.nix index 0101f79..ea298fa 100644 --- a/modules/home/devtools/default.nix +++ b/modules/home/devtools/default.nix @@ -1,8 +1,14 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let inherit (lib) mkOption types mkIf; cfg = config.rsydn.devTools; -in { +in +{ options.rsydn.devTools = { enable = mkOption { type = types.bool; diff --git a/modules/home/devtools/direnv.nix b/modules/home/devtools/direnv.nix index 58b8895..48af946 100644 --- a/modules/home/devtools/direnv.nix +++ b/modules/home/devtools/direnv.nix @@ -2,13 +2,13 @@ let inherit (lib) mkOption types mkIf; cfg = config.rsydn.direnv; -in { +in +{ options.rsydn.direnv = { enable = mkOption { type = types.bool; default = false; - description = - "Enable direnv with nix-direnv for automatic devshell activation."; + description = "Enable direnv with nix-direnv for automatic devshell activation."; }; silent = mkOption { type = types.bool; diff --git a/modules/home/devtools/languages.nix b/modules/home/devtools/languages.nix index 45c745d..dc5404a 100644 --- a/modules/home/devtools/languages.nix +++ b/modules/home/devtools/languages.nix @@ -1,12 +1,29 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let - inherit (lib) mkEnableOption mkOption mkIf types warn unique; + inherit (lib) + mkEnableOption + mkOption + mkIf + types + warn + unique + ; cfg = config.rsydn.languages; hasPkg = name: builtins.hasAttr name pkgs; getPkg = name: if hasPkg name then pkgs.${name} else null; - mkToolOption = { name, defaultPackage, description }: + mkToolOption = + { + name, + defaultPackage, + description, + }: mkOption { type = types.submodule { options = { @@ -18,8 +35,7 @@ let package = mkOption { type = types.nullOr types.package; default = defaultPackage; - description = - "Package derivation to install for ${name}. Set to null to skip."; + description = "Package derivation to install for ${name}. Set to null to skip."; }; }; }; @@ -30,23 +46,25 @@ let description = description; }; - mkToolPackages = specs: - builtins.concatMap (tool: - let toolCfg = tool.cfg; - in if toolCfg.enable then + mkToolPackages = + specs: + builtins.concatMap ( + tool: + let + toolCfg = tool.cfg; + in + if toolCfg.enable then if toolCfg.package != null then [ toolCfg.package ] else warn "rsydn.languages.${tool.name}: package is null, skipping" [ ] else - [ ]) specs; + [ ] + ) specs; uvPackage = getPkg "uv"; goPackage = getPkg "go"; - nodePackage = if builtins.hasAttr "nodejs_20" pkgs then - pkgs.nodejs_20 - else - getPkg "nodejs"; + nodePackage = if builtins.hasAttr "nodejs_20" pkgs then pkgs.nodejs_20 else getPkg "nodejs"; cargoPackage = getPkg "cargo"; bunPackage = getPkg "bun"; @@ -80,7 +98,8 @@ let languagePackages = mkToolPackages toolSpecs; -in { +in +{ options.rsydn.languages = { enable = mkEnableOption "Language tooling packages for everyday workflows"; diff --git a/modules/home/devtools/try.nix b/modules/home/devtools/try.nix index 2b85c74..b620e1a 100644 --- a/modules/home/devtools/try.nix +++ b/modules/home/devtools/try.nix @@ -1,8 +1,20 @@ -{ config, lib, pkgs, try, ... }: +{ + config, + lib, + pkgs, + try, + ... +}: let - inherit (lib) mkEnableOption mkOption types mkIf; + inherit (lib) + mkEnableOption + mkOption + types + mkIf + ; cfg = config.rsydn.try; -in { +in +{ imports = [ try.homeModules.default ]; options.rsydn.try = { diff --git a/modules/home/programs/fastfetch/default.nix b/modules/home/programs/fastfetch/default.nix index ed5045d..97dc31b 100644 --- a/modules/home/programs/fastfetch/default.nix +++ b/modules/home/programs/fastfetch/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: { home.packages = [ pkgs.fastfetch ]; @@ -6,147 +11,145 @@ # Copy the custom logo file xdg.configFile."fastfetch/oguri-logo.txt".source = ./oguri-logo.txt; - xdg.configFile."fastfetch/config.jsonc".text = let - esc = builtins.fromJSON ''"\u001b"''; - osIcon = if pkgs.stdenv.isDarwin then "" else ""; - in builtins.toJSON { - "$schema" = - "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json"; + xdg.configFile."fastfetch/config.jsonc".text = + let + esc = builtins.fromJSON ''"\u001b"''; + osIcon = if pkgs.stdenv.isDarwin then "" else ""; + in + builtins.toJSON { + "$schema" = "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json"; - logo = { - type = "file"; - source = "~/.config/fastfetch/oguri-logo.txt"; - color."1" = "green"; - padding = { - top = 2; - right = 6; - left = 2; + logo = { + type = "file"; + source = "~/.config/fastfetch/oguri-logo.txt"; + color."1" = "green"; + padding = { + top = 2; + right = 6; + left = 2; + }; }; + + display = { + separator = " → "; + key = { + width = 16; + }; + }; + + modules = [ + "break" + + # Hardware Section + { + type = "custom"; + format = "${esc}[32m── Hardware──────────────────────────────────────────${esc}[0m"; + } + { + type = "host"; + key = " PC"; + keyColor = "green"; + } + { + type = "cpu"; + key = " CPU"; + showPeCoreCount = true; + keyColor = "green"; + } + { + type = "gpu"; + key = " GPU"; + detectionMethod = "pci"; + keyColor = "green"; + } + { + type = "display"; + key = "󱄄 Display"; + keyColor = "green"; + } + { + type = "disk"; + key = "󰋊 Disk"; + keyColor = "green"; + } + { + type = "memory"; + key = " Memory"; + keyColor = "green"; + } + { + type = "swap"; + key = "󰓡 Swap"; + keyColor = "green"; + } + "break" + + # Software Section + { + type = "custom"; + format = "${esc}[34m── Software──────────────────────────────────────────${esc}[0m"; + } + { + type = "command"; + key = "${osIcon} OS"; + keyColor = "blue"; + text = "if [ $(uname) = 'Darwin' ]; then ver=$(sw_vers -productVersion); major=$(echo $ver | cut -d. -f1); case $major in 15) name='Sequoia';; 14) name='Sonoma';; 13) name='Ventura';; 12) name='Monterey';; 11) name='Big Sur';; *) name=''';; esac; echo \"macOS $name $major\"; else echo \"$(cat /etc/os-release | grep PRETTY_NAME | cut -d'\\\"' -f2)\"; fi"; + } + { + type = "kernel"; + key = " Kernel"; + keyColor = "blue"; + } + { + type = "wm"; + key = " WM"; + keyColor = "blue"; + } + { + type = "de"; + key = " DE"; + keyColor = "blue"; + } + { + type = "terminal"; + key = " Terminal"; + keyColor = "blue"; + } + { + type = "packages"; + key = "󰏖 Packages"; + keyColor = "blue"; + } + { + type = "wmtheme"; + key = "󰉼 WM Theme"; + keyColor = "blue"; + } + { + type = "terminalfont"; + key = " Font"; + keyColor = "blue"; + } + "break" + + # Uptime / Age Section + { + type = "custom"; + format = "${esc}[35m── Uptime / Age─────────────────────────────────────${esc}[0m"; + } + { + type = "command"; + key = "󱦟 OS Age"; + keyColor = "magenta"; + # macOS compatible stat command + text = ''if [ $(uname) = 'Darwin' ]; then birth=$(stat -f %B /); else birth=$(stat -c %W /); fi; current=$(date +%s); days=$(( (current - birth) / 86400 )); echo "$days days"''; + } + { + type = "uptime"; + key = "󱫐 Uptime"; + keyColor = "magenta"; + } + "break" + ]; }; - - display = { - separator = " → "; - key = { width = 16; }; - }; - - modules = [ - "break" - - # Hardware Section - { - type = "custom"; - format = - "${esc}[32m── Hardware──────────────────────────────────────────${esc}[0m"; - } - { - type = "host"; - key = " PC"; - keyColor = "green"; - } - { - type = "cpu"; - key = " CPU"; - showPeCoreCount = true; - keyColor = "green"; - } - { - type = "gpu"; - key = " GPU"; - detectionMethod = "pci"; - keyColor = "green"; - } - { - type = "display"; - key = "󱄄 Display"; - keyColor = "green"; - } - { - type = "disk"; - key = "󰋊 Disk"; - keyColor = "green"; - } - { - type = "memory"; - key = " Memory"; - keyColor = "green"; - } - { - type = "swap"; - key = "󰓡 Swap"; - keyColor = "green"; - } - "break" - - # Software Section - { - type = "custom"; - format = - "${esc}[34m── Software──────────────────────────────────────────${esc}[0m"; - } - { - type = "command"; - key = "${osIcon} OS"; - keyColor = "blue"; - text = - "if [ $(uname) = 'Darwin' ]; then ver=$(sw_vers -productVersion); major=$(echo $ver | cut -d. -f1); case $major in 15) name='Sequoia';; 14) name='Sonoma';; 13) name='Ventura';; 12) name='Monterey';; 11) name='Big Sur';; *) name=''';; esac; echo \"macOS $name $major\"; else echo \"$(cat /etc/os-release | grep PRETTY_NAME | cut -d'\\\"' -f2)\"; fi"; - } - { - type = "kernel"; - key = " Kernel"; - keyColor = "blue"; - } - { - type = "wm"; - key = " WM"; - keyColor = "blue"; - } - { - type = "de"; - key = " DE"; - keyColor = "blue"; - } - { - type = "terminal"; - key = " Terminal"; - keyColor = "blue"; - } - { - type = "packages"; - key = "󰏖 Packages"; - keyColor = "blue"; - } - { - type = "wmtheme"; - key = "󰉼 WM Theme"; - keyColor = "blue"; - } - { - type = "terminalfont"; - key = " Font"; - keyColor = "blue"; - } - "break" - - # Uptime / Age Section - { - type = "custom"; - format = - "${esc}[35m── Uptime / Age─────────────────────────────────────${esc}[0m"; - } - { - type = "command"; - key = "󱦟 OS Age"; - keyColor = "magenta"; - # macOS compatible stat command - text = '' - if [ $(uname) = 'Darwin' ]; then birth=$(stat -f %B /); else birth=$(stat -c %W /); fi; current=$(date +%s); days=$(( (current - birth) / 86400 )); echo "$days days"''; - } - { - type = "uptime"; - key = "󱫐 Uptime"; - keyColor = "magenta"; - } - "break" - ]; - }; } diff --git a/modules/home/programs/helix.nix b/modules/home/programs/helix.nix index 80a12e6..d443d72 100644 --- a/modules/home/programs/helix.nix +++ b/modules/home/programs/helix.nix @@ -1,4 +1,5 @@ -{ pkgs, lib, ... }: { +{ pkgs, lib, ... }: +{ programs.helix = { enable = lib.mkDefault true; settings = { @@ -18,10 +19,12 @@ }; }; }; - languages.language = [{ - name = "nix"; - auto-format = true; - formatter.command = "${pkgs.nixfmt-classic}/bin/nixfmt"; - }]; + languages.language = [ + { + name = "nix"; + auto-format = true; + formatter.command = "${pkgs.nixfmt}/bin/nixfmt"; + } + ]; }; } diff --git a/modules/home/programs/neovim.nix b/modules/home/programs/neovim.nix index 30b7bad..1d7d1a3 100644 --- a/modules/home/programs/neovim.nix +++ b/modules/home/programs/neovim.nix @@ -1,4 +1,5 @@ -{ pkgs, config, ... }: { +{ pkgs, config, ... }: +{ programs.neovim = { enable = true; viAlias = true; @@ -27,7 +28,7 @@ # Formatters stylua # Lua - nixfmt-classic # Nix (matches your fmt command) + nixfmt # Nix ruff # Python (formatter + linter) prettierd # JS/TS/JSON/YAML/Markdown rustfmt # Rust @@ -61,15 +62,14 @@ }; # Copy lazy-lock.json as writable (not symlinked to read-only Nix store) - home.activation.makeNvimLockWritable = - config.lib.dag.entryAfter [ "linkGeneration" ] '' - lockFile="${config.xdg.configHome}/nvim/lazy-lock.json" - sourceLock="${./nvim/lazy-lock.json}" + home.activation.makeNvimLockWritable = config.lib.dag.entryAfter [ "linkGeneration" ] '' + lockFile="${config.xdg.configHome}/nvim/lazy-lock.json" + sourceLock="${./nvim/lazy-lock.json}" - if [ -L "$lockFile" ]; then - rm "$lockFile" - cp "$sourceLock" "$lockFile" - chmod 644 "$lockFile" - fi - ''; + if [ -L "$lockFile" ]; then + rm "$lockFile" + cp "$sourceLock" "$lockFile" + chmod 644 "$lockFile" + fi + ''; } diff --git a/modules/home/secrets.nix b/modules/home/secrets.nix index 6d23eb7..354b9f5 100644 --- a/modules/home/secrets.nix +++ b/modules/home/secrets.nix @@ -1,24 +1,43 @@ -{ config, lib, inputs, ... }: +{ + config, + lib, + inputs, + ... +}: let - inherit (lib) mkEnableOption mkOption mkIf types; + inherit (lib) + mkEnableOption + mkOption + mkIf + types + ; cfg = config.rsydn.secrets; - sanitizeSecret = name: secret: + sanitizeSecret = + name: secret: let sopsFile = secret.sopsFile or cfg.defaultSopsFile; - extra = - lib.filterAttrs (k: _: !(builtins.elem k [ "path" "mode" "sopsFile" ])) - secret; - in { + extra = lib.filterAttrs ( + k: _: + !(builtins.elem k [ + "path" + "mode" + "sopsFile" + ]) + ) secret; + in + { path = secret.path or "${config.xdg.configHome}/secrets/${name}"; mode = secret.mode or "0400"; - } // (lib.optionalAttrs (sopsFile != null) { inherit sopsFile; }) // extra; -in { + } + // (lib.optionalAttrs (sopsFile != null) { inherit sopsFile; }) + // extra; +in +{ imports = [ inputs.sops-nix.homeManagerModules.sops ]; options.rsydn.secrets = { - enable = - mkEnableOption "sops-nix integration for managing decrypted secrets"; + enable = mkEnableOption "sops-nix integration for managing decrypted secrets"; ageKeyFile = mkOption { type = types.str; @@ -29,15 +48,13 @@ in { defaultSopsFile = mkOption { type = types.nullOr types.path; default = null; - description = - "Optional default SOPS file used when a secret definition omits `sopsFile`."; + description = "Optional default SOPS file used when a secret definition omits `sopsFile`."; }; secrets = mkOption { type = types.attrsOf types.attrs; default = { }; - description = - "Secret entries forwarded to `sops.secrets` with sensible defaults."; + description = "Secret entries forwarded to `sops.secrets` with sensible defaults."; example = lib.literalExpression '' { "api-key" = { @@ -58,14 +75,14 @@ in { }; secrets = lib.mapAttrs sanitizeSecret cfg.secrets; - } // (lib.optionalAttrs (cfg.defaultSopsFile != null) { + } + // (lib.optionalAttrs (cfg.defaultSopsFile != null) { defaultSopsFile = cfg.defaultSopsFile; }); - home.activation.ensureSecretDir = - lib.hm.dag.entryAfter [ "writeBoundary" ] '' - mkdir -p "${config.xdg.configHome}/secrets" - chmod 700 "${config.xdg.configHome}/secrets" - ''; + home.activation.ensureSecretDir = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + mkdir -p "${config.xdg.configHome}/secrets" + chmod 700 "${config.xdg.configHome}/secrets" + ''; }; } diff --git a/modules/home/shell/fish.nix b/modules/home/shell/fish.nix index efa494c..4ebcdd4 100644 --- a/modules/home/shell/fish.nix +++ b/modules/home/shell/fish.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ programs.fish = { enable = true; interactiveShellInit = '' diff --git a/modules/home/shell/nushell.nix b/modules/home/shell/nushell.nix index 6f09fba..b75c680 100644 --- a/modules/home/shell/nushell.nix +++ b/modules/home/shell/nushell.nix @@ -1,31 +1,40 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let profileBin = "${config.home.profileDirectory}/bin"; # System binaries path - same on both NixOS and Darwin systemBin = "/run/current-system/sw/bin"; defaultBin = "/nix/var/nix/profiles/default/bin"; - darwinHomebrewDir = if pkgs.stdenv.hostPlatform.isAarch64 then - "/opt/homebrew" - else - "/usr/local"; + darwinHomebrewDir = if pkgs.stdenv.hostPlatform.isAarch64 then "/opt/homebrew" else "/usr/local"; homebrewBin = "${darwinHomebrewDir}/bin"; homebrewSbin = "${darwinHomebrewDir}/sbin"; - homebrewPaths = if pkgs.stdenv.hostPlatform.isDarwin then - lib.unique [ homebrewBin homebrewSbin ] - else - [ ]; + homebrewPaths = + if pkgs.stdenv.hostPlatform.isDarwin then + lib.unique [ + homebrewBin + homebrewSbin + ] + else + [ ]; # Add common macOS system paths that may contain user-installed CLIs - macosSystemPaths = if pkgs.stdenv.hostPlatform.isDarwin then [ - "/usr/local/bin" - "/usr/bin" - "/bin" - "/usr/sbin" - "/sbin" - ] else - [ ]; - formatPathList = paths: - lib.concatMapStrings (path: " \"${path}\"\n") paths; -in { + macosSystemPaths = + if pkgs.stdenv.hostPlatform.isDarwin then + [ + "/usr/local/bin" + "/usr/bin" + "/bin" + "/usr/sbin" + "/sbin" + ] + else + [ ]; + formatPathList = paths: lib.concatMapStrings (path: " \"${path}\"\n") paths; +in +{ imports = [ ./starship ]; programs.nushell.enable = lib.mkDefault true; @@ -141,7 +150,13 @@ in { $env.XDG_CACHE_HOME = "${config.xdg.cacheHome}" let nix_paths = [ - ${formatPathList [ profileBin systemBin defaultBin ]} ] + ${ + formatPathList [ + profileBin + systemBin + defaultBin + ] + } ] let homebrew_paths = [ ${formatPathList homebrewPaths} ] diff --git a/modules/home/shell/starship/default.nix b/modules/home/shell/starship/default.nix index ea83b79..3998b2e 100644 --- a/modules/home/shell/starship/default.nix +++ b/modules/home/shell/starship/default.nix @@ -1,4 +1,5 @@ -{ lib, ... }: { +{ lib, ... }: +{ programs.starship = { enable = lib.mkDefault true; enableFishIntegration = true; diff --git a/modules/home/shell/tmux.nix b/modules/home/shell/tmux.nix index 26cffe7..8de8a45 100644 --- a/modules/home/shell/tmux.nix +++ b/modules/home/shell/tmux.nix @@ -1,4 +1,10 @@ -{ config, lib, pkgs, ... }: { +{ + config, + lib, + pkgs, + ... +}: +{ programs.tmux = { enable = lib.mkDefault true; clock24 = true; @@ -8,7 +14,7 @@ prefix = "C-a"; escapeTime = 0; aggressiveResize = true; - plugins = [{ plugin = pkgs.tmuxPlugins.gruvbox; }]; + plugins = [ { plugin = pkgs.tmuxPlugins.gruvbox; } ]; extraConfig = '' # Terminal configuration for proper colors and features set-option -g default-terminal "screen-256color" diff --git a/modules/nixos/audio.nix b/modules/nixos/audio.nix index f1093db..ad9707e 100644 --- a/modules/nixos/audio.nix +++ b/modules/nixos/audio.nix @@ -1,4 +1,5 @@ -{ lib, ... }: { +{ lib, ... }: +{ # Modern audio stack - PipeWire replaces PulseAudio + JACK + ALSA services.pipewire = { enable = lib.mkDefault true; diff --git a/modules/nixos/bluetooth.nix b/modules/nixos/bluetooth.nix index e3040b4..cd64072 100644 --- a/modules/nixos/bluetooth.nix +++ b/modules/nixos/bluetooth.nix @@ -1,4 +1,5 @@ -{ lib, ... }: { +{ lib, ... }: +{ hardware.bluetooth = { enable = lib.mkDefault false; # Enable when needed powerOnBoot = lib.mkDefault true; diff --git a/modules/nixos/containerization.nix b/modules/nixos/containerization.nix index 1dcae25..c465ba7 100644 --- a/modules/nixos/containerization.nix +++ b/modules/nixos/containerization.nix @@ -1,37 +1,51 @@ -{ config, lib, pkgs, user, ... }: +{ + config, + lib, + pkgs, + user, + ... +}: let inherit (lib) - mkEnableOption mkOption mkIf types mkMerge mkAfter optionals mkDefault; + mkEnableOption + mkOption + mkIf + types + mkMerge + mkAfter + optionals + mkDefault + ; cfg = config.rsydn.containerization; -in { +in +{ options.rsydn.containerization = { podman = { enable = mkOption { type = types.bool; default = true; - description = - "Enable Podman for rootless containers as the primary engine."; + description = "Enable Podman for rootless containers as the primary engine."; }; dockerCompat = mkOption { type = types.bool; default = true; - description = - "Expose the Docker-compatible socket for CLI compatibility."; + description = "Expose the Docker-compatible socket for CLI compatibility."; }; enableDnsnamePlugin = mkOption { type = types.bool; default = true; - description = - "Enable the dnsname CNI plugin so containers can resolve each other."; + description = "Enable the dnsname CNI plugin so containers can resolve each other."; }; extraPackages = mkOption { type = types.listOf types.package; - default = with pkgs; [ podman-compose podman-tui ]; - description = - "Additional Podman-related packages to install system-wide."; + default = with pkgs; [ + podman-compose + podman-tui + ]; + description = "Additional Podman-related packages to install system-wide."; }; }; @@ -39,8 +53,7 @@ in { enable = mkOption { type = types.bool; default = false; - description = - "Enable the Docker daemon alongside Podman when explicitly requested."; + description = "Enable the Docker daemon alongside Podman when explicitly requested."; }; autoPrune = mkOption { @@ -49,18 +62,19 @@ in { enable = mkOption { type = types.bool; default = true; - description = - "Automatically prune unused Docker data on a schedule."; + description = "Automatically prune unused Docker data on a schedule."; }; dates = mkOption { type = types.str; default = "weekly"; - description = - "Systemd calendar expression for docker system prune."; + description = "Systemd calendar expression for docker system prune."; }; flags = mkOption { type = types.listOf types.str; - default = [ "--all" "--volumes" ]; + default = [ + "--all" + "--volumes" + ]; description = "Extra flags passed to docker system prune."; }; }; @@ -71,11 +85,13 @@ in { }; k3s = { - enable = - mkEnableOption "Run a lightweight Kubernetes control plane with k3s."; + enable = mkEnableOption "Run a lightweight Kubernetes control plane with k3s."; role = mkOption { - type = types.enum [ "server" "agent" ]; + type = types.enum [ + "server" + "agent" + ]; default = "server"; description = "Choose whether this node runs as a k3s server or agent."; }; @@ -99,14 +115,18 @@ in { environment.systemPackages = mkAfter cfg.podman.extraPackages; users.users.${user} = { - subUidRanges = mkDefault [{ - startUid = 100000; - count = 65536; - }]; - subGidRanges = mkDefault [{ - startGid = 100000; - count = 65536; - }]; + subUidRanges = mkDefault [ + { + startUid = 100000; + count = 65536; + } + ]; + subGidRanges = mkDefault [ + { + startGid = 100000; + count = 65536; + } + ]; }; }) @@ -130,8 +150,7 @@ in { extraFlags = cfg.k3s.extraFlags; }; - networking.firewall.allowedTCPPorts = - mkAfter (optionals (cfg.k3s.role == "server") [ 6443 ]); + networking.firewall.allowedTCPPorts = mkAfter (optionals (cfg.k3s.role == "server") [ 6443 ]); }) ]; } diff --git a/modules/nixos/desktops/apps/browsers.nix b/modules/nixos/desktops/apps/browsers.nix index c61d233..257b08d 100644 --- a/modules/nixos/desktops/apps/browsers.nix +++ b/modules/nixos/desktops/apps/browsers.nix @@ -1,4 +1,5 @@ -{ pkgs, user, ... }: { +{ pkgs, user, ... }: +{ # Browser configurations for desktop users home-manager.users.${user} = { diff --git a/modules/nixos/desktops/apps/terminals.nix b/modules/nixos/desktops/apps/terminals.nix index 1120694..fa7a535 100644 --- a/modules/nixos/desktops/apps/terminals.nix +++ b/modules/nixos/desktops/apps/terminals.nix @@ -1,4 +1,10 @@ -{ lib, pkgs, user, ... }: { +{ + lib, + pkgs, + user, + ... +}: +{ # Terminal emulator configurations for desktop users home-manager.users.${user} = { diff --git a/modules/nixos/desktops/base.nix b/modules/nixos/desktops/base.nix index 7e078bb..1caf9d6 100644 --- a/modules/nixos/desktops/base.nix +++ b/modules/nixos/desktops/base.nix @@ -1,4 +1,5 @@ -{ lib, pkgs, ... }: { +{ lib, pkgs, ... }: +{ # Shared desktop settings (imported by all DEs) # XDG portals for desktop integration diff --git a/modules/nixos/desktops/gaming.nix b/modules/nixos/desktops/gaming.nix index dc9ec24..80cebc0 100644 --- a/modules/nixos/desktops/gaming.nix +++ b/modules/nixos/desktops/gaming.nix @@ -1,4 +1,5 @@ -{ pkgs, ... }: { +{ pkgs, ... }: +{ # Gaming configuration module # Steam, Proton, Vulkan, Wine, and gaming optimizations @@ -9,17 +10,18 @@ dedicatedServer.openFirewall = true; # Enable Proton compatibility layer - extraCompatPackages = with pkgs; - [ - proton-ge-bin # GloriousEggroll's Proton builds - ]; + extraCompatPackages = with pkgs; [ + proton-ge-bin # GloriousEggroll's Proton builds + ]; }; # GameMode for performance optimization programs.gamemode = { enable = true; settings = { - general = { renice = 10; }; + general = { + renice = 10; + }; custom = { start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'"; end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'"; @@ -72,5 +74,7 @@ # ]; # Increase file watchers for game modding tools - boot.kernel.sysctl = { "fs.inotify.max_user_watches" = 524288; }; + boot.kernel.sysctl = { + "fs.inotify.max_user_watches" = 524288; + }; } diff --git a/modules/nixos/desktops/hardware-configuration.nix b/modules/nixos/desktops/hardware-configuration.nix index 1419afc..d7d6df7 100644 --- a/modules/nixos/desktops/hardware-configuration.nix +++ b/modules/nixos/desktops/hardware-configuration.nix @@ -2,15 +2,25 @@ # Generated by running: nixos-generate-config --show-hardware-config # This file contains hardware-specific settings that should be adjusted for your actual hardware -{ config, lib, modulesPath, ... }: +{ + config, + lib, + modulesPath, + ... +}: { imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; # Kernel modules needed during boot # Adjust based on your hardware (NVMe, SATA, USB, etc.) - boot.initrd.availableKernelModules = - [ "nvme" "xhci_pci" "ahci" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usb_storage" + "sd_mod" + ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; # Change to "kvm-intel" for Intel CPUs @@ -24,7 +34,10 @@ fileSystems."/boot" = { device = "/dev/disk/by-uuid/REPLACE-WITH-YOUR-BOOT-UUID"; fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; + options = [ + "fmask=0022" + "dmask=0022" + ]; }; # Swap configuration (optional) @@ -34,8 +47,7 @@ # ]; # CPU microcode updates - hardware.cpu.amd.updateMicrocode = - lib.mkDefault config.hardware.enableRedistributableFirmware; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; # For Intel CPUs, use this instead: # hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; diff --git a/modules/nixos/desktops/hyprland/default.nix b/modules/nixos/desktops/hyprland/default.nix index 40bd0e6..5d54660 100644 --- a/modules/nixos/desktops/hyprland/default.nix +++ b/modules/nixos/desktops/hyprland/default.nix @@ -1,4 +1,10 @@ -{ pkgs, lib, user, ... }: { +{ + pkgs, + lib, + user, + ... +}: +{ imports = [ ../base.nix ]; # System-level: Enable Hyprland @@ -55,17 +61,18 @@ border_size = 2; }; - decoration = { rounding = 8; }; + decoration = { + rounding = 8; + }; }; }; # User packages: Hyprland utilities - home.packages = with pkgs; - [ - # Uncomment as needed: - # wofi # Launcher - # waybar # Status bar - # dunst # Notifications - ]; + home.packages = with pkgs; [ + # Uncomment as needed: + # wofi # Launcher + # waybar # Status bar + # dunst # Notifications + ]; }; } diff --git a/modules/nixos/desktops/plasma.nix b/modules/nixos/desktops/plasma.nix index 4872624..32c5c7a 100644 --- a/modules/nixos/desktops/plasma.nix +++ b/modules/nixos/desktops/plasma.nix @@ -1,4 +1,10 @@ -{ lib, pkgs, user, ... }: { +{ + lib, + pkgs, + user, + ... +}: +{ imports = [ ./base.nix ]; # System-level: KDE Plasma 6 @@ -11,16 +17,15 @@ }; # System packages: KDE applications - environment.systemPackages = with pkgs; - [ - # KDE applications (uncomment as needed) - # kdePackages.kate # Text editor - # kdePackages.dolphin # File manager - # kdePackages.konsole # Terminal - # kdePackages.okular # Document viewer - # kdePackages.gwenview # Image viewer - # kdePackages.spectacle # Screenshot tool - ]; + environment.systemPackages = with pkgs; [ + # KDE applications (uncomment as needed) + # kdePackages.kate # Text editor + # kdePackages.dolphin # File manager + # kdePackages.konsole # Terminal + # kdePackages.okular # Document viewer + # kdePackages.gwenview # Image viewer + # kdePackages.spectacle # Screenshot tool + ]; # User-level: KDE Plasma settings (optional) home-manager.users.${user} = { @@ -34,9 +39,8 @@ # }; # User packages for KDE environment - home.packages = with pkgs; - [ - # Add user-specific apps here - ]; + home.packages = with pkgs; [ + # Add user-specific apps here + ]; }; } diff --git a/modules/nixos/desktops/themes/catppuccin.nix b/modules/nixos/desktops/themes/catppuccin.nix index 74142ff..6ae7e7c 100644 --- a/modules/nixos/desktops/themes/catppuccin.nix +++ b/modules/nixos/desktops/themes/catppuccin.nix @@ -1,4 +1,10 @@ -{ lib, pkgs, user, ... }: { +{ + lib, + pkgs, + user, + ... +}: +{ # Catppuccin theme configuration # Soothing pastel theme for both GTK and Qt applications # Works with KDE Plasma, Hyprland, and other desktop environments diff --git a/modules/nixos/desktops/themes/default.nix b/modules/nixos/desktops/themes/default.nix index 649143d..49d5ea9 100644 --- a/modules/nixos/desktops/themes/default.nix +++ b/modules/nixos/desktops/themes/default.nix @@ -1,4 +1,10 @@ -{ lib, pkgs, user, ... }: { +{ + lib, + pkgs, + user, + ... +}: +{ # Default theme configuration for desktop # Simple Adwaita-dark theme that works across all desktop environments # Switch to catppuccin.nix or create your own for custom themes diff --git a/modules/nixos/fonts.nix b/modules/nixos/fonts.nix index c56813b..995940e 100644 --- a/modules/nixos/fonts.nix +++ b/modules/nixos/fonts.nix @@ -1,10 +1,17 @@ -{ lib, pkgs, ... }: { +{ lib, pkgs, ... }: +{ fonts = { enableDefaultPackages = lib.mkDefault true; packages = with pkgs; [ # Nerd Fonts for terminal icons - (nerdfonts.override { fonts = [ "FiraCode" "JetBrainsMono" "Iosevka" ]; }) + (nerdfonts.override { + fonts = [ + "FiraCode" + "JetBrainsMono" + "Iosevka" + ]; + }) # Core fonts noto-fonts @@ -20,7 +27,10 @@ fontconfig = { enable = lib.mkDefault true; defaultFonts = { - monospace = [ "JetBrains Mono" "FiraCode Nerd Font" ]; + monospace = [ + "JetBrains Mono" + "FiraCode Nerd Font" + ]; sansSerif = [ "Noto Sans" ]; serif = [ "Noto Serif" ]; emoji = [ "Noto Color Emoji" ]; diff --git a/modules/nixos/graphics.nix b/modules/nixos/graphics.nix index 0b319ce..eca92e9 100644 --- a/modules/nixos/graphics.nix +++ b/modules/nixos/graphics.nix @@ -1,4 +1,5 @@ -{ lib, pkgs, ... }: { +{ lib, pkgs, ... }: +{ # Hardware acceleration (OpenGL/Vulkan) hardware.graphics = { enable = lib.mkDefault true; diff --git a/modules/nixos/home/default.nix b/modules/nixos/home/default.nix index 9fa38e8..645bf7b 100644 --- a/modules/nixos/home/default.nix +++ b/modules/nixos/home/default.nix @@ -1,4 +1,10 @@ -{ config, pkgs, lib, ... }: { +{ + config, + pkgs, + lib, + ... +}: +{ # Minimal CLI-only Home Manager configuration # Used for servers, VMs, and headless systems # Desktop configs are handled directly in nixos/desktops/* modules diff --git a/modules/nixos/network.nix b/modules/nixos/network.nix index a5933c2..3faa474 100644 --- a/modules/nixos/network.nix +++ b/modules/nixos/network.nix @@ -1,4 +1,5 @@ -{ lib, ... }: { +{ lib, ... }: +{ networking.useDHCP = lib.mkDefault true; networking.networkmanager.enable = lib.mkDefault true; } diff --git a/modules/nixos/ssh.nix b/modules/nixos/ssh.nix index efb8028..fd96473 100644 --- a/modules/nixos/ssh.nix +++ b/modules/nixos/ssh.nix @@ -1,4 +1,5 @@ -{ lib, ... }: { +{ lib, ... }: +{ services.openssh = { enable = lib.mkDefault true; openFirewall = lib.mkDefault true; diff --git a/modules/nixos/system.nix b/modules/nixos/system.nix index 6065365..825873d 100644 --- a/modules/nixos/system.nix +++ b/modules/nixos/system.nix @@ -1,10 +1,22 @@ -{ lib, user, ... }: { - imports = [ ./users.nix ./network.nix ./ssh.nix ./containerization.nix ]; +{ lib, user, ... }: +{ + imports = [ + ./users.nix + ./network.nix + ./ssh.nix + ./containerization.nix + ]; nix = { settings.auto-optimise-store = lib.mkDefault true; - settings.experimental-features = lib.mkDefault [ "nix-command" "flakes" ]; - settings.trusted-users = lib.mkDefault [ "root" user ]; + settings.experimental-features = lib.mkDefault [ + "nix-command" + "flakes" + ]; + settings.trusted-users = lib.mkDefault [ + "root" + user + ]; optimise.automatic = lib.mkDefault true; gc = { automatic = lib.mkDefault true; diff --git a/modules/nixos/users.nix b/modules/nixos/users.nix index 820290e..8080961 100644 --- a/modules/nixos/users.nix +++ b/modules/nixos/users.nix @@ -1,7 +1,17 @@ -{ lib, pkgs, user, ... }: { +{ + lib, + pkgs, + user, + ... +}: +{ users.users.${user} = { isNormalUser = lib.mkDefault true; - extraGroups = lib.mkDefault [ "wheel" "networkmanager" "docker" ]; + extraGroups = lib.mkDefault [ + "wheel" + "networkmanager" + "docker" + ]; home = lib.mkDefault "/home/${user}"; shell = pkgs.fish; }; diff --git a/modules/nixos/virtualization.nix b/modules/nixos/virtualization.nix index 73afbad..4a6ce5c 100644 --- a/modules/nixos/virtualization.nix +++ b/modules/nixos/virtualization.nix @@ -1,4 +1,5 @@ -{ lib, pkgs, ... }: { +{ lib, pkgs, ... }: +{ # QEMU guest agent provides graceful shutdowns and metadata exchange. # Disabled by default - enable in host overlay if needed. services.qemuGuest.enable = lib.mkDefault false; @@ -18,8 +19,11 @@ "virtio_mmio" ]; - boot.kernelModules = - lib.mkDefault [ "virtio_balloon" "virtio_console" "virtio_rng" ]; + boot.kernelModules = lib.mkDefault [ + "virtio_balloon" + "virtio_console" + "virtio_rng" + ]; # Provide udev rules to improve virtio device behaviour. services.udev.extraRules = lib.mkDefault '' diff --git a/packages/default.nix b/packages/default.nix index d809254..0fe57ec 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -1,6 +1,13 @@ -{ pkgs, lib, llm-agents }: +{ + pkgs, + lib, + llm-agents, +}: let system = pkgs.stdenv.hostPlatform.system; llmPkgs = llm-agents.packages.${system}; -in { opencode = llmPkgs.opencode; } +in +{ + opencode = llmPkgs.opencode; +} diff --git a/shells/README.md b/shells/README.md index 9660bdb..820eeea 100644 --- a/shells/README.md +++ b/shells/README.md @@ -15,7 +15,7 @@ nix develop # or: nix develop .#default **Includes:** - Git -- nixfmt-classic +- nixfmt - uv (for `uvx` commands) **MCP helper:** diff --git a/shells/ai-agent.nix b/shells/ai-agent.nix index 5520e1c..2c50531 100644 --- a/shells/ai-agent.nix +++ b/shells/ai-agent.nix @@ -1,4 +1,9 @@ -{ pkgs, lib, customPkgs, ... }: +{ + pkgs, + lib, + customPkgs, + ... +}: pkgs.mkShell { name = "ai-agent"; diff --git a/shells/ai-notebook.nix b/shells/ai-notebook.nix index ddac3a4..06a44b3 100644 --- a/shells/ai-notebook.nix +++ b/shells/ai-notebook.nix @@ -1,7 +1,13 @@ -{ pkgs, lib, python ? pkgs.python312, ... }: +{ + pkgs, + lib, + python ? pkgs.python312, + ... +}: let - pythonWithAI = python.withPackages (ps: + pythonWithAI = python.withPackages ( + ps: let basePackages = with ps; [ accelerate @@ -25,12 +31,28 @@ let tokenizers transformers ]; - linuxOnlyPackages = lib.optionals pkgs.stdenv.isLinux - (with ps; [ sentencepiece torch torchaudio torchvision ]); - in basePackages ++ linuxOnlyPackages); -in pkgs.mkShell { + linuxOnlyPackages = lib.optionals pkgs.stdenv.isLinux ( + with ps; + [ + sentencepiece + torch + torchaudio + torchvision + ] + ); + in + basePackages ++ linuxOnlyPackages + ); +in +pkgs.mkShell { name = "ai-notebook"; - packages = with pkgs; [ pythonWithAI uv git-lfs ruff pyright ]; + packages = with pkgs; [ + pythonWithAI + uv + git-lfs + ruff + pyright + ]; shellHook = '' export UV_PYTHON="${pythonWithAI}/bin/python3" diff --git a/shells/default.nix b/shells/default.nix index 47cdfc5..e0438d1 100644 --- a/shells/default.nix +++ b/shells/default.nix @@ -8,15 +8,17 @@ let ''; # Generate MCP configs for GUI applications - mcpConfigForGUI = pkgs.writeText "mcp_settings.json" (builtins.toJSON { - mcpServers = { - nixos = { - type = "stdio"; - command = "${mcpNixosWrapper}/bin/mcp-nixos-wrapper"; - args = [ ]; + mcpConfigForGUI = pkgs.writeText "mcp_settings.json" ( + builtins.toJSON { + mcpServers = { + nixos = { + type = "stdio"; + command = "${mcpNixosWrapper}/bin/mcp-nixos-wrapper"; + args = [ ]; + }; }; - }; - }); + } + ); # Script to install MCP configs for Claude Code and Codex installMcpConfigs = pkgs.writeShellScriptBin "install-mcp-configs" '' @@ -83,12 +85,13 @@ let "$out_link/bin/nvim" "$@" ''; -in pkgs.mkShell { +in +pkgs.mkShell { name = "default"; packages = with pkgs; [ git nix - nixfmt-classic + nixfmt uv python3 mcpNixosWrapper diff --git a/shells/effect-ts.nix b/shells/effect-ts.nix index ad71996..39628d1 100644 --- a/shells/effect-ts.nix +++ b/shells/effect-ts.nix @@ -93,7 +93,8 @@ let echo " bun es list - Browse Effect patterns" ''; -in pkgs.mkShell { +in +pkgs.mkShell { name = "effect-ts"; packages = with pkgs; [ bun diff --git a/shells/go.nix b/shells/go.nix index 22e2c28..89d2d71 100644 --- a/shells/go.nix +++ b/shells/go.nix @@ -2,7 +2,13 @@ pkgs.mkShell { name = "go"; - packages = with pkgs; [ go gopls golangci-lint delve git ]; + packages = with pkgs; [ + go + gopls + golangci-lint + delve + git + ]; shellHook = '' mkdir -p "$PWD/.cache/go" "$PWD/.cache/gomod" export GOPATH="$PWD/.cache/go" diff --git a/shells/jupyter-notebook.nix b/shells/jupyter-notebook.nix index f8db924..beee5e5 100644 --- a/shells/jupyter-notebook.nix +++ b/shells/jupyter-notebook.nix @@ -1,9 +1,13 @@ -{ pkgs, python ? pkgs.python312, ... }: +{ + pkgs, + python ? pkgs.python312, + ... +}: let # Python environment with notebook tooling and core data-science libs - pythonWithNotebook = python.withPackages (ps: - with ps; [ + pythonWithNotebook = python.withPackages ( + ps: with ps; [ altair ipykernel jupyterlab @@ -15,10 +19,17 @@ let scipy scikit-learn seaborn - ]); -in pkgs.mkShell { + ] + ); +in +pkgs.mkShell { name = "jupyter-notebook"; - packages = [ pythonWithNotebook pkgs.ruff pkgs.pyright pkgs.git ]; + packages = [ + pythonWithNotebook + pkgs.ruff + pkgs.pyright + pkgs.git + ]; shellHook = '' export PYTHONNOUSERSITE=1 export JUPYTER_CONFIG_DIR="''${XDG_CONFIG_HOME:-$HOME/.config}/jupyter" diff --git a/shells/python-uv.nix b/shells/python-uv.nix index d8021dd..42780a9 100644 --- a/shells/python-uv.nix +++ b/shells/python-uv.nix @@ -1,8 +1,17 @@ -{ pkgs, python ? pkgs.python312, ... }: +{ + pkgs, + python ? pkgs.python312, + ... +}: pkgs.mkShell { name = "python-uv"; - packages = [ python pkgs.uv pkgs.ruff pkgs.pyright ]; + packages = [ + python + pkgs.uv + pkgs.ruff + pkgs.pyright + ]; shellHook = '' export UV_PYTHON="${python}/bin/python3" export UV_LINK_MODE=copy diff --git a/shells/rust.nix b/shells/rust.nix index c8c015c..b42f7eb 100644 --- a/shells/rust.nix +++ b/shells/rust.nix @@ -2,7 +2,13 @@ pkgs.mkShell { name = "rust"; - packages = with pkgs; [ cargo rustc rust-analyzer rustfmt clippy ]; + packages = with pkgs; [ + cargo + rustc + rust-analyzer + rustfmt + clippy + ]; shellHook = '' mkdir -p "$PWD/.cache/cargo" export CARGO_HOME="$PWD/.cache/cargo"