Skip to content

support DEVBOX_CACHE mirror for nixpkgs tarballs#2780

Open
oqxo wants to merge 1 commit intojetify-com:mainfrom
oqxo:fix-nixpkgs-info
Open

support DEVBOX_CACHE mirror for nixpkgs tarballs#2780
oqxo wants to merge 1 commit intojetify-com:mainfrom
oqxo:fix-nixpkgs-info

Conversation

@oqxo
Copy link

@oqxo oqxo commented Feb 8, 2026

support DEVBOX_CACHE mirror for nixpkgs tarballs

Problem

Devbox currently fetches nixpkgs tarballs directly from GitHub.
In environments where GitHub is blocked, devbox shell fails to fetch required tarballs, breaking reproducibility.

Solution

  • Added support for the DEVBOX_CACHE environment variable in getNixpkgsInfo.
  • When DEVBOX_CACHE is set, both URL and TarURL point to the local/internal mirror instead of GitHub.
  • Added debug logging to show which URLs are being used.
  • Fully backward compatible: if DEVBOX_CACHE is not set, Devbox falls back to GitHub as before.

Testing

1. Create local mirror directory hierarchy:
   ```bash
   mkdir -p ~/nix-mirror-test/nixos/nixpkgs/archive
  1. Place the nixpkgs tarballs in the archive folder:

    ~/nix-mirror-test/nixos/nixpkgs/archive/871b9fd269ff6246794583ce4ee1031e1da71895.tar.gz
    
  2. Set DEVBOX_CACHE to point to the mirror:

    export DEVBOX_CACHE="http://localhost:8000"
  3. Start a Python HTTP server to serve the mirror:

    cd ~/nix-mirror-test
    python3 -m http.server 8000
  4. Create devbox.json for testing:

    {
      "packages": [
        "github:NixOS/nixpkgs/871b9fd269ff6246794583ce4ee1031e1da71895#zulu21"
      ],
      "nixpkgs": {
        "commit": "871b9fd269ff6246794583ce4ee1031e1da71895"
      }
    }
  5. Run Devbox shell:

    devbox shell
  6. Verify that the tarball is fetched from the local mirror.
    Example server logs:

    127.0.0.1 - - [08/Feb/2026 01:55:18] "HEAD /nixos/nixpkgs/archive/871b9fd269ff6246794583ce4ee1031e1da71895.tar.gz HTTP/1.1" 200 -
    127.0.0.1 - - [08/Feb/2026 01:55:18] "GET /nixos/nixpkgs/archive/871b9fd269ff6246794583ce4ee1031e1da71895.tar.gz HTTP/1.1" 200 -
    
  7. Debug logs in Devbox confirm that both URL and TarURL point to the local mirror when DEVBOX_CACHE is set.

Signed-off-by: oqxo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant