0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixos/youtrack: rebuild module for 2023.x support

This commit is contained in:
Leona Maroni 2024-01-09 19:39:15 +01:00 committed by Yureka
parent 4f4a0821aa
commit 0f2df9ff19
3 changed files with 200 additions and 72 deletions

View file

@ -307,5 +307,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m
- The `mpich` package expression now requires `withPm` to be a list, e.g. `"hydra:gforker"` becomes `[ "hydra" "gforker" ]`. - The `mpich` package expression now requires `withPm` to be a list, e.g. `"hydra:gforker"` becomes `[ "hydra" "gforker" ]`.
- YouTrack is bumped to 2023.3. The update is not performed automatically, it requires manual interaction. See the YouTrack section in the manual for details.
- QtMultimedia has changed its default backend to `QT_MEDIA_BACKEND=ffmpeg` (previously `gstreamer` on Linux or `darwin` on MacOS). - QtMultimedia has changed its default backend to `QT_MEDIA_BACKEND=ffmpeg` (previously `gstreamer` on Linux or `darwin` on MacOS).
The previous native backends remain available but are now minimally maintained. Refer to [upstream documentation](https://doc.qt.io/qt-6/qtmultimedia-index.html#ffmpeg-as-the-default-backend) for further details about each platform. The previous native backends remain available but are now minimally maintained. Refer to [upstream documentation](https://doc.qt.io/qt-6/qtmultimedia-index.html#ffmpeg-as-the-default-backend) for further details about each platform.

View file

@ -0,0 +1,30 @@
# YouTrack {#module-services-youtrack}
YouTrack is a browser-based bug tracker, issue tracking system and project management software.
## Installation {#module-services-youtrack-installation}
YouTrack exposes a web GUI installer on first login.
You need a token to access it.
You can find this token in the log of the `youtrack` service. The log line looks like
```
* JetBrains YouTrack 2023.3 Configuration Wizard will be available on [http://127.0.0.1:8090/?wizard_token=somelongtoken] after start
```
## Upgrade from 2022.3 to 2023.x {#module-services-youtrack-upgrade-2022_3-2023_1}
Starting with YouTrack 2023.1, JetBrains no longer distributes it as as JAR.
The new distribution with the JetBrains Launcher as a ZIP changed the basic data structure and also some configuration parameters.
Check out https://www.jetbrains.com/help/youtrack/server/YouTrack-Java-Start-Parameters.html for more information on the new configuration options.
When upgrading to YouTrack 2023.1 or higher, a migration script will move the old state directory to `/var/lib/youtrack/2022_3` as a backup.
A one-time manual update is required:
1. Before you update take a backup of your YouTrack instance!
2. Migrate the options you set in `services.youtrack.extraParams` and `services.youtrack.jvmOpts` to `services.youtrack.generalParameters` and `services.youtrack.environmentalParameters` (see the examples and [the YouTrack docs](https://www.jetbrains.com/help/youtrack/server/2023.3/YouTrack-Java-Start-Parameters.html))
2. To start the upgrade set `services.youtrack.package = pkgs.youtrack`
3. YouTrack then starts in upgrade mode, meaning you need to obtain the wizard token as above
4. Select you want to **Upgrade** YouTrack
5. As source you select `/var/lib/youtrack/2022_3/teamsysdata/` (adopt if you have a different state path)
6. Change the data directory location to `/var/lib/youtrack/data/`. The other paths should already be right.
If you migrate a larger YouTrack instance, it might be useful to set `-Dexodus.entityStore.refactoring.forceAll=true` in `services.youtrack.generalParameters` for the first startup of YouTrack 2023.x.

View file

@ -1,130 +1,224 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.youtrack; cfg = config.services.youtrack;
extraAttr = concatStringsSep " " (mapAttrsToList (k: v: "-D${k}=${v}") (stdParams // cfg.extraParams));
mergeAttrList = lib.foldl' lib.mergeAttrs {};
stdParams = mergeAttrList [
(optionalAttrs (cfg.baseUrl != null) {
"jetbrains.youtrack.baseUrl" = cfg.baseUrl;
})
{
"java.aws.headless" = "true";
"jetbrains.youtrack.disableBrowser" = "true";
}
];
in in
{ {
imports = [
(lib.mkRenamedOptionModule [ "services" "youtrack" "baseUrl" ] [ "services" "youtrack" "environmentalParameters" "base-url" ])
(lib.mkRenamedOptionModule [ "services" "youtrack" "port" ] [ "services" "youtrack" "environmentalParameters" "listen-port" ])
(lib.mkRemovedOptionModule [ "services" "youtrack" "maxMemory" ] "Please instead use `services.youtrack.generalParameters`.")
(lib.mkRemovedOptionModule [ "services" "youtrack" "maxMetaspaceSize" ] "Please instead use `services.youtrack.generalParameters`.")
];
options.services.youtrack = { options.services.youtrack = {
enable = lib.mkEnableOption (lib.mdDoc "YouTrack service");
enable = mkEnableOption (lib.mdDoc "YouTrack service"); address = lib.mkOption {
address = mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
The interface youtrack will listen on. The interface youtrack will listen on.
''; '';
default = "127.0.0.1"; default = "127.0.0.1";
type = types.str; type = lib.types.str;
}; };
baseUrl = mkOption { extraParams = lib.mkOption {
description = lib.mdDoc ''
Base URL for youtrack. Will be auto-detected and stored in database.
'';
type = types.nullOr types.str;
default = null;
};
extraParams = mkOption {
default = {}; default = {};
description = lib.mdDoc '' description = lib.mdDoc ''
Extra parameters to pass to youtrack. See Extra parameters to pass to youtrack.
Use to configure YouTrack 2022.x, deprecated with YouTrack 2023.x. Use `services.youtrack.generalParameters`.
https://www.jetbrains.com/help/youtrack/standalone/YouTrack-Java-Start-Parameters.html https://www.jetbrains.com/help/youtrack/standalone/YouTrack-Java-Start-Parameters.html
for more information. for more information.
''; '';
example = literalExpression '' example = lib.literalExpression ''
{ {
"jetbrains.youtrack.overrideRootPassword" = "tortuga"; "jetbrains.youtrack.overrideRootPassword" = "tortuga";
} }
''; '';
type = types.attrsOf types.str; type = lib.types.attrsOf lib.types.str;
visible = false;
}; };
package = mkPackageOption pkgs "youtrack" { }; package = lib.mkOption {
port = mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
The port youtrack will listen on. Package to use.
''; '';
default = 8080; type = lib.types.package;
type = types.port; default = null;
relatedPackages = [ "youtrack_2022_3" "youtrack" ];
}; };
statePath = mkOption {
statePath = lib.mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
Where to keep the youtrack database. Path were the YouTrack state is stored.
To this path the base version (e.g. 2023_1) of the used package will be appended.
''; '';
type = types.path; type = lib.types.path;
default = "/var/lib/youtrack"; default = "/var/lib/youtrack";
}; };
virtualHost = mkOption { virtualHost = lib.mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
Name of the nginx virtual host to use and setup. Name of the nginx virtual host to use and setup.
If null, do not setup anything. If null, do not setup anything.
''; '';
default = null; default = null;
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
}; };
jvmOpts = mkOption { jvmOpts = lib.mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
Extra options to pass to the JVM. Extra options to pass to the JVM.
Only has a use with YouTrack 2022.x, deprecated with YouTrack 2023.x. Use `serivces.youtrack.generalParameters`.
See https://www.jetbrains.com/help/youtrack/standalone/Configure-JVM-Options.html See https://www.jetbrains.com/help/youtrack/standalone/Configure-JVM-Options.html
for more information. for more information.
''; '';
type = types.separatedString " "; type = lib.types.separatedString " ";
example = "-XX:MetaspaceSize=250m"; example = "--J-XX:MetaspaceSize=250m";
default = ""; default = "";
visible = false;
}; };
maxMemory = mkOption { autoUpgrade = lib.mkOption {
description = lib.mdDoc '' type = lib.types.bool;
Maximum Java heap size default = true;
''; description = lib.mdDoc "Whether YouTrack should auto upgrade it without showing the upgrade dialog.";
type = types.str;
default = "1g";
}; };
maxMetaspaceSize = mkOption { generalParameters = lib.mkOption {
type = with lib.types; listOf str;
description = lib.mdDoc '' description = lib.mdDoc ''
Maximum java Metaspace memory. General configuration parameters and other JVM options.
Only has an effect for YouTrack 2023.x.
See https://www.jetbrains.com/help/youtrack/server/2023.3/youtrack-java-start-parameters.html#general-parameters
for more information.
''; '';
type = types.str; example = lib.literalExpression ''
default = "350m"; [
"-Djetbrains.youtrack.admin.restore=true"
"-Xmx1024m"
];
'';
default = [];
};
environmentalParameters = lib.mkOption {
type = lib.types.submodule {
freeformType = with lib.types; attrsOf (oneOf [ int str port ]);
options = {
listen-address = lib.mkOption {
type = lib.types.str;
default = "0.0.0.0";
description = lib.mdDoc "The interface YouTrack will listen on.";
};
listen-port = lib.mkOption {
type = lib.types.port;
default = 8080;
description = lib.mdDoc "The port YouTrack will listen on.";
};
};
};
description = lib.mdDoc ''
Environmental configuration parameters, set imperatively. The values doesn't get removed, when removed in Nix.
Only has an effect for YouTrack 2023.x.
See https://www.jetbrains.com/help/youtrack/server/2023.3/youtrack-java-start-parameters.html#environmental-parameters
for more information.
'';
example = lib.literalExpression ''
{
secure-mode = "tls";
}
'';
default = {};
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
warnings = lib.optional (lib.versions.major cfg.package.version <= "2022")
"YouTrack 2022.x is deprecated. See https://nixos.org/manual/nixos/unstable/index.html#module-services-youtrack for details on how to upgrade."
++ lib.optional (cfg.extraParams != "" && (lib.versions.major cfg.package.version >= "2023"))
"'services.youtrack.extraParams' is deprecated and has no effect on YouTrack 2023.x and newer. Please migrate to 'services.youtrack.generalParameters'"
++ lib.optional (cfg.jvmOpts != "" && (lib.versions.major cfg.package.version >= "2023"))
"'services.youtrack.jvmOpts' is deprecated and has no effect on YouTrack 2023.x and newer. Please migrate to 'services.youtrack.generalParameters'";
systemd.services.youtrack = { # XXX: Drop all version feature switches at the point when we consider YT 2022.3 as outdated.
environment.HOME = cfg.statePath; services.youtrack.package = lib.mkDefault (
environment.YOUTRACK_JVM_OPTS = "${extraAttr}"; if lib.versionAtLeast config.system.stateVersion "24.11" then pkgs.youtrack
after = [ "network.target" ]; else pkgs.youtrack_2022_3
wantedBy = [ "multi-user.target" ]; );
path = with pkgs; [ unixtools.hostname ];
serviceConfig = { services.youtrack.generalParameters = lib.optional (lib.versions.major cfg.package.version >= "2023")
Type = "simple"; "-Ddisable.configuration.wizard.on.upgrade=${lib.boolToString cfg.autoUpgrade}"
User = "youtrack"; ++ (lib.mapAttrsToList (k: v: "-D${k}=${v}") cfg.extraParams);
Group = "youtrack";
Restart = "on-failure"; systemd.services.youtrack = let
ExecStart = ''${cfg.package}/bin/youtrack --J-Xmx${cfg.maxMemory} --J-XX:MaxMetaspaceSize=${cfg.maxMetaspaceSize} ${cfg.jvmOpts} ${cfg.address}:${toString cfg.port}''; service_jar = let
mergeAttrList = lib.foldl' lib.mergeAttrs {};
stdParams = mergeAttrList [
(lib.optionalAttrs (cfg.environmentalParameters ? base-url && cfg.environmentalParameters.base-url != null) {
"jetbrains.youtrack.baseUrl" = cfg.environmentalParameters.base-url;
})
{
"java.aws.headless" = "true";
"jetbrains.youtrack.disableBrowser" = "true";
}
];
extraAttr = lib.concatStringsSep " " (lib.mapAttrsToList (k: v: "-D${k}=${v}") (stdParams // cfg.extraParams));
in {
environment.HOME = cfg.statePath;
environment.YOUTRACK_JVM_OPTS = "${extraAttr}";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = with pkgs; [ unixtools.hostname ];
serviceConfig = {
Type = "simple";
User = "youtrack";
Group = "youtrack";
Restart = "on-failure";
ExecStart = ''${cfg.package}/bin/youtrack ${cfg.jvmOpts} ${cfg.environmentalParameters.listen-address}:${toString cfg.environmentalParameters.listen-port}'';
};
}; };
}; service_zip = let
jvmoptions = pkgs.writeTextFile {
name = "youtrack.jvmoptions";
text = (lib.concatStringsSep "\n" cfg.generalParameters);
};
package = cfg.package.override {
statePath = cfg.statePath;
};
in {
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = with pkgs; [ unixtools.hostname ];
preStart = ''
# This detects old (i.e. <= 2022.3) installations that were not migrated yet
# and migrates them to the new state directory style
if [[ -d ${cfg.statePath}/teamsysdata ]] && [[ ! -d ${cfg.statePath}/2022_3 ]]
then
mkdir -p ${cfg.statePath}/2022_3
mv ${cfg.statePath}/teamsysdata ${cfg.statePath}/2022_3
mv ${cfg.statePath}/.youtrack ${cfg.statePath}/2022_3
fi
mkdir -p ${cfg.statePath}/{backups,conf,data,logs,temp}
${pkgs.coreutils}/bin/ln -fs ${jvmoptions} ${cfg.statePath}/conf/youtrack.jvmoptions
${package}/bin/youtrack configure ${lib.concatStringsSep " " (lib.mapAttrsToList (name: value: "--${name}=${toString value}") cfg.environmentalParameters )}
'';
serviceConfig = lib.mkMerge [
{
Type = "simple";
User = "youtrack";
Group = "youtrack";
Restart = "on-failure";
ExecStart = "${package}/bin/youtrack run";
}
(lib.mkIf (cfg.statePath == "/var/lib/youtrack") {
StateDirectory = "youtrack";
})
];
};
in if (lib.versions.major cfg.package.version >= "2023") then service_zip else service_jar;
users.users.youtrack = { users.users.youtrack = {
description = "Youtrack service user"; description = "Youtrack service user";
@ -136,7 +230,7 @@ in
users.groups.youtrack = {}; users.groups.youtrack = {};
services.nginx = mkIf (cfg.virtualHost != null) { services.nginx = lib.mkIf (cfg.virtualHost != null) {
upstreams.youtrack.servers."${cfg.address}:${toString cfg.port}" = {}; upstreams.youtrack.servers."${cfg.address}:${toString cfg.port}" = {};
virtualHosts.${cfg.virtualHost}.locations = { virtualHosts.${cfg.virtualHost}.locations = {
"/" = { "/" = {
@ -166,9 +260,10 @@ in
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
''; '';
}; };
}; };
}; };
}; };
meta.doc = ./youtrack.md;
meta.maintainers = [ lib.maintainers.leona ];
} }