at 22.05-pre 2.0 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.port; 21 default = 8080; 22 description = '' 23 Port number Hoogle will be listening to. 24 ''; 25 }; 26 27 packages = mkOption { 28 type = types.functionTo (types.listOf types.package); 29 default = hp: []; 30 defaultText = literalExpression "hp: []"; 31 example = literalExpression "hp: with hp; [ text lens ]"; 32 description = '' 33 The Haskell packages to generate documentation for. 34 35 The option value is a function that takes the package set specified in 36 the <varname>haskellPackages</varname> option as its sole parameter and 37 returns a list of packages. 38 ''; 39 }; 40 41 haskellPackages = mkOption { 42 description = "Which haskell package set to use."; 43 default = pkgs.haskellPackages; 44 defaultText = literalExpression "pkgs.haskellPackages"; 45 }; 46 47 home = mkOption { 48 type = types.str; 49 description = "Url for hoogle logo"; 50 default = "https://hoogle.haskell.org"; 51 }; 52 53 host = mkOption { 54 type = types.str; 55 description = "Set the host to bind on."; 56 default = "127.0.0.1"; 57 }; 58 }; 59 60 config = mkIf cfg.enable { 61 systemd.services.hoogle = { 62 description = "Haskell documentation server"; 63 64 wantedBy = [ "multi-user.target" ]; 65 66 serviceConfig = { 67 Restart = "always"; 68 ExecStart = ''${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home} --host ${cfg.host}''; 69 70 DynamicUser = true; 71 72 ProtectHome = true; 73 74 RuntimeDirectory = "hoogle"; 75 WorkingDirectory = "%t/hoogle"; 76 }; 77 }; 78 }; 79 80}