Skip to content

feat: Add configurable temporary directory for NAR file downloads - #268

Merged
kalbasit merged 2 commits into
mainfrom
intermidiate_download_location
Aug 24, 2025
Merged

kalbasit merged 2 commits into
mainfrom
intermidiate_download_location

Conversation

@kalbasit

@kalbasit kalbasit commented Aug 24, 2025 •

Copy link
Copy Markdown
Owner

TL;DR

Added support for configuring the temporary directory used when downloading NAR files instead of streaming the download directly to the store.

What changed?

  • Added a new --cache-temp-path CLI flag (and corresponding CACHE_TEMP_PATH environment variable) to specify the temporary directory path
  • Default value is set to the system's temporary directory (os.TempDir())
  • Modified the NAR download process to:
    • First download the NAR file to a temporary file in the configured directory
    • Then read from this temporary file to store in the NAR store
    • Clean up the temporary file after use

How to test?

  1. Run the server with the new flag: nix-cache-info serve --cache-temp-path=/path/to/temp/dir
  2. Alternatively, set the environment variable: CACHE_TEMP_PATH=/path/to/temp/dir nix-cache-info serve
  3. Verify that NAR files are temporarily stored in the specified directory during downloads
  4. Confirm that temporary files are properly cleaned up after the download completes

Why make this change?

This change provides more control over where temporary NAR files are stored during the download process. This is particularly useful in environments where:

  • The default system temp directory has limited space
  • There are specific performance requirements for the temporary storage location
  • Security policies require temporary files to be stored in specific locations

@kalbasit
kalbasit marked this pull request as ready for review August 24, 2025 22:27
@kalbasit kalbasit changed the title store each nar in a temporary directory first feat: Add configurable temporary directory for NAR file downloads Aug 24, 2025
Comment thread pkg/cache/cache.go Resolved
@kalbasit
kalbasit merged commit 8e246d4 into main Aug 24, 2025

Copy link
Copy Markdown
Owner Author

Merge activity

@kalbasit
kalbasit deleted the intermidiate_download_location branch August 24, 2025 22:44
kalbasit added a commit that referenced this pull request Aug 25, 2025
The flag was added by #268 but I forgot to document it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant