2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
91 lines
2.4 KiB
Nix
91 lines
2.4 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.nix-serve;
|
|
in
|
|
{
|
|
options = {
|
|
services.nix-serve = {
|
|
enable = mkEnableOption "nix-serve, the standalone Nix binary cache server";
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 5000;
|
|
description = lib.mdDoc ''
|
|
Port number where nix-serve will listen on.
|
|
'';
|
|
};
|
|
|
|
bindAddress = mkOption {
|
|
type = types.str;
|
|
default = "0.0.0.0";
|
|
description = lib.mdDoc ''
|
|
IP address where nix-serve will bind its listening socket.
|
|
'';
|
|
};
|
|
|
|
openFirewall = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc "Open ports in the firewall for nix-serve.";
|
|
};
|
|
|
|
secretKeyFile = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = ''
|
|
The path to the file used for signing derivation data.
|
|
Generate with:
|
|
|
|
```
|
|
nix-store --generate-binary-cache-key key-name secret-key-file public-key-file
|
|
```
|
|
|
|
For more details see <citerefentry><refentrytitle>nix-store</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
|
|
'';
|
|
};
|
|
|
|
extraParams = mkOption {
|
|
type = types.separatedString " ";
|
|
default = "";
|
|
description = lib.mdDoc ''
|
|
Extra command line parameters for nix-serve.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.nix-serve = {
|
|
description = "nix-serve binary cache server";
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [ config.nix.package.out pkgs.bzip2.bin ];
|
|
environment.NIX_REMOTE = "daemon";
|
|
|
|
script = ''
|
|
${lib.optionalString (cfg.secretKeyFile != null) ''
|
|
export NIX_SECRET_KEY_FILE="$CREDENTIALS_DIRECTORY/NIX_SECRET_KEY_FILE"
|
|
''}
|
|
exec ${pkgs.nix-serve}/bin/nix-serve --listen ${cfg.bindAddress}:${toString cfg.port} ${cfg.extraParams}
|
|
'';
|
|
|
|
serviceConfig = {
|
|
Restart = "always";
|
|
RestartSec = "5s";
|
|
User = "nix-serve";
|
|
Group = "nix-serve";
|
|
DynamicUser = true;
|
|
LoadCredential = lib.optionalString (cfg.secretKeyFile != null)
|
|
"NIX_SECRET_KEY_FILE:${cfg.secretKeyFile}";
|
|
};
|
|
};
|
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
allowedTCPPorts = [ cfg.port ];
|
|
};
|
|
};
|
|
}
|