nixpkgs/nixos/modules/services/development/hoogle.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
2.3 KiB
Nix
Raw Permalink Normal View History

2016-04-12 13:31:47 -07:00
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.hoogle;
hoogleEnv = pkgs.buildEnv {
name = "hoogle";
paths = [ (cfg.haskellPackages.ghcWithHoogle cfg.packages) ];
};
2016-04-12 13:31:47 -07:00
in
{
options.services.hoogle = {
enable = lib.mkEnableOption "Haskell documentation server";
2016-04-12 13:31:47 -07:00
port = lib.mkOption {
type = lib.types.port;
2016-04-12 13:31:47 -07:00
default = 8080;
description = ''
Port number Hoogle will be listening to.
'';
};
packages = lib.mkOption {
type = lib.types.functionTo (lib.types.listOf lib.types.package);
2016-04-12 13:31:47 -07:00
default = hp: [ ];
defaultText = lib.literalExpression "hp: []";
example = lib.literalExpression "hp: with hp; [ text lens ]";
2016-04-12 13:31:47 -07:00
description = ''
The Haskell packages to generate documentation for.
2016-04-12 13:31:47 -07:00
The option value is a function that takes the package set specified in
the {var}`haskellPackages` option as its sole parameter and
returns a list of packages.
2016-04-12 13:31:47 -07:00
'';
};
haskellPackages = lib.mkOption {
2016-04-12 13:31:47 -07:00
description = "Which haskell package set to use.";
type = lib.types.attrs;
default = pkgs.haskellPackages;
defaultText = lib.literalExpression "pkgs.haskellPackages";
2016-04-12 13:31:47 -07:00
};
home = lib.mkOption {
type = lib.types.str;
2018-07-30 04:27:07 -06:00
description = "Url for hoogle logo";
default = "https://hoogle.haskell.org";
};
host = lib.mkOption {
type = lib.types.str;
description = "Set the host to bind on.";
default = "127.0.0.1";
};
2024-03-06 22:12:41 -05:00
extraOptions = lib.mkOption {
type = lib.types.listOf lib.types.str;
2024-03-06 22:12:41 -05:00
default = [ ];
example = [ "--no-security-headers" ];
description = ''
Additional command-line arguments to pass to
{command}`hoogle server`
'';
};
2016-04-12 13:31:47 -07:00
};
config = lib.mkIf cfg.enable {
2016-04-12 13:31:47 -07:00
systemd.services.hoogle = {
description = "Haskell documentation server";
2016-04-12 13:31:47 -07:00
wantedBy = [ "multi-user.target" ];
2016-04-12 13:31:47 -07:00
serviceConfig = {
Restart = "always";
2024-03-06 22:12:41 -05:00
ExecStart = ''
${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home} --host ${cfg.host} \
${lib.concatStringsSep " " cfg.extraOptions}
2024-03-06 22:12:41 -05:00
'';
DynamicUser = true;
ProtectHome = true;
RuntimeDirectory = "hoogle";
WorkingDirectory = "%t/hoogle";
2016-04-12 13:31:47 -07:00
};
};
};
}