default.nix (1567B)
1 { config, lib, pkgs, ... }: 2 3 with lib; 4 5 let 6 7 cfg = config.services.hoogle; 8 ghcWithHoogle = pkgs.haskellPackages.ghcWithHoogle; 9 10 in { 11 12 options.services.hoogle = { 13 enable = mkOption { 14 type = types.bool; 15 default = false; 16 example = true; 17 description = '' 18 Enable Hoogle to run a documentation server for a list of haskell packages 19 ''; 20 }; 21 22 port = mkOption { 23 type = types.int; 24 default = 8080; 25 description = '' 26 Number of the port Hoogle will be listening to. 27 ''; 28 }; 29 30 packages = mkOption { 31 default = hp: []; 32 example = "hp: with hp; [ text lens ]"; 33 description = '' 34 A function that takes a haskell package set and returns a list of 35 packages from it. 36 ''; 37 }; 38 39 haskellPackages = mkOption { 40 description = "Which haskell package set to use."; 41 example = "pkgs.haskell.packages.ghc704"; 42 default = pkgs.haskellPackages; 43 type = types.attrs; 44 }; 45 }; 46 47 config = mkIf cfg.enable { 48 systemd.services.hoogle = { 49 description = "Hoogle Haskell documentation search"; 50 wantedBy = [ "multi-user.target" ]; 51 serviceConfig = { 52 Restart = "always"; 53 ExecStart = 54 let env = cfg.haskellPackages.ghcWithHoogle cfg.packages; 55 hoogleEnv = pkgs.buildEnv { 56 name = "hoogleServiceEnv"; 57 paths = [env]; 58 }; 59 in '' 60 ${hoogleEnv}/bin/hoogle server --local -p ${toString cfg.port} 61 ''; 62 }; 63 }; 64 }; 65 66 }