2015-04-10 22:09:31 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.ihaskell;
|
|
|
|
ihaskell = pkgs.ihaskell.override {
|
|
|
|
packages = self: cfg.extraPackages self;
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.ihaskell = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Autostart an IHaskell notebook service.";
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
|
|
|
default = self: [];
|
|
|
|
example = literalExample ''
|
|
|
|
haskellPackages: [
|
|
|
|
haskellPackages.wreq
|
|
|
|
haskellPackages.lens
|
|
|
|
]
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra packages available to ghc when running ihaskell. The
|
|
|
|
value must be a function which receives the attrset defined
|
|
|
|
in <varname>haskellPackages</varname> as the sole argument.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.users.ihaskell = {
|
|
|
|
group = config.users.groups.ihaskell.name;
|
2015-04-10 22:09:31 +00:00
|
|
|
description = "IHaskell user";
|
|
|
|
home = "/var/lib/ihaskell";
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.ihaskell;
|
|
|
|
};
|
|
|
|
|
2018-06-29 23:58:35 +00:00
|
|
|
users.groups.ihaskell.gid = config.ids.gids.ihaskell;
|
2015-04-10 22:09:31 +00:00
|
|
|
|
|
|
|
systemd.services.ihaskell = {
|
|
|
|
description = "IHaskell notebook instance";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
2018-06-29 23:58:35 +00:00
|
|
|
User = config.users.users.ihaskell.name;
|
|
|
|
Group = config.users.groups.ihaskell.name;
|
2018-03-01 19:38:53 +00:00
|
|
|
ExecStart = "${pkgs.runtimeShell} -c \"cd $HOME;${ihaskell}/bin/ihaskell-notebook\"";
|
2015-04-10 22:09:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|