diff --git a/flake.lock b/flake.lock index 11cf819..c272251 100644 --- a/flake.lock +++ b/flake.lock @@ -57,31 +57,31 @@ "mattermost-server": { "flake": false, "locked": { - "lastModified": 1707502341, - "narHash": "sha256-eloO83koCNZOR/NYzUCdKOtVdF7rk+VrZ9U2bKWkxNU=", + "lastModified": 1707498729, + "narHash": "sha256-w+VF8VoS7oIcDlYS5kCFzSX4rgD9l1B99XBHeJDB6JI=", "owner": "mattermost", - "repo": "mattermost-server", - "rev": "674f549daf0e74933845be0ae32827e498137b63", + "repo": "mattermost", + "rev": "e9f10761eef2f9ed83fcf0be8205424bcc8df9f3", "type": "github" }, "original": { "owner": "mattermost", - "ref": "v8.1.10", - "repo": "mattermost-server", + "ref": "v9.5.1", + "repo": "mattermost", "type": "github" } }, "mattermost-webapp": { "flake": false, "locked": { - "lastModified": 1707771700, - "narHash": "sha256-5PYPNcUGcQmn9RgUbtv3U/s+pRB1a2CgZwxDnunuToA=", + "lastModified": 1707772650, + "narHash": "sha256-zOHWY0T1eM0PKBcNhAtMK3sNCYkSnmH7+o4aVu34dKg=", "type": "tarball", - "url": "https://releases.mattermost.com/8.1.10/mattermost-8.1.10-linux-amd64.tar.gz" + "url": "https://releases.mattermost.com/9.5.1/mattermost-9.5.1-linux-amd64.tar.gz" }, "original": { "type": "tarball", - "url": "https://releases.mattermost.com/8.1.10/mattermost-8.1.10-linux-amd64.tar.gz" + "url": "https://releases.mattermost.com/9.5.1/mattermost-9.5.1-linux-amd64.tar.gz" } }, "nixos-mailserver": { @@ -162,6 +162,21 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1708475490, + "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0e74ca98a74bc7270d28838369593635a5db3260", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1708294118, @@ -201,6 +216,7 @@ "nixos-mailserver": "nixos-mailserver", "nixpkgs": "nixpkgs_2", "nixpkgs-oldstable": "nixpkgs-oldstable", + "nixpkgs-unstable": "nixpkgs-unstable", "sops-nix": "sops-nix", "tracktrain": "tracktrain" } diff --git a/flake.nix b/flake.nix index b986d53..8261d6b 100644 --- a/flake.nix +++ b/flake.nix @@ -2,12 +2,13 @@ description = "hacc infra stuff"; inputs = { - mattermost-webapp.url = "https://releases.mattermost.com/8.1.10/mattermost-8.1.10-linux-amd64.tar.gz"; + mattermost-webapp.url = "https://releases.mattermost.com/9.5.1/mattermost-9.5.1-linux-amd64.tar.gz"; mattermost-webapp.flake = false; - mattermost-server.url = "github:mattermost/mattermost-server?ref=v8.1.10"; + mattermost-server.url = "github:mattermost/mattermost?ref=v9.5.1"; mattermost-server.flake = false; nixpkgs.url = "nixpkgs/nixos-23.11"; + nixpkgs-unstable.url = "nixpkgs/nixos-unstable"; nixpkgs-oldstable.url = "github:/NixOS/nixpkgs?rev=c4aec3c021620d98861639946123214207e98344"; nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-23.11"; diff --git a/parsons/forgejo.nix b/parsons/forgejo.nix index 001bd63..898e5a9 100644 --- a/parsons/forgejo.nix +++ b/parsons/forgejo.nix @@ -6,6 +6,7 @@ hostAddress = "192.168.100.1"; localAddress = "192.168.100.10"; autoStart = true; + ephemeral = true; bindMounts = { "/persist" = { hostPath = "/persist/containers/gitea"; diff --git a/parsons/hedgedoc-hacc.nix b/parsons/hedgedoc-hacc.nix index 533cd54..35462f2 100644 --- a/parsons/hedgedoc-hacc.nix +++ b/parsons/hedgedoc-hacc.nix @@ -11,6 +11,7 @@ hostAddress = "192.168.100.1"; localAddress = "192.168.100.5"; autoStart = true; + ephemeral = true; bindMounts = { "/persist" = { hostPath = "/persist/containers/pad-hacc"; diff --git a/parsons/hedgedoc-i4f.nix b/parsons/hedgedoc-i4f.nix index 1e65359..97ca2ce 100644 --- a/parsons/hedgedoc-i4f.nix +++ b/parsons/hedgedoc-i4f.nix @@ -6,6 +6,7 @@ hostAddress = "192.168.100.1"; localAddress = "192.168.100.6"; autoStart = true; + ephemeral = true; bindMounts = { "/persist" = { hostPath = "/persist/containers/pad-i4f"; diff --git a/parsons/mattermost.nix b/parsons/mattermost.nix index 1f46059..890d16a 100644 --- a/parsons/mattermost.nix +++ b/parsons/mattermost.nix @@ -10,6 +10,7 @@ privateNetwork = true; hostAddress = "192.168.100.1"; localAddress = "192.168.100.3"; + ephemeral = true; bindMounts = { "/persist" = { diff --git a/parsons/nextcloud.nix b/parsons/nextcloud.nix index 1130ea7..85bfcb6 100644 --- a/parsons/nextcloud.nix +++ b/parsons/nextcloud.nix @@ -6,6 +6,7 @@ privateNetwork = true; hostAddress = "192.168.100.1"; localAddress = "192.168.100.2"; + ephemeral = true; bindMounts = { "/persist" = { hostPath = "/persist/containers/nextcloud"; diff --git a/parsons/tracktrain.nix b/parsons/tracktrain.nix index 0440e57..c1ae335 100644 --- a/parsons/tracktrain.nix +++ b/parsons/tracktrain.nix @@ -45,6 +45,7 @@ in hostAddress = "192.168.42.40"; localAddress = "192.168.42.41"; autoStart = true; + ephemeral = true; bindMounts = { "/persist" = { hostPath = "/persist/containers/tracktrain"; diff --git a/parsons/uffd.nix b/parsons/uffd.nix index c7cbbef..b2d2048 100644 --- a/parsons/uffd.nix +++ b/parsons/uffd.nix @@ -6,6 +6,7 @@ hostAddress = "192.168.100.1"; localAddress = "192.168.100.9"; autoStart = true; + ephemeral = true; bindMounts = { "/persist" = { hostPath = "/persist/containers/uffd"; diff --git a/pkgs/default.nix b/pkgs/default.nix index 3c14078..ea2c71b 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -3,12 +3,16 @@ let pkgs = import sources.nixpkgs args; oldstable = import sources.nixpkgs-oldstable args; + unstable = import sources.nixpkgs-unstable args; callPackage = pkgs.lib.callPackageWith (pkgs // newpkgs); newpkgs = { - mattermost = callPackage ./mattermost.nix {inherit sources;}; + mattermost = callPackage ./mattermost.nix { + inherit sources; + buildGoModule = unstable.buildGo122Module; + }; tracktrain = import sources.tracktrain { nixpkgs = pkgs; diff --git a/pkgs/mattermost.nix b/pkgs/mattermost.nix index 0bea4d8..5fa8508 100644 --- a/pkgs/mattermost.nix +++ b/pkgs/mattermost.nix @@ -1,65 +1,74 @@ -{ stdenv, fetchurl, fetchFromGitHub, buildGoModule, buildEnv, lib, sources }: +{ lib +, sources +, buildGoModule +, fetchFromGitHub +, nix-update-script +, fetchurl +, nixosTests +}: -let - version = "8.1.10"; +buildGoModule rec { + pname = "mattermost"; + # ESR releases only. + # See https://docs.mattermost.com/upgrade/extended-support-release.html + # When a new ESR version is available (e.g. 8.1.x -> 9.5.x), update + # the version regex in passthru.updateScript as well. + version = "9.5.1"; - mattermost-server = buildGoModule rec { - pname = "mattermost-server"; - inherit version; + src = sources.mattermost-server; + webapp = sources.mattermost-webapp; - src = "${sources.mattermost-server}/server"; - - # TODO: this should not be needed after the next update, assuming they don't - # again push a release without running `go mod tidy` - overrideModAttrs = (_: { - preBuild = '' - go mod tidy - ''; - }); - - vendorHash = "sha256-ZbLSxG9Gyhk7PBC2V6sMtrQNXvm+ugMfliFIHWO1VLs="; - - subPackages = [ "cmd/mattermost" ]; - - ldflags = [ - "-s" - "-w" - "-X github.com/mattermost/mattermost/server/public/model.Version=${version}" - "-X github.com/mattermost/mattermost/server/public/model.BuildNumber=${version}-haccfiles" - "-X github.com/mattermost/mattermost/server/public/model.BuildDate=1970-01-01" - "-X github.com/mattermost/mattermost/server/public/model.BuildHash=v${version}" - "-X github.com/mattermost/mattermost/server/public/model.BuildHashEnterprise=none" - "-X github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady=false" - "-X github.com/mattermost/mattermost/server/public/model.MockCWS=false" - ]; - }; - - mattermost-webapp = stdenv.mkDerivation { - pname = "mattermost-webapp"; - inherit version; - - src = sources.mattermost-webapp; - - installPhase = '' - mkdir -p $out - cp -r client $out - cp -r i18n $out - cp -r fonts $out - cp -r templates $out - cp -r config $out + # Needed because buildGoModule does not support go workspaces yet. + # We use go 1.22's workspace vendor command, which is not yet available + # in the default version of go used in nixpkgs, nor is it used by upstream: + # https://github.com/mattermost/mattermost/issues/26221#issuecomment-1945351597 + overrideModAttrs = (_: { + buildPhase = '' + make setup-go-work + go work vendor -e ''; + }); + + vendorHash = "sha256-TJCtgNf56A1U0EbV5gXjTro+YudVBRWiSZoBC3nJxnE="; + + modRoot = "./server"; + preBuild = '' + make setup-go-work + ''; + + subPackages = [ "cmd/mattermost" "cmd/mmctl" ]; + + tags = [ "production" ]; + + ldflags = [ + "-s" + "-w" + "-X github.com/mattermost/mattermost/server/public/model.Version=${version}" + "-X github.com/mattermost/mattermost/server/public/model.BuildNumber=${version}-nixpkgs" + "-X github.com/mattermost/mattermost/server/public/model.BuildDate=1970-01-01" + "-X github.com/mattermost/mattermost/server/public/model.BuildHash=v${version}" + "-X github.com/mattermost/mattermost/server/public/model.BuildHashEnterprise=none" + "-X github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady=false" + ]; + + postInstall = '' + cp -r $webapp/{client,i18n,fonts,templates,config} $out + # For some reason a bunch of these files are executable + find $out/{client,i18n,fonts,templates,config} -type f -exec chmod -x {} \; + ''; + + passthru = { + updateScript = nix-update-script { + extraArgs = [ "--version-regex" "^v(9\.5\.([0-9.]+))" ]; + }; + tests.mattermost = nixosTests.mattermost; }; -in - buildEnv { - name = "mattermost-${version}"; - paths = [ mattermost-server mattermost-webapp ]; - - meta = with lib; { - description = "Open-source, self-hosted Slack-alternative"; - homepage = "https://www.mattermost.org"; - license = with licenses; [ agpl3 asl20 ]; - maintainers = with maintainers; [ fpletz ryantm ]; - platforms = platforms.unix; - }; - } + meta = with lib; { + description = "Mattermost is an open source platform for secure collaboration across the entire software development lifecycle"; + homepage = "https://www.mattermost.org"; + license = with licenses; [ agpl3 asl20 ]; + maintainers = with maintainers; [ ryantm numinit kranzes mgdelacroix ]; + mainProgram = "mattermost"; + }; +}