2015-09-08 07:17:21 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.mathics;
|
|
|
|
|
|
|
|
in {
|
|
|
|
options = {
|
|
|
|
services.mathics = {
|
|
|
|
enable = mkEnableOption "Mathics notebook service";
|
|
|
|
|
|
|
|
external = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Listen on all interfaces, rather than just localhost?";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 8000;
|
|
|
|
description = "TCP port to listen on.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.users.mathics = {
|
|
|
|
group = config.users.groups.mathics.name;
|
2015-09-08 07:17:21 +00:00
|
|
|
description = "Mathics user";
|
|
|
|
home = "/var/lib/mathics";
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.mathics;
|
|
|
|
};
|
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.groups.mathics.gid = config.ids.gids.mathics;
|
2015-09-08 07:17:21 +00:00
|
|
|
|
|
|
|
systemd.services.mathics = {
|
|
|
|
description = "Mathics notebook server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
2018-06-29 23:58:35 +00:00
|
|
|
User = config.users.users.mathics.name;
|
|
|
|
Group = config.users.groups.mathics.name;
|
2015-09-08 07:17:21 +00:00
|
|
|
ExecStart = concatStringsSep " " [
|
|
|
|
"${pkgs.mathics}/bin/mathicsserver"
|
|
|
|
"--port" (toString cfg.port)
|
|
|
|
(if cfg.external then "--external" else "")
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|