2016-04-12 21:31:47 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.hoogle;
|
2016-04-22 01:28:29 +01:00
|
|
|
|
|
|
|
hoogleEnv = pkgs.buildEnv {
|
|
|
|
name = "hoogle";
|
|
|
|
paths = [ (cfg.haskellPackages.ghcWithHoogle cfg.packages) ];
|
|
|
|
};
|
2016-04-12 21:31:47 +01:00
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options.services.hoogle = {
|
2016-04-22 01:28:29 +01:00
|
|
|
enable = mkEnableOption "Haskell documentation server";
|
2016-04-12 21:31:47 +01:00
|
|
|
|
|
|
|
port = mkOption {
|
2021-08-01 12:09:26 +01:00
|
|
|
type = types.port;
|
2016-04-12 21:31:47 +01:00
|
|
|
default = 8080;
|
|
|
|
description = ''
|
|
|
|
Port number Hoogle will be listening to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
packages = mkOption {
|
2018-08-07 17:53:56 +01:00
|
|
|
type = types.functionTo (types.listOf types.package);
|
2016-04-12 21:31:47 +01:00
|
|
|
default = hp: [];
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "hp: []";
|
|
|
|
example = literalExpression "hp: with hp; [ text lens ]";
|
2016-04-12 21:31:47 +01:00
|
|
|
description = ''
|
2016-04-22 01:28:29 +01:00
|
|
|
The Haskell packages to generate documentation for.
|
2016-04-12 21:31:47 +01:00
|
|
|
|
2016-04-22 01:28:29 +01:00
|
|
|
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.
|
2016-04-12 21:31:47 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
haskellPackages = mkOption {
|
|
|
|
description = "Which haskell package set to use.";
|
2021-12-07 17:36:01 +00:00
|
|
|
type = types.attrs;
|
2016-04-22 01:28:29 +01:00
|
|
|
default = pkgs.haskellPackages;
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "pkgs.haskellPackages";
|
2016-04-12 21:31:47 +01:00
|
|
|
};
|
|
|
|
|
2018-07-30 11:27:07 +01:00
|
|
|
home = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Url for hoogle logo";
|
|
|
|
default = "https://hoogle.haskell.org";
|
|
|
|
};
|
|
|
|
|
2020-12-30 03:20:48 +00:00
|
|
|
host = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
description = "Set the host to bind on.";
|
|
|
|
default = "127.0.0.1";
|
|
|
|
};
|
2016-04-12 21:31:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.hoogle = {
|
2016-04-22 01:28:29 +01:00
|
|
|
description = "Haskell documentation server";
|
|
|
|
|
2016-04-12 21:31:47 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-04-22 01:28:29 +01:00
|
|
|
|
2016-04-12 21:31:47 +01:00
|
|
|
serviceConfig = {
|
|
|
|
Restart = "always";
|
2020-12-30 03:20:48 +00:00
|
|
|
ExecStart = ''${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home} --host ${cfg.host}'';
|
2016-04-22 01:28:29 +01:00
|
|
|
|
2020-10-29 17:05:57 +00:00
|
|
|
DynamicUser = true;
|
2016-04-22 01:28:29 +01:00
|
|
|
|
|
|
|
ProtectHome = true;
|
|
|
|
|
|
|
|
RuntimeDirectory = "hoogle";
|
|
|
|
WorkingDirectory = "%t/hoogle";
|
2016-04-12 21:31:47 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|