nixos/codimd: rename to hedgedoc

CodiMD was renamed to HedgeDoc. The user, group and state directory,
will be named hedgedoc instead of codimd, starting with stateVersion
"21.03".
This commit is contained in:
WilliButz 2020-11-29 18:51:50 +01:00
parent e19995e43b
commit 1c55621706
No known key found for this signature in database
GPG Key ID: 92582A10F1179CB2
5 changed files with 120 additions and 112 deletions

View File

@ -856,7 +856,6 @@
./services/web-apps/atlassian/confluence.nix ./services/web-apps/atlassian/confluence.nix
./services/web-apps/atlassian/crowd.nix ./services/web-apps/atlassian/crowd.nix
./services/web-apps/atlassian/jira.nix ./services/web-apps/atlassian/jira.nix
./services/web-apps/codimd.nix
./services/web-apps/convos.nix ./services/web-apps/convos.nix
./services/web-apps/cryptpad.nix ./services/web-apps/cryptpad.nix
./services/web-apps/documize.nix ./services/web-apps/documize.nix
@ -865,6 +864,7 @@
./services/web-apps/gerrit.nix ./services/web-apps/gerrit.nix
./services/web-apps/gotify-server.nix ./services/web-apps/gotify-server.nix
./services/web-apps/grocy.nix ./services/web-apps/grocy.nix
./services/web-apps/hedgedoc.nix
./services/web-apps/icingaweb2/icingaweb2.nix ./services/web-apps/icingaweb2/icingaweb2.nix
./services/web-apps/icingaweb2/module-monitoring.nix ./services/web-apps/icingaweb2/module-monitoring.nix
./services/web-apps/ihatemoney ./services/web-apps/ihatemoney

View File

@ -3,10 +3,14 @@
with lib; with lib;
let let
cfg = config.services.codimd; cfg = config.services.hedgedoc;
name = if versionAtLeast config.system.stateVersion "21.03"
then "hedgedoc"
else "codimd";
prettyJSON = conf: prettyJSON = conf:
pkgs.runCommandLocal "codimd-config.json" { pkgs.runCommandLocal "hedgedoc-config.json" {
nativeBuildInputs = [ pkgs.jq ]; nativeBuildInputs = [ pkgs.jq ];
} '' } ''
echo '${builtins.toJSON conf}' | jq \ echo '${builtins.toJSON conf}' | jq \
@ -14,22 +18,26 @@ let
''; '';
in in
{ {
options.services.codimd = { imports = [
enable = mkEnableOption "the CodiMD Markdown Editor"; (mkRenamedOptionModule [ "services" "codimd" ] [ "services" "hedgedoc" ])
];
options.services.hedgedoc = {
enable = mkEnableOption "the HedgeDoc Markdown Editor";
groups = mkOption { groups = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
description = '' description = ''
Groups to which the codimd user should be added. Groups to which the user ${name} should be added.
''; '';
}; };
workDir = mkOption { workDir = mkOption {
type = types.path; type = types.path;
default = "/var/lib/codimd"; default = "/var/lib/${name}";
description = '' description = ''
Working directory for the CodiMD service. Working directory for the HedgeDoc service.
''; '';
}; };
@ -38,17 +46,17 @@ in
domain = mkOption { domain = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "codimd.org"; example = "hedgedoc.org";
description = '' description = ''
Domain name for the CodiMD instance. Domain name for the HedgeDoc instance.
''; '';
}; };
urlPath = mkOption { urlPath = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "/url/path/to/codimd"; example = "/url/path/to/hedgedoc";
description = '' description = ''
Path under which CodiMD is accessible. Path under which HedgeDoc is accessible.
''; '';
}; };
host = mkOption { host = mkOption {
@ -69,7 +77,7 @@ in
path = mkOption { path = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "/run/codimd.sock"; example = "/run/hedgedoc.sock";
description = '' description = ''
Specify where a UNIX domain socket should be placed. Specify where a UNIX domain socket should be placed.
''; '';
@ -77,7 +85,7 @@ in
allowOrigin = mkOption { allowOrigin = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
example = [ "localhost" "codimd.org" ]; example = [ "localhost" "hedgedoc.org" ];
description = '' description = ''
List of domains to whitelist. List of domains to whitelist.
''; '';
@ -201,7 +209,7 @@ in
''; '';
description = '' description = ''
Specify which database to use. Specify which database to use.
CodiMD supports mysql, postgres, sqlite and mssql. HedgeDoc supports mysql, postgres, sqlite and mssql.
See <link xlink:href="https://sequelize.readthedocs.io/en/v3/"> See <link xlink:href="https://sequelize.readthedocs.io/en/v3/">
https://sequelize.readthedocs.io/en/v3/</link> for more information. https://sequelize.readthedocs.io/en/v3/</link> for more information.
Note: This option overrides <option>db</option>. Note: This option overrides <option>db</option>.
@ -213,12 +221,12 @@ in
example = literalExample '' example = literalExample ''
{ {
dialect = "sqlite"; dialect = "sqlite";
storage = "/var/lib/codimd/db.codimd.sqlite"; storage = "/var/lib/${name}/db.${name}.sqlite";
} }
''; '';
description = '' description = ''
Specify the configuration for sequelize. Specify the configuration for sequelize.
CodiMD supports mysql, postgres, sqlite and mssql. HedgeDoc supports mysql, postgres, sqlite and mssql.
See <link xlink:href="https://sequelize.readthedocs.io/en/v3/"> See <link xlink:href="https://sequelize.readthedocs.io/en/v3/">
https://sequelize.readthedocs.io/en/v3/</link> for more information. https://sequelize.readthedocs.io/en/v3/</link> for more information.
Note: This option overrides <option>db</option>. Note: This option overrides <option>db</option>.
@ -227,7 +235,7 @@ in
sslKeyPath= mkOption { sslKeyPath= mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "/var/lib/codimd/codimd.key"; example = "/var/lib/hedgedoc/hedgedoc.key";
description = '' description = ''
Path to the SSL key. Needed when <option>useSSL</option> is enabled. Path to the SSL key. Needed when <option>useSSL</option> is enabled.
''; '';
@ -235,7 +243,7 @@ in
sslCertPath = mkOption { sslCertPath = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "/var/lib/codimd/codimd.crt"; example = "/var/lib/hedgedoc/hedgedoc.crt";
description = '' description = ''
Path to the SSL cert. Needed when <option>useSSL</option> is enabled. Path to the SSL cert. Needed when <option>useSSL</option> is enabled.
''; '';
@ -243,7 +251,7 @@ in
sslCAPath = mkOption { sslCAPath = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
example = [ "/var/lib/codimd/ca.crt" ]; example = [ "/var/lib/hedgedoc/ca.crt" ];
description = '' description = ''
SSL ca chain. Needed when <option>useSSL</option> is enabled. SSL ca chain. Needed when <option>useSSL</option> is enabled.
''; '';
@ -251,7 +259,7 @@ in
dhParamPath = mkOption { dhParamPath = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "/var/lib/codimd/dhparam.pem"; example = "/var/lib/hedgedoc/dhparam.pem";
description = '' description = ''
Path to the SSL dh params. Needed when <option>useSSL</option> is enabled. Path to the SSL dh params. Needed when <option>useSSL</option> is enabled.
''; '';
@ -260,10 +268,10 @@ in
type = types.str; type = types.str;
default = "/tmp"; default = "/tmp";
description = '' description = ''
Path to the temp directory CodiMD should use. Path to the temp directory HedgeDoc should use.
Note that <option>serviceConfig.PrivateTmp</option> is enabled for Note that <option>serviceConfig.PrivateTmp</option> is enabled for
the CodiMD systemd service by default. the HedgeDoc systemd service by default.
(Non-canonical paths are relative to CodiMD's base directory) (Non-canonical paths are relative to HedgeDoc's base directory)
''; '';
}; };
defaultNotePath = mkOption { defaultNotePath = mkOption {
@ -271,7 +279,7 @@ in
default = "./public/default.md"; default = "./public/default.md";
description = '' description = ''
Path to the default Note file. Path to the default Note file.
(Non-canonical paths are relative to CodiMD's base directory) (Non-canonical paths are relative to HedgeDoc's base directory)
''; '';
}; };
docsPath = mkOption { docsPath = mkOption {
@ -279,7 +287,7 @@ in
default = "./public/docs"; default = "./public/docs";
description = '' description = ''
Path to the docs directory. Path to the docs directory.
(Non-canonical paths are relative to CodiMD's base directory) (Non-canonical paths are relative to HedgeDoc's base directory)
''; '';
}; };
indexPath = mkOption { indexPath = mkOption {
@ -287,7 +295,7 @@ in
default = "./public/views/index.ejs"; default = "./public/views/index.ejs";
description = '' description = ''
Path to the index template file. Path to the index template file.
(Non-canonical paths are relative to CodiMD's base directory) (Non-canonical paths are relative to HedgeDoc's base directory)
''; '';
}; };
hackmdPath = mkOption { hackmdPath = mkOption {
@ -295,7 +303,7 @@ in
default = "./public/views/hackmd.ejs"; default = "./public/views/hackmd.ejs";
description = '' description = ''
Path to the hackmd template file. Path to the hackmd template file.
(Non-canonical paths are relative to CodiMD's base directory) (Non-canonical paths are relative to HedgeDoc's base directory)
''; '';
}; };
errorPath = mkOption { errorPath = mkOption {
@ -304,7 +312,7 @@ in
defaultText = "./public/views/error.ejs"; defaultText = "./public/views/error.ejs";
description = '' description = ''
Path to the error template file. Path to the error template file.
(Non-canonical paths are relative to CodiMD's base directory) (Non-canonical paths are relative to HedgeDoc's base directory)
''; '';
}; };
prettyPath = mkOption { prettyPath = mkOption {
@ -313,7 +321,7 @@ in
defaultText = "./public/views/pretty.ejs"; defaultText = "./public/views/pretty.ejs";
description = '' description = ''
Path to the pretty template file. Path to the pretty template file.
(Non-canonical paths are relative to CodiMD's base directory) (Non-canonical paths are relative to HedgeDoc's base directory)
''; '';
}; };
slidePath = mkOption { slidePath = mkOption {
@ -322,13 +330,13 @@ in
defaultText = "./public/views/slide.hbs"; defaultText = "./public/views/slide.hbs";
description = '' description = ''
Path to the slide template file. Path to the slide template file.
(Non-canonical paths are relative to CodiMD's base directory) (Non-canonical paths are relative to HedgeDoc's base directory)
''; '';
}; };
uploadsPath = mkOption { uploadsPath = mkOption {
type = types.str; type = types.str;
default = "${cfg.workDir}/uploads"; default = "${cfg.workDir}/uploads";
defaultText = "/var/lib/codimd/uploads"; defaultText = "/var/lib/${name}/uploads";
description = '' description = ''
Path under which uploaded files are saved. Path under which uploaded files are saved.
''; '';
@ -766,7 +774,7 @@ in
type = types.str; type = types.str;
default = ""; default = "";
description = '' description = ''
LDAP field which is used as the username on CodiMD. LDAP field which is used as the username on HedgeDoc.
By default <option>useridField</option> is used. By default <option>useridField</option> is used.
''; '';
}; };
@ -774,7 +782,7 @@ in
type = types.str; type = types.str;
example = "uid"; example = "uid";
description = '' description = ''
LDAP field which is a unique identifier for users on CodiMD. LDAP field which is a unique identifier for users on HedgeDoc.
''; '';
}; };
tlsca = mkOption { tlsca = mkOption {
@ -840,7 +848,7 @@ in
requiredGroups = mkOption { requiredGroups = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
example = [ "Hackmd-users" "Codimd-users" ]; example = [ "Hedgedoc-Users" ];
description = '' description = ''
Required group names. Required group names.
''; '';
@ -883,7 +891,7 @@ in
environmentFile = mkOption { environmentFile = mkOption {
type = with types; nullOr path; type = with types; nullOr path;
default = null; default = null;
example = "/var/lib/codimd/codimd.env"; example = "/var/lib/hedgedoc/hedgedoc.env";
description = '' description = ''
Environment file as defined in <citerefentry> Environment file as defined in <citerefentry>
<refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum> <refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum>
@ -894,9 +902,9 @@ in
setting these variables accordingly in the environment file. setting these variables accordingly in the environment file.
<programlisting> <programlisting>
# snippet of CodiMD-related config # snippet of HedgeDoc-related config
services.codimd.configuration.dbURL = "postgres://codimd:\''${DB_PASSWORD}@db-host:5432/codimddb"; services.hedgedoc.configuration.dbURL = "postgres://hedgedoc:\''${DB_PASSWORD}@db-host:5432/hedgedocdb";
services.codimd.configuration.minio.secretKey = "$MINIO_SECRET_KEY"; services.hedgedoc.configuration.minio.secretKey = "$MINIO_SECRET_KEY";
</programlisting> </programlisting>
<programlisting> <programlisting>
@ -906,15 +914,15 @@ in
</programlisting> </programlisting>
Note that this file needs to be available on the host on which Note that this file needs to be available on the host on which
<literal>CodiMD</literal> is running. <literal>HedgeDoc</literal> is running.
''; '';
}; };
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = pkgs.codimd; default = pkgs.hedgedoc;
description = '' description = ''
Package that provides CodiMD. Package that provides HedgeDoc.
''; '';
}; };
}; };
@ -924,20 +932,20 @@ in
{ assertion = cfg.configuration.db == {} -> ( { assertion = cfg.configuration.db == {} -> (
cfg.configuration.dbURL != "" && cfg.configuration.dbURL != null cfg.configuration.dbURL != "" && cfg.configuration.dbURL != null
); );
message = "Database configuration for CodiMD missing."; } message = "Database configuration for HedgeDoc missing."; }
]; ];
users.groups.codimd = {}; users.groups.${name} = {};
users.users.codimd = { users.users.${name} = {
description = "CodiMD service user"; description = "HedgeDoc service user";
group = "codimd"; group = name;
extraGroups = cfg.groups; extraGroups = cfg.groups;
home = cfg.workDir; home = cfg.workDir;
createHome = true; createHome = true;
isSystemUser = true; isSystemUser = true;
}; };
systemd.services.codimd = { systemd.services.hedgedoc = {
description = "CodiMD Service"; description = "HedgeDoc Service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "networking.target" ]; after = [ "networking.target" ];
preStart = '' preStart = ''
@ -947,14 +955,14 @@ in
''; '';
serviceConfig = { serviceConfig = {
WorkingDirectory = cfg.workDir; WorkingDirectory = cfg.workDir;
ExecStart = "${cfg.package}/bin/codimd"; ExecStart = "${cfg.package}/bin/hedgedoc";
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"
"NODE_ENV=production" "NODE_ENV=production"
]; ];
Restart = "always"; Restart = "always";
User = "codimd"; User = name;
PrivateTmp = true; PrivateTmp = true;
}; };
}; };

View File

@ -63,7 +63,6 @@ in
clickhouse = handleTest ./clickhouse.nix {}; clickhouse = handleTest ./clickhouse.nix {};
cloud-init = handleTest ./cloud-init.nix {}; cloud-init = handleTest ./cloud-init.nix {};
cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {}; cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {};
codimd = handleTest ./codimd.nix {};
consul = handleTest ./consul.nix {}; consul = handleTest ./consul.nix {};
containers-bridge = handleTest ./containers-bridge.nix {}; containers-bridge = handleTest ./containers-bridge.nix {};
containers-custom-pkgs.nix = handleTest ./containers-custom-pkgs.nix {}; containers-custom-pkgs.nix = handleTest ./containers-custom-pkgs.nix {};
@ -147,6 +146,7 @@ in
handbrake = handleTestOn ["x86_64-linux"] ./handbrake.nix {}; handbrake = handleTestOn ["x86_64-linux"] ./handbrake.nix {};
haproxy = handleTest ./haproxy.nix {}; haproxy = handleTest ./haproxy.nix {};
hardened = handleTest ./hardened.nix {}; hardened = handleTest ./hardened.nix {};
hedgedoc = handleTest ./hedgedoc.nix {};
installed-tests = pkgs.recurseIntoAttrs (handleTest ./installed-tests {}); installed-tests = pkgs.recurseIntoAttrs (handleTest ./installed-tests {});
oci-containers = handleTestOn ["x86_64-linux"] ./oci-containers.nix {}; oci-containers = handleTestOn ["x86_64-linux"] ./oci-containers.nix {};
# 9pnet_virtio used to mount /nix partition doesn't support # 9pnet_virtio used to mount /nix partition doesn't support

View File

@ -1,60 +0,0 @@
import ./make-test-python.nix ({ pkgs, lib, ... }:
{
name = "codimd";
meta = with lib.maintainers; {
maintainers = [ willibutz ];
};
nodes = {
codimdSqlite = { ... }: {
services = {
codimd = {
enable = true;
configuration.dbURL = "sqlite:///var/lib/codimd/codimd.db";
};
};
};
codimdPostgres = { ... }: {
systemd.services.codimd.after = [ "postgresql.service" ];
services = {
codimd = {
enable = true;
configuration.dbURL = "postgres://codimd:\${DB_PASSWORD}@localhost:5432/codimddb";
/*
* Do not use pkgs.writeText for secrets as
* they will end up in the world-readable Nix store.
*/
environmentFile = pkgs.writeText "codimd-env" ''
DB_PASSWORD=snakeoilpassword
'';
};
postgresql = {
enable = true;
initialScript = pkgs.writeText "pg-init-script.sql" ''
CREATE ROLE codimd LOGIN PASSWORD 'snakeoilpassword';
CREATE DATABASE codimddb OWNER codimd;
'';
};
};
};
};
testScript = ''
start_all()
with subtest("CodiMD sqlite"):
codimdSqlite.wait_for_unit("codimd.service")
codimdSqlite.wait_for_open_port(3000)
codimdSqlite.wait_until_succeeds("curl -sSf http://localhost:3000/new")
with subtest("CodiMD postgres"):
codimdPostgres.wait_for_unit("postgresql.service")
codimdPostgres.wait_for_unit("codimd.service")
codimdPostgres.wait_for_open_port(5432)
codimdPostgres.wait_for_open_port(3000)
codimdPostgres.wait_until_succeeds("curl -sSf http://localhost:3000/new")
'';
})

60
nixos/tests/hedgedoc.nix Normal file
View File

@ -0,0 +1,60 @@
import ./make-test-python.nix ({ pkgs, lib, ... }:
{
name = "hedgedoc";
meta = with lib.maintainers; {
maintainers = [ willibutz ];
};
nodes = {
hedgedocSqlite = { ... }: {
services = {
hedgedoc = {
enable = true;
configuration.dbURL = "sqlite:///var/lib/hedgedoc/hedgedoc.db";
};
};
};
hedgedocPostgres = { ... }: {
systemd.services.hedgedoc.after = [ "postgresql.service" ];
services = {
hedgedoc = {
enable = true;
configuration.dbURL = "postgres://hedgedoc:\${DB_PASSWORD}@localhost:5432/hedgedocdb";
/*
* Do not use pkgs.writeText for secrets as
* they will end up in the world-readable Nix store.
*/
environmentFile = pkgs.writeText "hedgedoc-env" ''
DB_PASSWORD=snakeoilpassword
'';
};
postgresql = {
enable = true;
initialScript = pkgs.writeText "pg-init-script.sql" ''
CREATE ROLE hedgedoc LOGIN PASSWORD 'snakeoilpassword';
CREATE DATABASE hedgedocdb OWNER hedgedoc;
'';
};
};
};
};
testScript = ''
start_all()
with subtest("HedgeDoc sqlite"):
hedgedocSqlite.wait_for_unit("hedgedoc.service")
hedgedocSqlite.wait_for_open_port(3000)
hedgedocSqlite.wait_until_succeeds("curl -sSf http://localhost:3000/new")
with subtest("HedgeDoc postgres"):
hedgedocPostgres.wait_for_unit("postgresql.service")
hedgedocPostgres.wait_for_unit("hedgedoc.service")
hedgedocPostgres.wait_for_open_port(5432)
hedgedocPostgres.wait_for_open_port(3000)
hedgedocPostgres.wait_until_succeeds("curl -sSf http://localhost:3000/new")
'';
})