| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  | { config, lib, pkgs, ... }: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | with lib; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   cfg = config.services.hoogle; | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   hoogleEnv = pkgs.buildEnv { | 
					
						
							|  |  |  |     name = "hoogle"; | 
					
						
							|  |  |  |     paths = [ (cfg.haskellPackages.ghcWithHoogle cfg.packages) ]; | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | in { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   options.services.hoogle = { | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  |     enable = mkEnableOption "Haskell documentation server"; | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     port = mkOption { | 
					
						
							|  |  |  |       type = types.int; | 
					
						
							|  |  |  |       default = 8080; | 
					
						
							|  |  |  |       description = ''
 | 
					
						
							|  |  |  |         Port number Hoogle will be listening to. | 
					
						
							|  |  |  |       '';
 | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     packages = mkOption { | 
					
						
							|  |  |  |       default = hp: []; | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  |       defaultText = "hp: []"; | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  |       example = "hp: with hp; [ text lens ]"; | 
					
						
							|  |  |  |       description = ''
 | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  |         The Haskell packages to generate documentation for. | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  |         The option value is a function that takes the package set specified in | 
					
						
							|  |  |  |         the <varname>haskellPackages</varname> option as its sole parameter and | 
					
						
							|  |  |  |         returns a list of packages. | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  |       '';
 | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     haskellPackages = mkOption { | 
					
						
							|  |  |  |       description = "Which haskell package set to use."; | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  |       default = pkgs.haskellPackages; | 
					
						
							|  |  |  |       defaultText = "pkgs.haskellPackages"; | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-30 04:27:07 -06:00
										 |  |  |     home = mkOption { | 
					
						
							|  |  |  |       type = types.str; | 
					
						
							|  |  |  |       description = "Url for hoogle logo"; | 
					
						
							|  |  |  |       default = "https://hoogle.haskell.org"; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   config = mkIf cfg.enable { | 
					
						
							|  |  |  |     systemd.services.hoogle = { | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  |       description = "Haskell documentation server"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  |       wantedBy = [ "multi-user.target" ]; | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  |       serviceConfig = { | 
					
						
							|  |  |  |         Restart = "always"; | 
					
						
							| 
									
										
										
										
											2018-07-30 04:27:07 -06:00
										 |  |  |         ExecStart = ''${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home}''; | 
					
						
							| 
									
										
										
										
											2016-04-22 02:28:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         User = "nobody"; | 
					
						
							|  |  |  |         Group = "nogroup"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         PrivateTmp = true; | 
					
						
							|  |  |  |         ProtectHome = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         RuntimeDirectory = "hoogle"; | 
					
						
							|  |  |  |         WorkingDirectory = "%t/hoogle"; | 
					
						
							| 
									
										
										
										
											2016-04-12 13:31:47 -07:00
										 |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |