depot/nixos/modules/services/networking/freenet.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

60 lines
1.2 KiB
Nix

# NixOS module for Freenet daemon
{ config, lib, pkgs, ... }:
let
cfg = config.services.freenet;
varDir = "/var/lib/freenet";
in
{
### configuration
options = {
services.freenet = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable the Freenet daemon";
};
nice = lib.mkOption {
type = lib.types.int;
default = 10;
description = "Set the nice level for the Freenet daemon";
};
};
};
### implementation
config = lib.mkIf cfg.enable {
systemd.services.freenet = {
description = "Freenet daemon";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = "${pkgs.freenet}/bin/freenet";
serviceConfig.User = "freenet";
serviceConfig.UMask = "0007";
serviceConfig.WorkingDirectory = varDir;
serviceConfig.Nice = cfg.nice;
};
users.users.freenet = {
group = "freenet";
description = "Freenet daemon user";
home = varDir;
createHome = true;
uid = config.ids.uids.freenet;
};
users.groups.freenet.gid = config.ids.gids.freenet;
};
}