Merge pull request #246575 from NixOS/modules/hedgedoc/refactor-options

nixos/modules/hedgedoc: minor refactoring

authored by

WilliButz and committed by
GitHub
308bac15 9313322e

+11 -13
+11 -13
nixos/modules/services/web-apps/hedgedoc.nix
··· 1 1 { config, lib, pkgs, ... }: 2 2 3 - with lib; 4 - 5 3 let 4 + inherit (lib) literalExpression mdDoc mkEnableOption mkIf mkOption mkPackageOptionMD mkRenamedOptionModule types versionAtLeast; 5 + 6 6 cfg = config.services.hedgedoc; 7 7 8 8 # 21.03 will not be an official release - it was instead 21.05. This ··· 32 32 ]; 33 33 34 34 options.services.hedgedoc = { 35 + package = mkPackageOptionMD pkgs "hedgedoc" { }; 35 36 enable = mkEnableOption (lib.mdDoc "the HedgeDoc Markdown Editor"); 36 37 37 38 groups = mkOption { ··· 105 106 description = lib.mdDoc '' 106 107 Enable to use SSL server. This will also enable 107 108 {option}`protocolUseSSL`. 109 + ''; 110 + }; 111 + enableStatsApi = mkOption { 112 + type = types.bool; 113 + default = false; 114 + description = lib.mdDoc '' 115 + Enables or disables the /status and /metrics endpoint. 108 116 ''; 109 117 }; 110 118 hsts = { ··· 1018 1026 `HedgeDoc` is running. 1019 1027 ''; 1020 1028 }; 1021 - 1022 - package = mkOption { 1023 - type = types.package; 1024 - default = pkgs.hedgedoc; 1025 - defaultText = literalExpression "pkgs.hedgedoc"; 1026 - description = lib.mdDoc '' 1027 - Package that provides HedgeDoc. 1028 - ''; 1029 - }; 1030 - 1031 1029 }; 1032 1030 1033 1031 config = mkIf cfg.enable { ··· 1060 1058 serviceConfig = { 1061 1059 WorkingDirectory = cfg.workDir; 1062 1060 StateDirectory = [ cfg.workDir cfg.settings.uploadsPath ]; 1063 - ExecStart = "${cfg.package}/bin/hedgedoc"; 1061 + ExecStart = "${lib.getExe cfg.package}"; 1064 1062 EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ]; 1065 1063 Environment = [ 1066 1064 "CMD_CONFIG_FILE=${cfg.workDir}/config.json"