2016-04-12 20:31:47 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.hoogle;
|
2016-04-22 00:28:29 +00:00
|
|
|
|
|
|
|
hoogleEnv = pkgs.buildEnv {
|
|
|
|
name = "hoogle";
|
|
|
|
paths = [ (cfg.haskellPackages.ghcWithHoogle cfg.packages) ];
|
|
|
|
};
|
2016-04-12 20:31:47 +00:00
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
options.services.hoogle = {
|
2016-04-22 00:28:29 +00:00
|
|
|
enable = mkEnableOption "Haskell documentation server";
|
2016-04-12 20:31:47 +00:00
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 8080;
|
|
|
|
description = ''
|
|
|
|
Port number Hoogle will be listening to.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
packages = mkOption {
|
2018-08-07 16:53:56 +00:00
|
|
|
type = types.functionTo (types.listOf types.package);
|
2016-04-12 20:31:47 +00:00
|
|
|
default = hp: [];
|
2016-04-22 00:28:29 +00:00
|
|
|
defaultText = "hp: []";
|
2016-04-12 20:31:47 +00:00
|
|
|
example = "hp: with hp; [ text lens ]";
|
|
|
|
description = ''
|
2016-04-22 00:28:29 +00:00
|
|
|
The Haskell packages to generate documentation for.
|
2016-04-12 20:31:47 +00:00
|
|
|
|
2016-04-22 00:28:29 +00: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 20:31:47 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
haskellPackages = mkOption {
|
|
|
|
description = "Which haskell package set to use.";
|
2016-04-22 00:28:29 +00:00
|
|
|
default = pkgs.haskellPackages;
|
|
|
|
defaultText = "pkgs.haskellPackages";
|
2016-04-12 20:31:47 +00:00
|
|
|
};
|
|
|
|
|
2018-07-30 10:27:07 +00: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 20:31:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.hoogle = {
|
2016-04-22 00:28:29 +00:00
|
|
|
description = "Haskell documentation server";
|
|
|
|
|
2016-04-12 20:31:47 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-04-22 00:28:29 +00:00
|
|
|
|
2016-04-12 20:31:47 +00: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 00:28:29 +00:00
|
|
|
|
2020-10-29 17:05:57 +00:00
|
|
|
DynamicUser = true;
|
2016-04-22 00:28:29 +00:00
|
|
|
|
|
|
|
ProtectHome = true;
|
|
|
|
|
|
|
|
RuntimeDirectory = "hoogle";
|
|
|
|
WorkingDirectory = "%t/hoogle";
|
2016-04-12 20:31:47 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|