3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #103717 from WilliButz/codimd/add-package-option

nixos/codimd: add package option, refactor prettyJSON
This commit is contained in:
Maximilian Bosch 2020-11-16 13:46:17 +01:00 committed by GitHub
commit 9fc484c373
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,8 +6,10 @@ let
cfg = config.services.codimd;
prettyJSON = conf:
pkgs.runCommand "codimd-config.json" { preferLocalBuild = true; } ''
echo '${builtins.toJSON conf}' | ${pkgs.jq}/bin/jq \
pkgs.runCommandLocal "codimd-config.json" {
nativeBuildInputs = [ pkgs.jq ];
} ''
echo '${builtins.toJSON conf}' | jq \
'{production:del(.[]|nulls)|del(.[][]?|nulls)}' > $out
'';
in
@ -878,7 +880,6 @@ in
};
};
environmentFile = mkOption {
type = with types; nullOr path;
default = null;
@ -908,6 +909,14 @@ in
<literal>CodiMD</literal> is running.
'';
};
package = mkOption {
type = types.package;
default = pkgs.codimd;
description = ''
Package that provides CodiMD.
'';
};
};
config = mkIf cfg.enable {
@ -938,7 +947,7 @@ in
'';
serviceConfig = {
WorkingDirectory = cfg.workDir;
ExecStart = "${pkgs.codimd}/bin/codimd";
ExecStart = "${cfg.package}/bin/codimd";
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
Environment = [
"CMD_CONFIG_FILE=${cfg.workDir}/config.json"