1 { config, pkgs, lib, ... }:
4 inherit (lib) mkOption types;
5 cfg = config.services.nar-serve;
9 maintainers = with lib.maintainers; [ rizary zimbatm ];
12 services.nar-serve = {
13 enable = lib.mkEnableOption "serving NAR file contents via HTTP";
15 package = lib.mkPackageOption pkgs "nar-serve" { };
21 Port number where nar-serve will listen on.
27 default = "https://cache.nixos.org/";
29 Binary cache URL to connect to.
31 The URL format is compatible with the nix remote url style, such as:
32 - http://, https:// for binary caches via HTTP or HTTPS
33 - s3:// for binary caches stored in Amazon S3
34 - gs:// for binary caches stored in Google Cloud Storage
42 When set, enables the feature of serving <nar-hash>.<domain>
43 on top of <domain>/nix/store/<nar-hash>-<pname>.
45 Useful to preview static websites where paths are absolute.
51 config = lib.mkIf cfg.enable {
52 systemd.services.nar-serve = {
53 description = "NAR server";
54 after = [ "network.target" ];
55 wantedBy = [ "multi-user.target" ];
57 environment.PORT = toString cfg.port;
58 environment.NAR_CACHE_URL = cfg.cacheURL;
63 ExecStart = lib.getExe cfg.package;