
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase
).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
107 lines
3.0 KiB
Nix
107 lines
3.0 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.gonic;
|
|
settingsFormat = pkgs.formats.keyValue {
|
|
mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
|
|
listsAsDuplicateKeys = true;
|
|
};
|
|
in
|
|
{
|
|
options = {
|
|
services.gonic = {
|
|
|
|
enable = lib.mkEnableOption "Gonic music server";
|
|
|
|
settings = lib.mkOption rec {
|
|
type = settingsFormat.type;
|
|
apply = lib.recursiveUpdate default;
|
|
default = {
|
|
listen-addr = "127.0.0.1:4747";
|
|
cache-path = "/var/cache/gonic";
|
|
tls-cert = null;
|
|
tls-key = null;
|
|
};
|
|
example = {
|
|
music-path = [ "/mnt/music" ];
|
|
podcast-path = "/mnt/podcasts";
|
|
};
|
|
description = ''
|
|
Configuration for Gonic, see <https://github.com/sentriz/gonic#configuration-options> for supported values.
|
|
'';
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.gonic = {
|
|
description = "Gonic Media Server";
|
|
after = [ "network.target" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig = {
|
|
ExecStart =
|
|
let
|
|
# these values are null by default but should not appear in the final config
|
|
filteredSettings = lib.filterAttrs (
|
|
n: v: !((n == "tls-cert" || n == "tls-key") && v == null)
|
|
) cfg.settings;
|
|
in
|
|
"${pkgs.gonic}/bin/gonic -config-path ${settingsFormat.generate "gonic" filteredSettings}";
|
|
DynamicUser = true;
|
|
StateDirectory = "gonic";
|
|
CacheDirectory = "gonic";
|
|
WorkingDirectory = "/var/lib/gonic";
|
|
RuntimeDirectory = "gonic";
|
|
RootDirectory = "/run/gonic";
|
|
ReadWritePaths = "";
|
|
BindPaths = [
|
|
cfg.settings.playlists-path
|
|
cfg.settings.podcast-path
|
|
];
|
|
BindReadOnlyPaths =
|
|
[
|
|
# gonic can access scrobbling services
|
|
"-/etc/resolv.conf"
|
|
"${config.security.pki.caBundle}:/etc/ssl/certs/ca-certificates.crt"
|
|
builtins.storeDir
|
|
]
|
|
++ cfg.settings.music-path
|
|
++ lib.optional (cfg.settings.tls-cert != null) cfg.settings.tls-cert
|
|
++ lib.optional (cfg.settings.tls-key != null) cfg.settings.tls-key;
|
|
CapabilityBoundingSet = "";
|
|
RestrictAddressFamilies = [
|
|
"AF_UNIX"
|
|
"AF_INET"
|
|
"AF_INET6"
|
|
];
|
|
RestrictNamespaces = true;
|
|
PrivateDevices = true;
|
|
PrivateUsers = true;
|
|
ProtectClock = true;
|
|
ProtectControlGroups = true;
|
|
ProtectHome = true;
|
|
ProtectKernelLogs = true;
|
|
ProtectKernelModules = true;
|
|
ProtectKernelTunables = true;
|
|
SystemCallArchitectures = "native";
|
|
SystemCallFilter = [
|
|
"@system-service"
|
|
"~@privileged"
|
|
];
|
|
RestrictRealtime = true;
|
|
LockPersonality = true;
|
|
MemoryDenyWriteExecute = true;
|
|
UMask = "0066";
|
|
ProtectHostname = true;
|
|
};
|
|
};
|
|
};
|
|
|
|
meta.maintainers = [ lib.maintainers.autrimpo ];
|
|
}
|