2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.hoogle;
|
|
|
|
|
|
|
|
hoogleEnv = pkgs.buildEnv {
|
|
|
|
name = "hoogle";
|
|
|
|
paths = [ (cfg.haskellPackages.ghcWithHoogle cfg.packages) ];
|
|
|
|
};
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options.services.hoogle = {
|
|
|
|
enable = mkEnableOption "Haskell documentation server";
|
|
|
|
|
|
|
|
port = mkOption {
|
2021-08-11 14:56:57 +00:00
|
|
|
type = types.port;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = 8080;
|
|
|
|
description = ''
|
|
|
|
Port number Hoogle will be listening to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
packages = mkOption {
|
2021-02-05 17:12:51 +00:00
|
|
|
type = types.functionTo (types.listOf types.package);
|
2020-04-24 23:36:52 +00:00
|
|
|
default = hp: [];
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = literalExpression "hp: []";
|
|
|
|
example = literalExpression "hp: with hp; [ text lens ]";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = ''
|
|
|
|
The Haskell packages to generate documentation for.
|
|
|
|
|
|
|
|
The option value is a function that takes the package set specified in
|
|
|
|
the <varname>haskellPackages</varname> option as its sole parameter and
|
|
|
|
returns a list of packages.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
haskellPackages = mkOption {
|
|
|
|
description = "Which haskell package set to use.";
|
2021-12-19 01:06:50 +00:00
|
|
|
type = types.attrs;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = pkgs.haskellPackages;
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = literalExpression "pkgs.haskellPackages";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
home = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Url for hoogle logo";
|
|
|
|
default = "https://hoogle.haskell.org";
|
|
|
|
};
|
|
|
|
|
2021-01-09 10:05:03 +00:00
|
|
|
host = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Set the host to bind on.";
|
|
|
|
default = "127.0.0.1";
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.hoogle = {
|
|
|
|
description = "Haskell documentation server";
|
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Restart = "always";
|
2021-01-09 10:05:03 +00:00
|
|
|
ExecStart = ''${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home} --host ${cfg.host}'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-12-03 08:41:04 +00:00
|
|
|
DynamicUser = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
ProtectHome = true;
|
|
|
|
|
|
|
|
RuntimeDirectory = "hoogle";
|
|
|
|
WorkingDirectory = "%t/hoogle";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|