1 { config, pkgs, lib, ... }:
5 cfg = config.services.nar-serve;
9 maintainers = [ maintainers.rizary ];
12 services.nar-serve = {
13 enable = mkEnableOption (lib.mdDoc "Serve NAR file contents via HTTP");
18 description = lib.mdDoc ''
19 Port number where nar-serve will listen on.
25 default = "https://cache.nixos.org/";
26 description = lib.mdDoc ''
27 Binary cache URL to connect to.
29 The URL format is compatible with the nix remote url style, such as:
30 - http://, https:// for binary caches via HTTP or HTTPS
31 - s3:// for binary caches stored in Amazon S3
32 - gs:// for binary caches stored in Google Cloud Storage
38 config = mkIf cfg.enable {
39 systemd.services.nar-serve = {
40 description = "NAR server";
41 after = [ "network.target" ];
42 wantedBy = [ "multi-user.target" ];
44 environment.PORT = toString cfg.port;
45 environment.NAR_CACHE_URL = cfg.cacheURL;
50 ExecStart = "${pkgs.nar-serve}/bin/nar-serve";