From 036bf4982a6cc2fc9deb17bfe938193bc4d16cce Mon Sep 17 00:00:00 2001 From: Jeff Slight Date: Thu, 19 Sep 2019 12:58:13 -0700 Subject: [PATCH 1/3] mattermost: 5.9.0 -> 5.15.0 --- pkgs/servers/mattermost/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/mattermost/default.nix b/pkgs/servers/mattermost/default.nix index 2919647e5734..00f74e7a01ec 100644 --- a/pkgs/servers/mattermost/default.nix +++ b/pkgs/servers/mattermost/default.nix @@ -1,7 +1,7 @@ { stdenv, fetchurl, fetchFromGitHub, buildGoPackage, buildEnv }: let - version = "5.9.0"; + version = "5.15.0"; mattermost-server = buildGoPackage rec { pname = "mattermost-server"; @@ -11,7 +11,7 @@ let owner = "mattermost"; repo = "mattermost-server"; rev = "v${version}"; - sha256 = "08h7n9smv6f1njazn4pl6pwkfmqxn93rzg69h6asicp9c4vad3m2"; + sha256 = "1bh53h0bmpc1qmnbpsmwkfrvj66z18m7b1xg7pqikid57ssqxjx9"; }; goPackagePath = "github.com/mattermost/mattermost-server"; @@ -29,7 +29,7 @@ let src = fetchurl { url = "https://releases.mattermost.com/${version}/mattermost-${version}-linux-amd64.tar.gz"; - sha256 = "19ys5mwmw99fbj44gd00vrl2qj09lrwvj1ihic0fsn6nd3hnx3mw"; + sha256 = "13xmc2y4pp0b0svzaf4v7ynx6rxcvznx3vqmlrpiil414s69xv45"; }; installPhase = '' From 366be2ea324571a7b40410e79d45e900ff6b0ae2 Mon Sep 17 00:00:00 2001 From: Jeff Slight Date: Thu, 19 Sep 2019 16:00:27 -0700 Subject: [PATCH 2/3] nixos/mattermost: unescape unicode characters in config.json --- nixos/modules/services/web-apps/mattermost.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/web-apps/mattermost.nix b/nixos/modules/services/web-apps/mattermost.nix index 8c7fc4056adc..97dc0dd3c66b 100644 --- a/nixos/modules/services/web-apps/mattermost.nix +++ b/nixos/modules/services/web-apps/mattermost.nix @@ -6,7 +6,9 @@ let cfg = config.services.mattermost; - defaultConfig = builtins.fromJSON (readFile "${pkgs.mattermost}/config/config.json"); + defaultConfig = builtins.fromJSON (builtins.replaceStrings [ "\\u0026" ] [ "&" ] + (readFile "${pkgs.mattermost}/config/config.json") + ); mattermostConf = foldl recursiveUpdate defaultConfig [ { ServiceSettings.SiteURL = cfg.siteUrl; From 346a6ce2653324a61a2855fffa30a8fba00fbdbb Mon Sep 17 00:00:00 2001 From: Jeff Slight Date: Fri, 20 Sep 2019 10:39:57 -0700 Subject: [PATCH 3/3] nixos/mattermost: use database config if set to immutable --- nixos/modules/services/web-apps/mattermost.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/web-apps/mattermost.nix b/nixos/modules/services/web-apps/mattermost.nix index 97dc0dd3c66b..e402f5ff843f 100644 --- a/nixos/modules/services/web-apps/mattermost.nix +++ b/nixos/modules/services/web-apps/mattermost.nix @@ -10,12 +10,14 @@ let (readFile "${pkgs.mattermost}/config/config.json") ); + database = "postgres://${cfg.localDatabaseUser}:${cfg.localDatabasePassword}@localhost:5432/${cfg.localDatabaseName}?sslmode=disable&connect_timeout=10"; + mattermostConf = foldl recursiveUpdate defaultConfig [ { ServiceSettings.SiteURL = cfg.siteUrl; ServiceSettings.ListenAddress = cfg.listenAddress; TeamSettings.SiteName = cfg.siteName; SqlSettings.DriverName = "postgres"; - SqlSettings.DataSource = "postgres://${cfg.localDatabaseUser}:${cfg.localDatabasePassword}@localhost:5432/${cfg.localDatabaseName}?sslmode=disable&connect_timeout=10"; + SqlSettings.DataSource = database; } cfg.extraConfig ]; @@ -177,7 +179,9 @@ in mkdir -p ${cfg.statePath}/{data,config,logs} ln -sf ${pkgs.mattermost}/{bin,fonts,i18n,templates,client} ${cfg.statePath} '' + lib.optionalString (!cfg.mutableConfig) '' - ln -sf ${mattermostConfJSON} ${cfg.statePath}/config/config.json + rm -f ${cfg.statePath}/config/config.json + cp ${mattermostConfJSON} ${cfg.statePath}/config/config.json + ${pkgs.mattermost}/bin/mattermost config migrate ${cfg.statePath}/config/config.json ${database} '' + lib.optionalString cfg.mutableConfig '' if ! test -e "${cfg.statePath}/config/.initial-created"; then rm -f ${cfg.statePath}/config/config.json @@ -203,7 +207,8 @@ in PermissionsStartOnly = true; User = cfg.user; Group = cfg.group; - ExecStart = "${pkgs.mattermost}/bin/mattermost"; + ExecStart = "${pkgs.mattermost}/bin/mattermost" + + (lib.optionalString (!cfg.mutableConfig) " -c ${database}"); WorkingDirectory = "${cfg.statePath}"; Restart = "always"; RestartSec = "10"; @@ -229,4 +234,3 @@ in }) ]; } -