at 23.11-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 (lib.mdDoc "Haskell documentation server"); 18 19 port = mkOption { 20 type = types.port; 21 default = 8080; 22 description = lib.mdDoc '' 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 = lib.mdDoc '' 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 {var}`haskellPackages` option as its sole parameter and 37 returns a list of packages. 38 ''; 39 }; 40 41 haskellPackages = mkOption { 42 description = lib.mdDoc "Which haskell package set to use."; 43 type = types.attrs; 44 default = pkgs.haskellPackages; 45 defaultText = literalExpression "pkgs.haskellPackages"; 46 }; 47 48 home = mkOption { 49 type = types.str; 50 description = lib.mdDoc "Url for hoogle logo"; 51 default = "https://hoogle.haskell.org"; 52 }; 53 54 host = mkOption { 55 type = types.str; 56 description = lib.mdDoc "Set the host to bind on."; 57 default = "127.0.0.1"; 58 }; 59 }; 60 61 config = mkIf cfg.enable { 62 systemd.services.hoogle = { 63 description = "Haskell documentation server"; 64 65 wantedBy = [ "multi-user.target" ]; 66 67 serviceConfig = { 68 Restart = "always"; 69 ExecStart = ''${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home} --host ${cfg.host}''; 70 71 DynamicUser = true; 72 73 ProtectHome = true; 74 75 RuntimeDirectory = "hoogle"; 76 WorkingDirectory = "%t/hoogle"; 77 }; 78 }; 79 }; 80 81}