2013-04-22 15:50:58 +02:00
|
|
|
# NixOS module for Freenet daemon
|
2013-04-21 09:27:41 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-04-21 09:27:41 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2013-04-21 09:27:41 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.freenet;
|
|
|
|
varDir = "/var/lib/freenet";
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
### configuration
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.freenet = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.uniq types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Enable the Freenet daemon";
|
|
|
|
};
|
|
|
|
|
|
|
|
nice = mkOption {
|
|
|
|
type = types.uniq types.int;
|
|
|
|
default = 10;
|
|
|
|
description = "Set the nice level for the Freenet daemon";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
### implementation
|
|
|
|
|
|
|
|
config = 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.extraUsers.freenet = {
|
|
|
|
group = "freenet";
|
2013-04-22 15:50:58 +02:00
|
|
|
description = "Freenet daemon user";
|
2013-04-21 09:27:41 +02:00
|
|
|
home = varDir;
|
|
|
|
createHome = true;
|
2013-08-23 11:33:24 +02:00
|
|
|
uid = config.ids.uids.freenet;
|
2013-04-21 09:27:41 +02:00
|
|
|
};
|
|
|
|
|
2013-08-23 11:33:24 +02:00
|
|
|
users.extraGroups.freenet.gid = config.ids.gids.freenet;
|
2013-04-21 09:27:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|