nixos/codimd: add package option, refactor prettyJSON
This adds a `package` option to allow for easier overriding of the used CodiMD version and `runCommandLocal` with `nativeBuildInputs` is now used to pretty print the configuration.
This commit is contained in:
parent
eb64d1518f
commit
74d354a397
@ -6,8 +6,10 @@ let
|
|||||||
cfg = config.services.codimd;
|
cfg = config.services.codimd;
|
||||||
|
|
||||||
prettyJSON = conf:
|
prettyJSON = conf:
|
||||||
pkgs.runCommand "codimd-config.json" { preferLocalBuild = true; } ''
|
pkgs.runCommandLocal "codimd-config.json" {
|
||||||
echo '${builtins.toJSON conf}' | ${pkgs.jq}/bin/jq \
|
nativeBuildInputs = [ pkgs.jq ];
|
||||||
|
} ''
|
||||||
|
echo '${builtins.toJSON conf}' | jq \
|
||||||
'{production:del(.[]|nulls)|del(.[][]?|nulls)}' > $out
|
'{production:del(.[]|nulls)|del(.[][]?|nulls)}' > $out
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
@ -878,7 +880,6 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
environmentFile = mkOption {
|
environmentFile = mkOption {
|
||||||
type = with types; nullOr path;
|
type = with types; nullOr path;
|
||||||
default = null;
|
default = null;
|
||||||
@ -908,6 +909,14 @@ in
|
|||||||
<literal>CodiMD</literal> is running.
|
<literal>CodiMD</literal> is running.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = pkgs.codimd;
|
||||||
|
description = ''
|
||||||
|
Package that provides CodiMD.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@ -938,7 +947,7 @@ in
|
|||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
WorkingDirectory = cfg.workDir;
|
WorkingDirectory = cfg.workDir;
|
||||||
ExecStart = "${pkgs.codimd}/bin/codimd";
|
ExecStart = "${cfg.package}/bin/codimd";
|
||||||
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
|
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
|
||||||
Environment = [
|
Environment = [
|
||||||
"CMD_CONFIG_FILE=${cfg.workDir}/config.json"
|
"CMD_CONFIG_FILE=${cfg.workDir}/config.json"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user