From 333ad51f5c7ee6f8d72f7194a95e473becaf90a0 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 17 Feb 2024 19:40:41 +0100 Subject: [PATCH 1/3] listmonk: 2.5.1 -> 3.0.0 listmonk switched their frontend toolchain to vite the existing past usage of yarn2nix did not work using the new toolchain setup. Therefore, I migrated the derivation to the "normal" yarn2nix. --- pkgs/servers/mail/listmonk/default.nix | 18 +++------ pkgs/servers/mail/listmonk/frontend.nix | 41 +++++++++------------ pkgs/servers/mail/listmonk/package.json | 49 ++++++++++++------------- 3 files changed, 46 insertions(+), 62 deletions(-) diff --git a/pkgs/servers/mail/listmonk/default.nix b/pkgs/servers/mail/listmonk/default.nix index 24f97afa348d..3ac3522a861e 100644 --- a/pkgs/servers/mail/listmonk/default.nix +++ b/pkgs/servers/mail/listmonk/default.nix @@ -1,25 +1,17 @@ -{ lib, buildGoModule, fetchFromGitHub, callPackage, stuffbin, nixosTests, fetchpatch }: +{ lib, buildGoModule, fetchFromGitHub, callPackage, stuffbin, nixosTests }: buildGoModule rec { pname = "listmonk"; - version = "2.5.1"; + version = "3.0.0"; src = fetchFromGitHub { owner = "knadh"; repo = "listmonk"; rev = "v${version}"; - sha256 = "sha256-gCnIblc83CmG1auvYYxqW/xBl6Oy1KHGkqSY/3yIm3I="; + sha256 = "sha256-eNX+2ens+mz2V8ZBHtFFHDVbi64AAiiREElMjh67Dd8="; }; - patches = [ - # Ensure that listmonk supports Go 1.20 - (fetchpatch { - url = "https://github.com/knadh/listmonk/commit/25513b81044803b104ada63c0be57a913960484e.patch"; - hash = "sha256-SYACM8r+NgeSWn9VJV4+wkm+6s/MhNGwn5zyc2tw7FU="; - }) - ]; - - vendorHash = "sha256-0sgC1+ueZTUCP+7JwI/OKLktfMHQq959GEk1mC0TQgE="; + vendorHash = "sha256-XAm2VfX1nHWTuAV2COEn8qrqPNv0xbaWgTYCpjrEfMw="; nativeBuildInputs = [ stuffbin @@ -50,7 +42,7 @@ buildGoModule rec { ''; passthru = { - frontend = callPackage ./frontend.nix { inherit meta; }; + frontend = callPackage ./frontend.nix { inherit meta version src; }; tests = { inherit (nixosTests) listmonk; }; }; diff --git a/pkgs/servers/mail/listmonk/frontend.nix b/pkgs/servers/mail/listmonk/frontend.nix index 647f5cfd9f6a..928092038c12 100644 --- a/pkgs/servers/mail/listmonk/frontend.nix +++ b/pkgs/servers/mail/listmonk/frontend.nix @@ -1,40 +1,33 @@ -{ yarn2nix-moretea -, fetchFromGitHub +{ mkYarnPackage , fetchYarnDeps , meta +, version +, src }: -yarn2nix-moretea.mkYarnPackage rec { +mkYarnPackage { pname = "listmonk-frontend"; - version = "2.5.1"; - - src = fetchFromGitHub { - owner = "knadh"; - repo = "listmonk"; - rev = "v${version}"; - sha256 = "sha256-gCnIblc83CmG1auvYYxqW/xBl6Oy1KHGkqSY/3yIm3I="; - }; + inherit version; + src = "${src}/frontend"; packageJSON = ./package.json; - yarnLock = "${src}/frontend/yarn.lock"; offlineCache = fetchYarnDeps { - inherit yarnLock; - hash = "sha256-KKNk4lrM7unMFClkY6F3nqhKx5xfx87Ac+rug9sOwvI="; + yarnLock = "${src}/frontend/yarn.lock"; + hash = "sha256-TdrglyRtb2Q8SFtoiCoDj/zBV2+7DwzIm/Fzlt0ZvSo="; }; - # For Node.js v17+, this is necessary. - NODE_OPTIONS = "--openssl-legacy-provider"; + configurePhase = '' + ln -s $node_modules node_modules + ''; + + buildPhase = '' + yarn --offline build + ''; installPhase = '' - runHook preInstall - - cd deps/listmonk-frontend/frontend - npm run build - - mv dist $out - - runHook postInstall + mkdir $out + cp -R dist/* $out ''; doDist = false; diff --git a/pkgs/servers/mail/listmonk/package.json b/pkgs/servers/mail/listmonk/package.json index 6e981fefc8b3..25018ef265dd 100644 --- a/pkgs/servers/mail/listmonk/package.json +++ b/pkgs/servers/mail/listmonk/package.json @@ -1,46 +1,45 @@ { - "name": "listmonk-frontend", + "name": "listmonk", "version": "0.1.0", "private": true, "scripts": { - "serve": "vue-cli-service serve", - "build": "vue-cli-service build", - "build-report": "vue-cli-service build --report", - "lint": "vue-cli-service lint" + "dev": "vite", + "build": "vite build", + "serve": "vite preview", + "lint": "eslint --ext .js,.vue --ignore-path .gitignore src", + "prebuild": "eslint --ext .js,.vue --ignore-path .gitignore src" }, "dependencies": { "@tinymce/tinymce-vue": "^3", - "axios": "^0.27.2", - "buefy": "^0.9.10", - "c3": "^0.7.20", + "axios": "^1.6.2", + "buefy": "^0.9.25", + "bulma": "^0.9.4", + "chart.js": "^4.4.1", "codeflask": "^1.4.1", - "core-js": "^3.12.1", - "dayjs": "^1.10.4", + "dayjs": "^1.11.10", "indent.js": "^0.3.5", "qs": "^6.10.1", "textversionjs": "^1.1.3", - "tinymce": "^5.10.7", - "turndown": "^7.0.0", - "vue": "^2.6.12", - "vue-i18n": "^8.22.2", + "tinymce": "^5.10.9", + "turndown": "^7.1.2", + "vue": "^2.7.14", + "vue-chartjs": "^5.3.0", + "vue-i18n": "^8.28.2", "vue-router": "^3.2.0", "vuex": "^3.6.2" }, "devDependencies": { - "@vue/cli-plugin-babel": "~5.0.8", - "@vue/cli-plugin-eslint": "~5.0.8", - "@vue/cli-plugin-router": "~5.0.8", - "@vue/cli-plugin-vuex": "~5.0.8", - "@vue/cli-service": "~5.0.8", - "@vue/eslint-config-airbnb": "^5.3.0", - "babel-eslint": "^10.1.0", - "cypress": "10.10.0", + "@vitejs/plugin-vue2": "^2.3.1", + "@vue/eslint-config-airbnb": "^7.0.1", + "cypress": "13.6.1", "cypress-file-upload": "^5.0.2", - "eslint": "^7.27.0", + "eslint": "^8.56.0", + "eslint-define-config": "^2.0.0", "eslint-plugin-import": "^2.23.3", - "eslint-plugin-vue": "^7.9.0", + "eslint-plugin-vue": "^9.19.2", "sass": "^1.34.0", - "sass-loader": "^10.2.0", + "vite": "^5.0.12", + "vue-eslint-parser": "^9.3.2", "vue-template-compiler": "^2.6.12" } } From 896a4d62d8c7e36ef19e2d40b6cc26adcc89fe03 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 17 Feb 2024 19:46:53 +0100 Subject: [PATCH 2/3] listmonk: ensure correct application of data migration --- nixos/modules/services/mail/listmonk.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/mail/listmonk.nix b/nixos/modules/services/mail/listmonk.nix index 945eb436c1f2..d6399304cc10 100644 --- a/nixos/modules/services/mail/listmonk.nix +++ b/nixos/modules/services/mail/listmonk.nix @@ -187,7 +187,11 @@ in { # Indeed, it will try to create all the folders and realize one of them already exist. # Therefore, we have to create it ourselves. ''${pkgs.coreutils}/bin/mkdir -p "''${STATE_DIRECTORY}/listmonk/uploads"'' - "${cfg.package}/bin/listmonk --config ${cfgFile} --idempotent --install --upgrade --yes" + # setup database if not already done + "${cfg.package}/bin/listmonk --config ${cfgFile} --idempotent --install --yes" + # apply db migrations (setup and migrations can not be done in one step + # with "--install --upgrade" listmonk ignores the upgrade) + "${cfg.package}/bin/listmonk --config ${cfgFile} --upgrade --yes" "${updateDatabaseConfigScript}/bin/update-database-config.sh" ]; ExecStart = "${cfg.package}/bin/listmonk --config ${cfgFile}"; From 1d399850788fb5d313ccee1309ccdd5c20225831 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 1 Mar 2024 10:47:33 +0100 Subject: [PATCH 3/3] listmonk: move to pkgs/by-name --- pkgs/{servers/mail => by-name/li}/listmonk/frontend.nix | 0 pkgs/{servers/mail => by-name/li}/listmonk/package.json | 0 .../listmonk/default.nix => by-name/li/listmonk/package.nix} | 0 pkgs/{servers/mail => by-name/li}/listmonk/stuffbin.nix | 0 pkgs/top-level/all-packages.nix | 2 -- 5 files changed, 2 deletions(-) rename pkgs/{servers/mail => by-name/li}/listmonk/frontend.nix (100%) rename pkgs/{servers/mail => by-name/li}/listmonk/package.json (100%) rename pkgs/{servers/mail/listmonk/default.nix => by-name/li/listmonk/package.nix} (100%) rename pkgs/{servers/mail => by-name/li}/listmonk/stuffbin.nix (100%) diff --git a/pkgs/servers/mail/listmonk/frontend.nix b/pkgs/by-name/li/listmonk/frontend.nix similarity index 100% rename from pkgs/servers/mail/listmonk/frontend.nix rename to pkgs/by-name/li/listmonk/frontend.nix diff --git a/pkgs/servers/mail/listmonk/package.json b/pkgs/by-name/li/listmonk/package.json similarity index 100% rename from pkgs/servers/mail/listmonk/package.json rename to pkgs/by-name/li/listmonk/package.json diff --git a/pkgs/servers/mail/listmonk/default.nix b/pkgs/by-name/li/listmonk/package.nix similarity index 100% rename from pkgs/servers/mail/listmonk/default.nix rename to pkgs/by-name/li/listmonk/package.nix diff --git a/pkgs/servers/mail/listmonk/stuffbin.nix b/pkgs/by-name/li/listmonk/stuffbin.nix similarity index 100% rename from pkgs/servers/mail/listmonk/stuffbin.nix rename to pkgs/by-name/li/listmonk/stuffbin.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5ece348a9304..28e5bdbcc809 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26344,8 +26344,6 @@ with pkgs; lighttpd = callPackage ../servers/http/lighttpd { }; - listmonk = callPackage ../servers/mail/listmonk { }; - linx-server = callPackage ../servers/web-apps/linx-server { }; livepeer = callPackage ../servers/livepeer { };