diff --git a/.github/workflows/lua.yml b/.github/workflows/lua.yml index a235ca681..e51bc5784 100644 --- a/.github/workflows/lua.yml +++ b/.github/workflows/lua.yml @@ -13,13 +13,11 @@ jobs: lua-neovim: runs-on: ubuntu-latest timeout-minutes: 300 + env: + DEVENV_ROOT: ${{ github.workspace }} steps: - name: Checkout uses: actions/checkout@v6 - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@v1.3.1 - with: - tool-cache: false - name: Install Nix uses: cachix/install-nix-action@v31 with: @@ -29,6 +27,8 @@ jobs: lua-hammerspoon: runs-on: macos-latest timeout-minutes: 300 + env: + DEVENV_ROOT: ${{ github.workspace }} steps: - name: Checkout uses: actions/checkout@v6 diff --git a/.gitignore b/.gitignore index 31e02e131..d2e7f5d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,9 @@ # AI .claude +.devenv.nix # Nix +.devenv *.hm-backup # General diff --git a/Makefile b/Makefile index 964d875df..b49e8e9ad 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ ##@ Variables -# Include rules from submodule +# Include rules from submodule but keep the local help target authoritative. +RULES_SKIP_HELP := 1 -include rules/Makefile # Detect architecture and OS @@ -25,6 +26,11 @@ DOCKER_IMAGE_TAGGED := $(DOCKER_IMAGE_NAME_BASE):$(GIT_COMMIT_SHA) # Nix executable path NIX_EXEC := $(shell which nix) +# Common cache settings (apply even before switch) +NIX_SUBSTITUTERS := https://cache.nixos.org https://devenv.cachix.org https://cachix.cachix.org +NIX_TRUSTED_KEYS := cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM= +NIX_CACHIX_CONF := /etc/nix/cachix.conf + # Nix configuration system NIX_SYSTEM := $(shell if [ "$(OS)" = "Darwin" ] && [ "$(ARCH)" = "arm64" ]; then \ echo "aarch64-darwin"; \ @@ -62,7 +68,8 @@ NIX_USERNAME := $(shell \ echo "$(shell whoami)"; \ fi) NIX_ENV := $(shell . ~/.nix-profile/etc/profile.d/nix.sh 2>/dev/null || echo "not_found") -NIX_FLAGS := --extra-experimental-features 'flakes nix-command' +NIX_FLAGS := --extra-experimental-features 'flakes nix-command' --no-pure-eval --impure +NIX_FLAGS += --option substituters "$(NIX_SUBSTITUTERS)" --option trusted-public-keys "$(NIX_TRUSTED_KEYS)" # Machine detection for automatic host mapping DETECTED_HOST := $(shell \ @@ -139,7 +146,7 @@ dev: nix-develop ## Enter the Nix dev shell (alias for nix-develop). ##@ Nix Setup .PHONY: nix-setup -nix-setup: nix-install nix-check nix-connect ## Set up Nix environment (install, check, connect). +nix-setup: nix-install nix-check nix-connect ## Set up Nix environment (install, check, connect, trust caches). .PHONY: nix-connect nix-connect: ## Ensure Nix daemon is running. @@ -181,7 +188,13 @@ nix-check: ## Verify Nix environment setup. .PHONY: nix-develop nix-develop: ## Enter the Nix development shell. - $(NIX_ALLOW_UNFREE) $(NIX_EXEC) develop $(NIX_FLAGS) + DEVENV_ROOT=$(CURDIR) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) develop $(NIX_FLAGS) + +.PHONY: devenv-cli +devenv-cli: ## Build the packaged devenv CLI binary. + @echo "📦 Building packaged devenv CLI..." + @$(NIX_ALLOW_UNFREE) $(NIX_EXEC) build .#devenv-cli $(NIX_FLAGS) --show-trace + @echo "✅ devenv CLI available in ./result/bin/devenv" .PHONY: nix-install nix-install: ## Install Nix if not already installed. @@ -549,4 +562,3 @@ git-submodule-sync: ## Sync and update git submodules. @git submodule sync @git submodule update --init --recursive @echo "✅ Submodules synced and updated" - diff --git a/home-manager/modules/codex/config.toml b/config/codex/config.toml similarity index 95% rename from home-manager/modules/codex/config.toml rename to config/codex/config.toml index ff5dba45c..a5a216020 100644 --- a/home-manager/modules/codex/config.toml +++ b/config/codex/config.toml @@ -5,8 +5,8 @@ notify = [ "notify", ] -[tools] -web_search = true +[features] +web_search_request = true [model_providers.lmstudio] name = "LMStudio" diff --git a/home-manager/modules/codex/default.nix b/config/codex/default.nix similarity index 100% rename from home-manager/modules/codex/default.nix rename to config/codex/default.nix diff --git a/home-manager/modules/crush/crush.json b/config/crush/crush.json similarity index 100% rename from home-manager/modules/crush/crush.json rename to config/crush/crush.json diff --git a/home-manager/modules/crush/default.nix b/config/crush/default.nix similarity index 100% rename from home-manager/modules/crush/default.nix rename to config/crush/default.nix diff --git a/config/default.nix b/config/default.nix index 01f73d9cb..5238bec0e 100644 --- a/config/default.nix +++ b/config/default.nix @@ -1,8 +1,13 @@ [ + ./codex + ./crush ./claude ./direnv + ./ghostty ./hammerspoon ./karabiner ./nvim + ./opencode + ./serena ./starship ] diff --git a/home-manager/modules/ghostty/config b/config/ghostty/config similarity index 100% rename from home-manager/modules/ghostty/config rename to config/ghostty/config diff --git a/home-manager/modules/ghostty/default.nix b/config/ghostty/default.nix similarity index 100% rename from home-manager/modules/ghostty/default.nix rename to config/ghostty/default.nix diff --git a/home-manager/modules/opencode/default.nix b/config/opencode/default.nix similarity index 100% rename from home-manager/modules/opencode/default.nix rename to config/opencode/default.nix diff --git a/home-manager/modules/opencode/opencode.jsonc b/config/opencode/opencode.jsonc similarity index 100% rename from home-manager/modules/opencode/opencode.jsonc rename to config/opencode/opencode.jsonc diff --git a/home-manager/modules/serena/default.nix b/config/serena/default.nix similarity index 100% rename from home-manager/modules/serena/default.nix rename to config/serena/default.nix diff --git a/home-manager/modules/serena/serena_config.yml b/config/serena/serena_config.yml similarity index 100% rename from home-manager/modules/serena/serena_config.yml rename to config/serena/serena_config.yml diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 000000000..2dc95190e --- /dev/null +++ b/devenv.nix @@ -0,0 +1,15 @@ +{ pkgs }: + +{ + packages = [ + pkgs.nodejs + pkgs.bun + pkgs.neovim + ]; + + containers = pkgs.lib.mkIf (!pkgs.stdenv.hostPlatform.isLinux) (pkgs.lib.mkForce { }); + + enterShell = '' + echo "Dev shell ready: Node.js, bun, and Neovim available." + ''; +} diff --git a/flake.lock b/flake.lock index 552d1fe03..e66f00bbf 100644 --- a/flake.lock +++ b/flake.lock @@ -25,6 +25,39 @@ "type": "github" } }, + "cachix": { + "inputs": { + "devenv": [ + "devenv" + ], + "flake-compat": [ + "devenv", + "flake-compat" + ], + "git-hooks": [ + "devenv", + "git-hooks" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1752264895, + "narHash": "sha256-1zBPE/PNAkPNUsOWFET4J0cjlvziH8DOekesDmjND+w=", + "owner": "cachix", + "repo": "cachix", + "rev": "47053aef762f452e816e44eb9a23fbc3827b241a", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "latest", + "repo": "cachix", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -47,7 +80,69 @@ "type": "github" } }, + "devenv": { + "inputs": { + "cachix": "cachix", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "git-hooks": "git-hooks", + "nix": "nix", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1764115645, + "narHash": "sha256-CL0YunWEB0muQOec0gd72bveuClMNtR5R6PiaMnIZGg=", + "owner": "cachix", + "repo": "devenv", + "rev": "9f75ca2f931ab24b92d1733bd1a4f0d441d68591", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1756770412, + "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "4524271976b625a4a605beefd893f270620fd751", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" }, @@ -65,7 +160,7 @@ "type": "github" } }, - "flake-parts_2": { + "flake-parts_3": { "inputs": { "nixpkgs-lib": [ "neovim-nightly-overlay", @@ -86,7 +181,7 @@ "type": "github" } }, - "flake-parts_3": { + "flake-parts_4": { "inputs": { "nixpkgs-lib": [ "nur", @@ -107,6 +202,54 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1758108966, + "narHash": "sha256-ytw7ROXaWZ7OfwHrQ9xvjpUWeGVm86pwnEd1QhzawIo=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "54df955a695a84cd47d4a43e08e1feaf90b1fd9b", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "devenv", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -114,11 +257,11 @@ ] }, "locked": { - "lastModified": 1764075860, - "narHash": "sha256-KYEIHCBBw+/lwKsJNRNoUxBB4ZY2LK0G0T8f+0i65q0=", + "lastModified": 1764135300, + "narHash": "sha256-5xOuutXM7UPTUcn3uDAD8UlPQsXmqPrX81cXoDOAGcA=", "owner": "nix-community", "repo": "home-manager", - "rev": "295d90e22d557ccc3049dc92460b82f372cd3892", + "rev": "f4cb25928fafa9ae68660fe71f730fc820a59028", "type": "github" }, "original": { @@ -127,9 +270,24 @@ "type": "github" } }, + "mk-shell-bin": { + "locked": { + "lastModified": 1677004959, + "narHash": "sha256-/uEkr1UkJrh11vD02aqufCxtbF5YnhRTIKlx5kyvf+I=", + "owner": "rrbutani", + "repo": "nix-mk-shell-bin", + "rev": "ff5d8bd4d68a347be5042e2f16caee391cd75887", + "type": "github" + }, + "original": { + "owner": "rrbutani", + "repo": "nix-mk-shell-bin", + "type": "github" + } + }, "neovim-nightly-overlay": { "inputs": { - "flake-parts": "flake-parts_2", + "flake-parts": "flake-parts_3", "neovim-src": "neovim-src", "nixpkgs": [ "nixpkgs" @@ -165,6 +323,46 @@ "type": "github" } }, + "nix": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "flake-parts": [ + "devenv", + "flake-parts" + ], + "git-hooks-nix": [ + "devenv", + "git-hooks" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-23-11": [ + "devenv" + ], + "nixpkgs-regression": [ + "devenv" + ] + }, + "locked": { + "lastModified": 1761648602, + "narHash": "sha256-H97KSB/luq/aGobKRuHahOvT1r7C03BgB6D5HBZsbN8=", + "owner": "cachix", + "repo": "nix", + "rev": "3e5644da6830ef65f0a2f7ec22830c46285bfff6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "devenv-2.30.6", + "repo": "nix", + "type": "github" + } + }, "nix-darwin": { "inputs": { "nixpkgs": [ @@ -185,6 +383,26 @@ "type": "github" } }, + "nix2container": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1761716996, + "narHash": "sha256-vdOuy2pid2/DasUgb08lDOswdPJkN5qjXfBYItVy/R4=", + "owner": "nlewo", + "repo": "nix2container", + "rev": "e5496ab66e9de9e3f67dc06f692dfbc471b6316e", + "type": "github" + }, + "original": { + "owner": "nlewo", + "repo": "nix2container", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1763934636, @@ -218,17 +436,17 @@ }, "nur": { "inputs": { - "flake-parts": "flake-parts_3", + "flake-parts": "flake-parts_4", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1764123065, - "narHash": "sha256-CgN6wQxiTtZiIq+SlFLa9pB1ps0tFwtp1NIDE7zUsQo=", + "lastModified": 1764136035, + "narHash": "sha256-SHpjsENYdUTjEOX3q8QBXYTtZrtKWgt/ZCsZH9gUL7Y=", "owner": "nix-community", "repo": "NUR", - "rev": "03295536ac80064c58abb3d86864a1d85e28040f", + "rev": "497fb115d451b14a9eac11337382d63d974e1bfe", "type": "github" }, "original": { @@ -240,10 +458,13 @@ "root": { "inputs": { "agenix": "agenix", - "flake-parts": "flake-parts", + "devenv": "devenv", + "flake-parts": "flake-parts_2", "home-manager": "home-manager", + "mk-shell-bin": "mk-shell-bin", "neovim-nightly-overlay": "neovim-nightly-overlay", "nix-darwin": "nix-darwin", + "nix2container": "nix2container", "nixpkgs": "nixpkgs", "nur": "nur", "treefmt-nix": "treefmt-nix" diff --git a/flake.nix b/flake.nix index 82ad56872..a3763d60f 100644 --- a/flake.nix +++ b/flake.nix @@ -33,12 +33,24 @@ url = "github:nix-community/neovim-nightly-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; + devenv = { + url = "github:cachix/devenv"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + mk-shell-bin = { + url = "github:rrbutani/nix-mk-shell-bin"; + }; + nix2container = { + url = "github:nlewo/nix2container"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { flake-parts, treefmt-nix, + devenv, ... }@inputs: @@ -49,7 +61,10 @@ "x86_64-linux" ]; - imports = [ treefmt-nix.flakeModule ]; + imports = [ + treefmt-nix.flakeModule + devenv.flakeModule + ]; flake = let @@ -118,19 +133,36 @@ }; perSystem = - { system, ... }: + { + config, + system, + ... + }: let - overlays = import ./overlays { inherit inputs; }; - nixpkgsConfig = import ./lib/nixpkgs-config.nix { - nixpkgsLib = inputs.nixpkgs.lib; - }; - devPkgs = import inputs.nixpkgs { - inherit system overlays; - config = nixpkgsConfig; + devenvRoot = + let + envRoot = builtins.getEnv "DEVENV_ROOT"; + in + if envRoot != "" then envRoot else builtins.toString ./.; + pkgs = import inputs.nixpkgs { + inherit system; + config = import ./lib/nixpkgs-config.nix { + nixpkgsLib = inputs.nixpkgs.lib; + }; + overlays = (import ./overlays) { inherit inputs; }; }; in { - _module.args.pkgs = devPkgs; + # Force this attribute so devenv's deprecated helper packages don't surface during flake checks. + packages = inputs.nixpkgs.lib.mkForce { + # Use nixpkgs-provided binary to avoid rebuilding cachi. + devenv-cli = pkgs.devenv; + }; + + devenv.shells.default = (import ./devenv.nix) { inherit pkgs; } // { + devenv.root = devenvRoot; + }; + treefmt = { projectRootFile = "flake.nix"; programs = { @@ -143,17 +175,6 @@ yamlfmt.enable = true; }; }; - - devShells.default = devPkgs.mkShell { - packages = [ - devPkgs.nodejs - devPkgs.bun - devPkgs.neovim - ]; - shellHook = '' - echo "Dev shell ready: Node.js, bun, and Neovim available." - ''; - }; }; }; } diff --git a/home-manager/modules/default.nix b/home-manager/modules/default.nix index 39590c1a5..256b443a4 100644 --- a/home-manager/modules/default.nix +++ b/home-manager/modules/default.nix @@ -1,10 +1,4 @@ [ - ./codex - ./crush - ./dust - ./ghostty ./npm-globals - ./opencode - ./serena ./yek ] diff --git a/home-manager/modules/dust/default.nix b/home-manager/modules/dust/default.nix deleted file mode 100644 index 927ec0e3f..000000000 --- a/home-manager/modules/dust/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: -let - cfg = config.programs.dust; -in -with lib; -{ - options.programs.dust = { - enable = mkEnableOption "A more intuitive version of du in rust"; - package = mkPackageOption pkgs "du-dust" { }; - config = mkOption { - type = types.lines; - default = ""; - }; - }; - - config = mkIf cfg.enable { - home.packages = [ cfg.package ]; - xdg.configFile."dust/config.toml".text = builtins.toString cfg.config; - }; -} diff --git a/nix-darwin/config/homebrew.nix b/nix-darwin/config/homebrew.nix index 7a6238585..2cbc4ea12 100644 --- a/nix-darwin/config/homebrew.nix +++ b/nix-darwin/config/homebrew.nix @@ -19,7 +19,6 @@ "bun" "claude-squad" "cmake" - "codex" "colima" "coreutils" "ffmpeg" @@ -50,6 +49,7 @@ "block-goose" "chatgpt" "claude" + "codex" "claude-code" "conductor" "copilot-money" diff --git a/nix-darwin/config/nix.nix b/nix-darwin/config/nix.nix index 802454173..d117a8f05 100644 --- a/nix-darwin/config/nix.nix +++ b/nix-darwin/config/nix.nix @@ -4,6 +4,20 @@ settings = { experimental-features = "nix-command flakes"; max-jobs = 8; + substituters = [ + "https://cache.nixos.org" + "https://devenv.cachix.org" + "https://cachix.cachix.org" + ]; + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=" + "cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM=" + ]; + trusted-users = [ + "root" + "shunkakinoki" + ]; }; }; diff --git a/rules b/rules index aebdd269f..2c10fe126 160000 --- a/rules +++ b/rules @@ -1 +1 @@ -Subproject commit aebdd269f4a75ed8d7018b7f6464e5e72fc5a0d4 +Subproject commit 2c10fe126efa826199fecc73342288b39e5094c6