2020-11-06 00:33:48 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.nar-serve;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
meta = {
|
2024-01-02 11:29:13 +00:00
|
|
|
maintainers = [ maintainers.rizary maintainers.zimbatm ];
|
2020-11-06 00:33:48 +00:00
|
|
|
};
|
|
|
|
options = {
|
|
|
|
services.nar-serve = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "serving NAR file contents via HTTP";
|
2020-11-06 00:33:48 +00:00
|
|
|
|
|
|
|
port = mkOption {
|
2021-07-14 22:03:04 +00:00
|
|
|
type = types.port;
|
2020-11-06 00:33:48 +00:00
|
|
|
default = 8383;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-11-06 00:33:48 +00:00
|
|
|
Port number where nar-serve will listen on.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
cacheURL = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "https://cache.nixos.org/";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-11-06 00:33:48 +00:00
|
|
|
Binary cache URL to connect to.
|
|
|
|
|
|
|
|
The URL format is compatible with the nix remote url style, such as:
|
|
|
|
- http://, https:// for binary caches via HTTP or HTTPS
|
|
|
|
- s3:// for binary caches stored in Amazon S3
|
|
|
|
- gs:// for binary caches stored in Google Cloud Storage
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.nar-serve = {
|
|
|
|
description = "NAR server";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
environment.PORT = toString cfg.port;
|
|
|
|
environment.NAR_CACHE_URL = cfg.cacheURL;
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Restart = "always";
|
|
|
|
RestartSec = "5s";
|
|
|
|
ExecStart = "${pkgs.nar-serve}/bin/nar-serve";
|
|
|
|
DynamicUser = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|