at 18.09-beta 1.7 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.hoogle; 8 9 hoogleEnv = pkgs.buildEnv { 10 name = "hoogle"; 11 paths = [ (cfg.haskellPackages.ghcWithHoogle cfg.packages) ]; 12 }; 13 14in { 15 16 options.services.hoogle = { 17 enable = mkEnableOption "Haskell documentation server"; 18 19 port = mkOption { 20 type = types.int; 21 default = 8080; 22 description = '' 23 Port number Hoogle will be listening to. 24 ''; 25 }; 26 27 packages = mkOption { 28 default = hp: []; 29 defaultText = "hp: []"; 30 example = "hp: with hp; [ text lens ]"; 31 description = '' 32 The Haskell packages to generate documentation for. 33 34 The option value is a function that takes the package set specified in 35 the <varname>haskellPackages</varname> option as its sole parameter and 36 returns a list of packages. 37 ''; 38 }; 39 40 haskellPackages = mkOption { 41 description = "Which haskell package set to use."; 42 default = pkgs.haskellPackages; 43 defaultText = "pkgs.haskellPackages"; 44 }; 45 46 home = mkOption { 47 type = types.str; 48 description = "Url for hoogle logo"; 49 default = "https://hoogle.haskell.org"; 50 }; 51 52 }; 53 54 config = mkIf cfg.enable { 55 systemd.services.hoogle = { 56 description = "Haskell documentation server"; 57 58 wantedBy = [ "multi-user.target" ]; 59 60 serviceConfig = { 61 Restart = "always"; 62 ExecStart = ''${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home}''; 63 64 User = "nobody"; 65 Group = "nogroup"; 66 67 PrivateTmp = true; 68 ProtectHome = true; 69 70 RuntimeDirectory = "hoogle"; 71 WorkingDirectory = "%t/hoogle"; 72 }; 73 }; 74 }; 75 76}