Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Name

nix serve - serve a Nix store as a HTTP binary cache

Synopsis

nix serve [option...]

Examples

  • Serve the local Nix store on the default port (8080), listening on localhost only:

    # nix serve
    Listening on http://127.0.0.1:8080/
    
  • Serve the local store on all interfaces, on port 9000:

    # nix serve --listen-address 0.0.0.0 --port 9000
    

    On another machine, you can then use this server as a substituter:

    # nix copy --from http://other-host:8080 /nix/store/...-hello-2.12.1
    
  • Serve a chroot store as a binary cache:

    # nix serve --store /tmp/my-store
    

Description

nix serve runs an HTTP server that exposes a Nix store as a binary cache. Clients can fetch store paths from this server by adding its URL to their list of substituters.

NARs are served uncompressed.

Note

nix serve only handles GET and HEAD requests; it cannot be used to upload paths to the store. It also does not implement authentication or TLS — if you want to expose it to the public internet, run it behind a reverse proxy such as nginx.

To shut down the server, send it a SIGINT signal.

Options

  • --listen-address address

    IP address to listen on (default: 127.0.0.1). Use 0.0.0.0 or :: to listen on all interfaces.

  • --port / -p port

    Port to listen on (default: 8080). Use 0 to dynamically allocate a free port.

  • --port-file path

    Write the bound port number to this file.

  • --priority priority

    Priority of this cache (overrides the store's default).

  • --debug

    Set the logging verbosity level to 'debug'.

  • --log-format format

    Set the format of log output; one of raw, internal-json, bar or bar-with-logs.

  • --print-build-logs / -L

    Print full build logs on standard error.

  • --quiet

    Decrease the logging verbosity level.

  • --verbose / -v

    Increase the logging verbosity level.

Miscellaneous global options

  • --help

    Show usage information.

  • --offline

    Disable substituters and consider all previously downloaded files up-to-date.

  • --option name value

    Set the Nix configuration setting name to value (overriding nix.conf).

  • --refresh

    Consider all previously downloaded files out-of-date.

  • --version

    Show version information.

Note

See man nix.conf for overriding configuration settings with command line flags.