summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/misc/mathics.nix54
-rw-r--r--nixos/release.nix1
-rw-r--r--nixos/tests/mathics.nix20
5 files changed, 78 insertions, 0 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index 7a7ed2f4408c..1da3737b07cb 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -239,6 +239,7 @@
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!
@@ -455,6 +456,7 @@
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
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 7fc41b0e9ca7..e1ffb0b7edf8 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -209,6 +209,7 @@
./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
diff --git a/nixos/modules/services/misc/mathics.nix b/nixos/modules/services/misc/mathics.nix
new file mode 100644
index 000000000000..50715858881a
--- /dev/null
+++ b/nixos/modules/services/misc/mathics.nix
@@ -0,0 +1,54 @@
+{ 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 "")
+ ];
+ };
+ };
+ };
+}
diff --git a/nixos/release.nix b/nixos/release.nix
index d7c736d66a95..8a502ae2baa1 100644
--- a/nixos/release.nix
+++ b/nixos/release.nix
@@ -252,6 +252,7 @@ in rec {
#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 {};
diff --git a/nixos/tests/mathics.nix b/nixos/tests/mathics.nix
new file mode 100644
index 000000000000..310b751b4d84
--- /dev/null
+++ b/nixos/tests/mathics.nix
@@ -0,0 +1,20 @@
+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/");
+ '';
+})