1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-30 13:05:15 +03:00
nixpkgs/nixos/modules/services/networking/scion/scion-dispatcher.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

79 lines
2.2 KiB
Nix

{
config,
lib,
pkgs,
...
}:
with lib;
let
globalCfg = config.services.scion;
cfg = config.services.scion.scion-dispatcher;
toml = pkgs.formats.toml { };
defaultConfig = {
dispatcher = {
id = "dispatcher";
socket_file_mode = "0770";
application_socket = "/dev/shm/dispatcher/default.sock";
};
log.console = {
level = "info";
};
};
configFile = toml.generate "scion-dispatcher.toml" (recursiveUpdate defaultConfig cfg.settings);
in
{
options.services.scion.scion-dispatcher = {
enable = mkEnableOption "the scion-dispatcher service";
settings = mkOption {
default = { };
type = toml.type;
example = literalExpression ''
{
dispatcher = {
id = "dispatcher";
socket_file_mode = "0770";
application_socket = "/dev/shm/dispatcher/default.sock";
};
log.console = {
level = "info";
};
}
'';
description = ''
scion-dispatcher configuration. Refer to
<https://docs.scion.org/en/latest/manuals/common.html>
for details on supported values.
'';
};
};
config = mkIf cfg.enable {
# Needed for group ownership of the dispatcher socket
users.groups.scion = { };
# scion programs hardcode path to dispatcher in /run/shm, and is not
# configurable at runtime upstream plans to obsolete the dispatcher in
# favor of an SCMP daemon, at which point this can be removed.
system.activationScripts.scion-dispatcher = ''
ln -sf /dev/shm /run/shm
'';
systemd.services.scion-dispatcher = {
description = "SCION Dispatcher";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
Group = "scion";
DynamicUser = true;
BindPaths = [ "/dev/shm:/run/shm" ];
ExecStartPre = "${pkgs.coreutils}/bin/rm -rf /run/shm/dispatcher";
ExecStart = "${globalCfg.package}/bin/scion-dispatcher --config ${configFile}";
Restart = "on-failure";
${if globalCfg.stateless then "RuntimeDirectory" else "StateDirectory"} = "scion-dispatcher";
};
};
};
}