nixos/mathics: New service and test

Changed files
+78
nixos
modules
misc
services
tests
+2
nixos/modules/misc/ids.nix
···
bepasty = 215;
pumpio = 216;
nm-openvpn = 217;
+
mathics = 218;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
···
bepasty = 215;
pumpio = 216;
nm-openvpn = 217;
+
mathics = 218;
# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal
+1
nixos/modules/module-list.nix
···
./services/misc/gitolite.nix
./services/misc/gpsd.nix
./services/misc/ihaskell.nix
+
./services/misc/mathics.nix
./services/misc/mbpfan.nix
./services/misc/mediatomb.nix
./services/misc/mesos-master.nix
+54
nixos/modules/services/misc/mathics.nix
···
+
{ 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 {
+
+
users.extraUsers.mathics = {
+
group = config.users.extraGroups.mathics.name;
+
description = "Mathics user";
+
home = "/var/lib/mathics";
+
createHome = true;
+
uid = config.ids.uids.mathics;
+
};
+
+
users.extraGroups.mathics.gid = config.ids.gids.mathics;
+
+
systemd.services.mathics = {
+
description = "Mathics notebook server";
+
wantedBy = [ "multi-user.target" ];
+
after = [ "network.target" ];
+
serviceConfig = {
+
User = config.users.extraUsers.mathics.name;
+
Group = config.users.extraGroups.mathics.name;
+
ExecStart = concatStringsSep " " [
+
"${pkgs.mathics}/bin/mathicsserver"
+
"--port" (toString cfg.port)
+
(if cfg.external then "--external" else "")
+
];
+
};
+
};
+
};
+
}
+1
nixos/release.nix
···
#tests.lightdm = callTest tests/lightdm.nix {};
tests.login = callTest tests/login.nix {};
#tests.logstash = callTest tests/logstash.nix {};
+
tests.mathics = callTest tests/mathics.nix {};
tests.misc = callTest tests/misc.nix {};
tests.mumble = callTest tests/mumble.nix {};
tests.munin = callTest tests/munin.nix {};
+20
nixos/tests/mathics.nix
···
+
import ./make-test.nix ({ pkgs, ... }: {
+
name = "mathics";
+
meta = with pkgs.stdenv.lib.maintainers; {
+
maintainers = [ benley ];
+
};
+
+
nodes = {
+
machine = { config, pkgs, ... }: {
+
services.mathics.enable = true;
+
services.mathics.port = 8888;
+
};
+
};
+
+
testScript = ''
+
startAll;
+
$machine->waitForUnit("mathics.service");
+
$machine->waitForOpenPort(8888);
+
$machine->succeed("curl http://localhost:8888/");
+
'';
+
})