2020-04-24 23:36:52 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.ihaskell;
|
|
|
|
ihaskell = pkgs.ihaskell.override {
|
2021-10-06 13:57:05 +00:00
|
|
|
packages = cfg.extraPackages;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.ihaskell = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Autostart an IHaskell notebook service.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.functionTo (types.listOf types.package);
|
2021-10-06 13:57:05 +00:00
|
|
|
default = haskellPackages: [];
|
|
|
|
defaultText = literalExpression "haskellPackages: []";
|
|
|
|
example = literalExpression ''
|
2020-04-24 23:36:52 +00:00
|
|
|
haskellPackages: [
|
|
|
|
haskellPackages.wreq
|
|
|
|
haskellPackages.lens
|
|
|
|
]
|
|
|
|
'';
|
2022-09-09 14:08:57 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Extra packages available to ghc when running ihaskell. The
|
|
|
|
value must be a function which receives the attrset defined
|
2022-09-09 14:08:57 +00:00
|
|
|
in {var}`haskellPackages` as the sole argument.
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
users.users.ihaskell = {
|
|
|
|
group = config.users.groups.ihaskell.name;
|
|
|
|
description = "IHaskell user";
|
|
|
|
home = "/var/lib/ihaskell";
|
|
|
|
createHome = true;
|
|
|
|
uid = config.ids.uids.ihaskell;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.ihaskell.gid = config.ids.gids.ihaskell;
|
|
|
|
|
|
|
|
systemd.services.ihaskell = {
|
|
|
|
description = "IHaskell notebook instance";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
User = config.users.users.ihaskell.name;
|
|
|
|
Group = config.users.groups.ihaskell.name;
|
|
|
|
ExecStart = "${pkgs.runtimeShell} -c \"cd $HOME;${ihaskell}/bin/ihaskell-notebook\"";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|