nar-serve

command module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

nar-serve - Serve NAR file content directly from cache

Push your build artifacts to one place.

All the files in https://cache.nixos.org are packed in NAR files which makes them not directly accessible. This service allows to download, decompress, unpack and serve any file in the cache on the fly.

Use cases

  • Avoid publishing build artifacts to both the binary cache and another service.
  • Allows to share build results easily.
  • Inspect the content of a NAR file.

Development

Inside the provided nix shell run:

./start-dev

This will create a small local server with live reload that emulates now.sh.

Currently, the default port is 8383. You can change it by setting the PORT environment variable, or HTTP_ADDR to also change the bind address.

Usage

Store contents can be fetched via a simple HTTP GET request.

Append any store path to the hostname to fetch and unpack it on the fly. That's it.

E.g.:

NAR archives also contain information about the executable bit for each contained file. nar-serve uses a custom HTTP header named NAR-executable to indicate whether the fetched file would be executable.

Configuration

You can use the following environment variables to configure nar-serve:

Name Default value Description
PORT 8383 Port number on which nar-service listens
HTTP_ADDR :$PORT HTTP address to bind the server to. When set, takes precedence over $PORT.
NIX_CACHE_URL https://cache.nixos.org The URL of the Nix store from which NARs are fetched
DOMAIN "" When set, also serve <nar-hash>.$DOMAIN paths.

Contributing

Contributions are welcome!

Before adding any new feature it might be best to first discuss them by creating a new issue in https://github.com/numtide/nar-serve/issues .

All code is licensed under the Apache 2.0 license.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
pkg
libstore
Package libstore implements a subset of the nix libstore API
Package libstore implements a subset of the nix libstore API
nar
Package nar implements access to .nar files.
Package nar implements access to .nar files.
nar/ls
It is provided on cache.nixos.org, and more generally, written when write-nar-listing=1 is passed while copying build results into a binary cache.
It is provided on cache.nixos.org, and more generally, written when write-nar-listing=1 is passed while copying build results into a binary cache.
nixhash
Package nixhash provides methods to serialize and deserialize some of the hashes used in nix code and .narinfo files.
Package nixhash provides methods to serialize and deserialize some of the hashes used in nix code and .narinfo files.
nixpath
Package nixpath parses and renders Nix store paths.
Package nixpath parses and renders Nix store paths.
wire
Package wire provides methods to parse and produce fields used in the low-level Nix wire protocol, operating on io.Reader and io.Writer When reading fields with arbitrary lengths, a maximum number of bytes needs to be specified.
Package wire provides methods to parse and produce fields used in the low-level Nix wire protocol, operating on io.Reader and io.Writer When reading fields with arbitrary lengths, a maximum number of bytes needs to be specified.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL