hoogle service: init

authored by

William Casarin and committed by
Joachim Fasting
9c0997a0 a240d950

+69
+1
nixos/modules/module-list.nix
··· 158 158 ./services/desktops/gnome3/tracker.nix 159 159 ./services/desktops/profile-sync-daemon.nix 160 160 ./services/desktops/telepathy.nix 161 + ./services/development/hoogle.nix 161 162 ./services/games/factorio.nix 162 163 ./services/games/ghost-one.nix 163 164 ./services/games/minecraft-server.nix
+68
nixos/modules/services/development/hoogle.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + # services.hoogle = { 4 + # enable = true; 5 + # packages = hp: with hp; [ text lens ]; 6 + # haskellPackages = pkgs.haskellPackages; 7 + # }; 8 + 9 + with lib; 10 + 11 + let 12 + 13 + cfg = config.services.hoogle; 14 + ghcWithHoogle = pkgs.haskellPackages.ghcWithHoogle; 15 + 16 + in { 17 + 18 + options.services.hoogle = { 19 + enable = mkEnableOption "Hoogle Documentation service"; 20 + 21 + port = mkOption { 22 + type = types.int; 23 + default = 8080; 24 + description = '' 25 + Port number Hoogle will be listening to. 26 + ''; 27 + }; 28 + 29 + packages = mkOption { 30 + default = hp: []; 31 + example = "hp: with hp; [ text lens ]"; 32 + description = '' 33 + A function that returns a list of Haskell packages to generate 34 + documentation for. 35 + 36 + The argument will be a Haskell package set provided by the 37 + haskellPackages config option. 38 + ''; 39 + }; 40 + 41 + haskellPackages = mkOption { 42 + description = "Which haskell package set to use."; 43 + example = "pkgs.haskellPackages"; 44 + type = types.attrs; 45 + }; 46 + 47 + }; 48 + 49 + config = mkIf cfg.enable { 50 + systemd.services.hoogle = { 51 + description = "Hoogle Haskell documentation search"; 52 + wantedBy = [ "multi-user.target" ]; 53 + serviceConfig = { 54 + Restart = "always"; 55 + ExecStart = 56 + let env = cfg.haskellPackages.ghcWithHoogle cfg.packages; 57 + hoogleEnv = pkgs.buildEnv { 58 + name = "hoogleServiceEnv"; 59 + paths = [env]; 60 + }; 61 + in '' 62 + ${hoogleEnv}/bin/hoogle server --local -p ${toString cfg.port} 63 + ''; 64 + }; 65 + }; 66 + }; 67 + 68 + }