2015-04-10 23:09:31 +01:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.ihaskell;
|
|
|
|
ihaskell = pkgs.ihaskell.override {
|
2021-10-03 17:06:03 +01:00
|
|
|
packages = cfg.extraPackages;
|
2015-04-10 23:09:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.ihaskell = {
|
|
|
|
enable = mkOption {
|
2020-04-20 19:05:26 +01:00
|
|
|
type = types.bool;
|
2015-04-10 23:09:31 +01:00
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Autostart an IHaskell notebook service.";
|
2015-04-10 23:09:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
2018-08-07 17:53:56 +01:00
|
|
|
type = types.functionTo (types.listOf types.package);
|
2021-10-03 17:06:03 +01:00
|
|
|
default = haskellPackages: [];
|
|
|
|
defaultText = literalExpression "haskellPackages: []";
|
|
|
|
example = literalExpression ''
|
2015-04-10 23:09:31 +01:00
|
|
|
haskellPackages: [
|
|
|
|
haskellPackages.wreq
|
|
|
|
haskellPackages.lens
|
|
|
|
]
|
|
|
|
'';
|
2022-08-28 20:18:44 +01:00
|
|
|
description = lib.mdDoc ''
|
2015-04-10 23:09:31 +01:00
|
|
|
Extra packages available to ghc when running ihaskell. The
|
|
|
|
value must be a function which receives the attrset defined
|
2022-08-28 20:18:44 +01:00
|
|
|
in {var}`haskellPackages` as the sole argument.
|
2015-04-10 23:09:31 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.users.ihaskell = {
|
|
|
|
group = config.users.groups.ihaskell.name;
|
2015-04-10 23:09:31 +01:00
|
|
|
description = "IHaskell user";
|
|
|
|
home = "/var/lib/ihaskell";
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.ihaskell;
|
|
|
|
};
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.groups.ihaskell.gid = config.ids.gids.ihaskell;
|
2015-04-10 23:09:31 +01:00
|
|
|
|
|
|
|
systemd.services.ihaskell = {
|
|
|
|
description = "IHaskell notebook instance";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
2018-06-30 00:58:35 +01: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 23:09:31 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|