aboutsummaryrefslogtreecommitdiff
path: root/nixos/modules/services/development/hoogle.nix
diff options
context:
space:
mode:
authorWilliam Casarin <bill@casarin.me>2016-04-12 13:31:47 -0700
committerJoachim Fasting <joachifm@fastmail.fm>2016-04-22 03:58:07 +0200
commit9c0997a0ef62d178d6bc88aeacc2643481edef9e (patch)
treea8775e46c89989cc7aa87ce2a9c94c527faeb1a9 /nixos/modules/services/development/hoogle.nix
parenta240d9509e1f9318cb099e6d573360dae7aa4743 (diff)
hoogle service: init
Diffstat (limited to 'nixos/modules/services/development/hoogle.nix')
-rw-r--r--nixos/modules/services/development/hoogle.nix68
1 files changed, 68 insertions, 0 deletions
diff --git a/nixos/modules/services/development/hoogle.nix b/nixos/modules/services/development/hoogle.nix
new file mode 100644
index 000000000000..27281774b6fc
--- /dev/null
+++ b/nixos/modules/services/development/hoogle.nix
@@ -0,0 +1,68 @@
+{ config, lib, pkgs, ... }:
+
+# services.hoogle = {
+# enable = true;
+# packages = hp: with hp; [ text lens ];
+# haskellPackages = pkgs.haskellPackages;
+# };
+
+with lib;
+
+let
+
+ cfg = config.services.hoogle;
+ ghcWithHoogle = pkgs.haskellPackages.ghcWithHoogle;
+
+in {
+
+ options.services.hoogle = {
+ enable = mkEnableOption "Hoogle Documentation service";
+
+ port = mkOption {
+ type = types.int;
+ default = 8080;
+ description = ''
+ Port number Hoogle will be listening to.
+ '';
+ };
+
+ packages = mkOption {
+ default = hp: [];
+ example = "hp: with hp; [ text lens ]";
+ description = ''
+ A function that returns a list of Haskell packages to generate
+ documentation for.
+
+ The argument will be a Haskell package set provided by the
+ haskellPackages config option.
+ '';
+ };
+
+ haskellPackages = mkOption {
+ description = "Which haskell package set to use.";
+ example = "pkgs.haskellPackages";
+ type = types.attrs;
+ };
+
+ };
+
+ config = mkIf cfg.enable {
+ systemd.services.hoogle = {
+ description = "Hoogle Haskell documentation search";
+ wantedBy = [ "multi-user.target" ];
+ serviceConfig = {
+ Restart = "always";
+ ExecStart =
+ let env = cfg.haskellPackages.ghcWithHoogle cfg.packages;
+ hoogleEnv = pkgs.buildEnv {
+ name = "hoogleServiceEnv";
+ paths = [env];
+ };
+ in ''
+ ${hoogleEnv}/bin/hoogle server --local -p ${toString cfg.port}
+ '';
+ };
+ };
+ };
+
+}