diff --git a/default-home.nix b/default-home.nix index ea1e220..707ccb8 100644 --- a/default-home.nix +++ b/default-home.nix @@ -124,6 +124,7 @@ in inputs.claude-code.packages.${system}.claude-code unstable.codex unstable.opencode + unstable.hunk # Python dev tools pyright diff --git a/flake.nix b/flake.nix index d3dd1c9..fef274a 100644 --- a/flake.nix +++ b/flake.nix @@ -88,6 +88,8 @@ # Use the neovim overlay for all hosts (import ./overlays/neovim.nix) (import ./overlays/codex.nix) + (import ./overlays/opencode.nix) + (import ./overlays/hunk.nix) ]; config.allowUnfree = true; }; @@ -206,6 +208,8 @@ overlays = [ (import ./overlays/neovim.nix) (import ./overlays/codex.nix) + (import ./overlays/opencode.nix) + (import ./overlays/hunk.nix) ]; }; }; @@ -223,6 +227,8 @@ overlays = [ (import ./overlays/neovim.nix) (import ./overlays/codex.nix) + (import ./overlays/opencode.nix) + (import ./overlays/hunk.nix) ]; }; in diff --git a/host-specific/aleister-noah.nix b/host-specific/aleister-noah.nix index d45394f..d841f2c 100644 --- a/host-specific/aleister-noah.nix +++ b/host-specific/aleister-noah.nix @@ -123,9 +123,10 @@ minica mkcert step-cli - opencode + unstable.opencode claude-code unstable.codex + unstable.hunk # Libraries because MacOS is kinda stupid ncurses diff --git a/overlays/hunk.nix b/overlays/hunk.nix new file mode 100644 index 0000000..ed67ac3 --- /dev/null +++ b/overlays/hunk.nix @@ -0,0 +1,78 @@ +final: prev: + +let + version = "0.10.0"; + platformPackage = + { + "aarch64-darwin" = { + name = "hunkdiff-darwin-arm64"; + hash = "sha256-wwnjeFPt2WrLfRVIdM9U0hbk5Ntf3v7GvU7z/f1ZDyY="; + }; + "x86_64-darwin" = { + name = "hunkdiff-darwin-x64"; + hash = "sha256-LPGnO8Pz/sFs7xyYa9sFEGBJZ2VovqmuFXhz/J/fKI8="; + }; + "aarch64-linux" = { + name = "hunkdiff-linux-arm64"; + hash = "sha256-+1/uVxcmkyqYSTDz9gk+aZOgTKUzcypgichFfMwnGF4="; + }; + "x86_64-linux" = { + name = "hunkdiff-linux-x64"; + hash = "sha256-ICkeeCq8X7czMDtVBH3P5lPDhSrgueZMeQb0QwTcfSA="; + }; + } + .${prev.stdenv.hostPlatform.system} + or (throw "hunkdiff is not packaged for ${prev.stdenv.hostPlatform.system}"); + hunkdiff = prev.fetchurl { + url = "https://registry.npmjs.org/hunkdiff/-/hunkdiff-${version}.tgz"; + hash = "sha256-wOp9cLyfE6PM+KLhxp8v1NOuGQ4Y+RygHIGdBdqTthY="; + }; + prebuilt = prev.fetchurl { + url = "https://registry.npmjs.org/${platformPackage.name}/-/${platformPackage.name}-${version}.tgz"; + inherit (platformPackage) hash; + }; +in +{ + hunk = prev.stdenv.mkDerivation { + pname = "hunkdiff"; + inherit version; + + dontUnpack = true; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/lib/node_modules/hunkdiff" "$out/lib/node_modules/${platformPackage.name}" + tar -xzf ${hunkdiff} -C "$out/lib/node_modules/hunkdiff" --strip-components=1 + tar -xzf ${prebuilt} -C "$out/lib/node_modules/${platformPackage.name}" --strip-components=1 + + patchShebangs "$out/lib/node_modules/hunkdiff/bin/hunk.cjs" + chmod +x "$out/lib/node_modules/hunkdiff/bin/hunk.cjs" + chmod +x "$out/lib/node_modules/${platformPackage.name}/bin/hunk" + + mkdir -p "$out/bin" + ln -s "$out/lib/node_modules/hunkdiff/bin/hunk.cjs" "$out/bin/hunk" + + runHook postInstall + ''; + + nativeBuildInputs = [ + prev.nodejs + ]; + + meta = { + description = "Review-first terminal diff viewer for agent-authored changesets"; + homepage = "https://github.com/modem-dev/hunk"; + license = prev.lib.licenses.mit; + mainProgram = "hunk"; + platforms = [ + "aarch64-darwin" + "x86_64-darwin" + "aarch64-linux" + "x86_64-linux" + ]; + }; + }; + + hunkdiff = final.hunk; +} diff --git a/overlays/opencode.nix b/overlays/opencode.nix new file mode 100644 index 0000000..bf34007 --- /dev/null +++ b/overlays/opencode.nix @@ -0,0 +1,16 @@ +final: prev: { + opencode = prev.opencode.overrideAttrs ( + finalAttrs: prevAttrs: { + version = "1.14.48"; + src = prev.fetchFromGitHub { + owner = "anomalyco"; + repo = "opencode"; + tag = "v${finalAttrs.version}"; + hash = "sha256-gyybqabTco+5ZeWv4lCX8t/R9Jm3tYsA8wVvkrxkEYQ="; + }; + node_modules = prevAttrs.node_modules.overrideAttrs { + outputHash = "sha256-94uXrhyGqW016U6LPE/xIfZGoDOzyUto5DyQrYYePds="; + }; + } + ); +}