Use Claude Code with your ChatGPT, Kimi, Cursor or Grok subscription via a local Anthropic-compatible proxy
Rust
add nix flake
Raine Virta07f01f0b5a0b
diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.ymlnew file mode 100644index 0000000..001e900--- /dev/null+++ b/.github/workflows/nix.yml@@ -0,0 +1,27 @@+name: Nix++on:+ push:+ branches: [main]+ pull_request:++permissions:+ contents: read++jobs:+ flake:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v5+ - uses: cachix/install-nix-action@v31+ - name: Build package+ run: |+ for attempt in 1 2 3 4 5; do+ if nix build --no-link --print-build-logs --option sandbox false --option max-jobs 1; then+ exit 0+ fi+ if [ "$attempt" = 5 ]; then+ exit 1+ fi+ sleep 10+ donediff --git a/flake.lock b/flake.locknew file mode 100644index 0000000..77972fb--- /dev/null+++ b/flake.lock@@ -0,0 +1,27 @@+{+ "nodes": {+ "nixpkgs": {+ "locked": {+ "lastModified": 1775710090,+ "narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=",+ "owner": "NixOS",+ "repo": "nixpkgs",+ "rev": "4c1018dae018162ec878d42fec712642d214fdfa",+ "type": "github"+ },+ "original": {+ "owner": "NixOS",+ "ref": "nixos-unstable",+ "repo": "nixpkgs",+ "type": "github"+ }+ },+ "root": {+ "inputs": {+ "nixpkgs": "nixpkgs"+ }+ }+ },+ "root": "root",+ "version": 7+}diff --git a/flake.nix b/flake.nixnew file mode 100644index 0000000..92142c3--- /dev/null+++ b/flake.nix@@ -0,0 +1,80 @@+{+ description = "Anthropic-compatible proxy for Claude Code provider backends";++ inputs = {+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";+ };++ outputs = { self, nixpkgs }:+ let+ cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);+ systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];+ forAllSystems = nixpkgs.lib.genAttrs systems;+ in+ {+ packages = forAllSystems (system:+ let+ pkgs = nixpkgs.legacyPackages.${system};+ in+ {+ default = pkgs.stdenv.mkDerivation {+ pname = cargoToml.package.name;+ version = cargoToml.package.version;++ src = ./.;++ nativeBuildInputs = with pkgs; [+ cargo+ rustc+ ];++ buildPhase = ''+ runHook preBuild+ export CARGO_HOME="$TMPDIR/cargo-home"+ cargo build --release --locked+ runHook postBuild+ '';++ installPhase = ''+ runHook preInstall+ install -Dm755 target/release/claude-code-proxy "$out/bin/claude-code-proxy"+ runHook postInstall+ '';++ meta = with pkgs.lib; {+ description = cargoToml.package.description;+ homepage = "https://github.com/raine/claude-code-proxy";+ license = licenses.mit;+ mainProgram = "claude-code-proxy";+ };+ };+ }+ );++ apps = forAllSystems (system: {+ default = {+ type = "app";+ program = "${self.packages.${system}.default}/bin/claude-code-proxy";+ };+ });++ devShells = forAllSystems (system:+ let+ pkgs = nixpkgs.legacyPackages.${system};+ in+ {+ default = pkgs.mkShell {+ buildInputs = with pkgs; [+ cargo+ rustc+ rust-analyzer+ rustfmt+ clippy+ ];++ RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";+ };+ }+ );+ };+}