diff --git a/nixos/tests/lemmy.nix b/nixos/tests/lemmy.nix index fb64daa80e64..b1a39827b072 100644 --- a/nixos/tests/lemmy.nix +++ b/nixos/tests/lemmy.nix @@ -26,6 +26,8 @@ in site_name = "Lemmy FTW"; admin_email = "mightyiam@example.com"; }; + # https://github.com/LemmyNet/lemmy/blob/50efb1d519c63a7007a07f11cc8a11487703c70d/crates/utils/src/settings/mod.rs#L52 + database.uri = "postgres:///lemmy?host=/run/postgresql&user=lemmy"; }; caddy.enable = true; }; diff --git a/pkgs/servers/web-apps/lemmy/package.json b/pkgs/servers/web-apps/lemmy/package.json index a01cf033df30..45d4daf16612 100644 --- a/pkgs/servers/web-apps/lemmy/package.json +++ b/pkgs/servers/web-apps/lemmy/package.json @@ -1,121 +1,134 @@ { "name": "lemmy-ui", + "version": "0.18.0", "description": "An isomorphic UI for lemmy", - "version": "0.17.4", - "author": "Dessalines ", + "repository": "https://github.com/LemmyNet/lemmy-ui", "license": "AGPL-3.0", + "author": "Dessalines ", "scripts": { + "prebuild:dev": "yarn clean && node generate_translations.js", "build:dev": "webpack --mode=development", + "prebuild:prod": "yarn clean && node generate_translations.js", "build:prod": "webpack --mode=production", "clean": "yarn run rimraf dist", "dev": "yarn start", - "lint": "node generate_translations.js && tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx src && prettier --check 'src/**/*.tsx'", - "prebuild:dev": "yarn clean && node generate_translations.js", - "prebuild:prod": "yarn clean && node generate_translations.js", + "lint": "yarn translations:generate && tsc --noEmit && eslint --report-unused-disable-directives --ext .js,.ts,.tsx \"src/**\" && prettier --check \"src/**/*.{ts,tsx,js,css,scss}\"", "prepare": "husky install", - "start": "yarn build:dev --watch" + "start": "yarn build:dev --watch", + "themes:build": "sass src/assets/css/themes/:src/assets/css/themes", + "themes:watch": "sass --watch src/assets/css/themes/:src/assets/css/themes", + "translations:generate": "node generate_translations.js", + "translations:init": "git submodule init && yarn translations:update", + "translations:update": "git submodule update --remote --recursive" }, - "repository": "https://github.com/LemmyNet/lemmy-ui", - "dependencies": { - "@babel/plugin-proposal-decorators": "^7.21.0", - "@babel/plugin-transform-runtime": "^7.21.0", - "@babel/plugin-transform-typescript": "^7.21.0", - "@babel/preset-env": "7.20.2", - "@babel/preset-typescript": "^7.21.0", - "@babel/runtime": "^7.21.0", - "autosize": "^6.0.1", - "babel-loader": "^9.1.2", - "babel-plugin-inferno": "^6.6.0", - "check-password-strength": "^2.0.7", - "choices.js": "^10.2.0", - "classnames": "^2.3.1", - "clean-webpack-plugin": "^4.0.0", - "copy-webpack-plugin": "^11.0.0", - "css-loader": "^6.7.3", - "emoji-short-name": "^2.0.0", - "express": "~4.18.2", - "html-to-text": "^9.0.4", - "i18next": "^22.4.10", - "inferno": "^8.0.6", - "inferno-create-element": "^8.0.6", - "inferno-helmet": "^5.2.1", - "inferno-hydrate": "^8.0.6", - "inferno-i18next-dess": "0.0.2", - "inferno-router": "^8.0.6", - "inferno-server": "^8.0.6", - "isomorphic-cookie": "^1.2.4", - "jwt-decode": "^3.1.2", - "lemmy-js-client": "0.17.2-rc.1", - "markdown-it": "^13.0.1", - "markdown-it-container": "^3.0.0", - "markdown-it-footnote": "^3.0.3", - "markdown-it-html5-embed": "^1.0.0", - "markdown-it-sub": "^1.0.0", - "markdown-it-sup": "^1.0.0", - "mini-css-extract-plugin": "^2.7.2", - "moment": "^2.29.4", - "node-fetch": "^2.6.1", - "register-service-worker": "^1.7.2", - "run-node-webpack-plugin": "^1.3.0", - "rxjs": "^7.8.0", - "sanitize-html": "^2.10.0", - "sass": "^1.58.3", - "sass-loader": "^13.2.0", - "serialize-javascript": "^6.0.1", - "tippy.js": "^6.3.7", - "toastify-js": "^1.12.0", - "tributejs": "^5.1.3", - "webpack": "5.75.0", - "webpack-cli": "^5.0.1", - "webpack-node-externals": "^3.0.0", - "websocket-ts": "^1.1.1" - }, - "devDependencies": { - "@babel/core": "^7.21.0", - "@types/autosize": "^4.0.0", - "@types/express": "^4.17.17", - "@types/html-to-text": "^9.0.0", - "@types/markdown-it": "^12.2.3", - "@types/markdown-it-container": "^2.0.5", - "@types/node": "^18.14.0", - "@types/node-fetch": "^2.6.2", - "@types/sanitize-html": "^2.8.0", - "@types/serialize-javascript": "^5.0.1", - "@types/toastify-js": "^1.11.1", - "@typescript-eslint/eslint-plugin": "^5.53.0", - "@typescript-eslint/parser": "^5.53.0", - "bootstrap": "^5.2.3", - "bootswatch": "^5.2.3", - "eslint": "^8.34.0", - "eslint-plugin-inferno": "^7.32.1", - "eslint-plugin-prettier": "^4.2.1", - "husky": "^8.0.3", - "import-sort-style-module": "^6.0.0", - "lint-staged": "^13.1.2", - "prettier": "^2.8.4", - "prettier-plugin-import-sort": "^0.0.7", - "prettier-plugin-organize-imports": "^3.2.2", - "prettier-plugin-packagejson": "^2.4.3", - "rimraf": "^4.1.2", - "sortpack": "^2.3.3", - "style-loader": "^3.3.1", - "terser": "^5.16.4", - "typescript": "^4.9.5", - "webpack-dev-server": "4.11.1" - }, - "engines": { - "node": ">=8.9.0" - }, - "engineStrict": true, "lint-staged": { "*.{ts,tsx,js}": [ "prettier --write", "eslint --fix" ], + "*.{css, scss}": [ + "prettier --write" + ], "package.json": [ "sortpack" ] }, + "dependencies": { + "@babel/plugin-proposal-decorators": "^7.21.0", + "@babel/plugin-transform-runtime": "^7.21.4", + "@babel/plugin-transform-typescript": "^7.21.3", + "@babel/preset-env": "7.21.5", + "@babel/preset-typescript": "^7.21.5", + "@babel/runtime": "^7.21.5", + "@emoji-mart/data": "^1.1.0", + "autosize": "^6.0.1", + "babel-loader": "^9.1.2", + "babel-plugin-inferno": "^6.6.0", + "bootstrap": "^5.2.3", + "check-password-strength": "^2.0.7", + "classnames": "^2.3.1", + "clean-webpack-plugin": "^4.0.0", + "copy-webpack-plugin": "^11.0.0", + "cross-fetch": "^3.1.5", + "css-loader": "^6.7.3", + "emoji-mart": "^5.4.0", + "emoji-short-name": "^2.0.0", + "express": "~4.18.2", + "history": "^5.3.0", + "html-to-text": "^9.0.5", + "i18next": "^22.4.15", + "inferno": "^8.1.1", + "inferno-create-element": "^8.1.1", + "inferno-helmet": "^5.2.1", + "inferno-hydrate": "^8.1.1", + "inferno-i18next-dess": "0.0.2", + "inferno-router": "^8.1.1", + "inferno-server": "^8.1.1", + "isomorphic-cookie": "^1.2.4", + "jwt-decode": "^3.1.2", + "lemmy-js-client": "0.18.0-rc.2", + "lodash": "^4.17.21", + "markdown-it": "^13.0.1", + "markdown-it-container": "^3.0.0", + "markdown-it-emoji": "^2.0.2", + "markdown-it-footnote": "^3.0.3", + "markdown-it-html5-embed": "^1.0.0", + "markdown-it-sub": "^1.0.0", + "markdown-it-sup": "^1.0.0", + "mini-css-extract-plugin": "^2.7.5", + "moment": "^2.29.4", + "register-service-worker": "^1.7.2", + "run-node-webpack-plugin": "^1.3.0", + "sanitize-html": "^2.10.0", + "sass": "^1.62.1", + "sass-loader": "^13.2.2", + "serialize-javascript": "^6.0.1", + "service-worker-webpack": "^1.0.0", + "sharp": "^0.32.1", + "tippy.js": "^6.3.7", + "toastify-js": "^1.12.0", + "tributejs": "^5.1.3", + "webpack": "5.82.1", + "webpack-cli": "^5.1.1", + "webpack-node-externals": "^3.0.0" + }, + "devDependencies": { + "@babel/core": "^7.21.8", + "@types/autosize": "^4.0.0", + "@types/bootstrap": "^5.2.6", + "@types/express": "^4.17.17", + "@types/html-to-text": "^9.0.0", + "@types/markdown-it": "^12.2.3", + "@types/markdown-it-container": "^2.0.5", + "@types/node": "^20.1.2", + "@types/sanitize-html": "^2.9.0", + "@types/serialize-javascript": "^5.0.1", + "@types/toastify-js": "^1.11.1", + "@typescript-eslint/eslint-plugin": "^5.59.5", + "@typescript-eslint/parser": "^5.59.5", + "eslint": "^8.40.0", + "eslint-plugin-inferno": "^7.32.2", + "eslint-plugin-jsx-a11y": "^6.7.1", + "eslint-plugin-prettier": "^4.2.1", + "husky": "^8.0.3", + "import-sort-style-module": "^6.0.0", + "lint-staged": "^13.2.2", + "prettier": "^2.8.8", + "prettier-plugin-import-sort": "^0.0.7", + "prettier-plugin-organize-imports": "^3.2.2", + "prettier-plugin-packagejson": "^2.4.3", + "rimraf": "^5.0.0", + "sortpack": "^2.3.4", + "style-loader": "^3.3.2", + "terser": "^5.17.3", + "typescript": "^5.0.4", + "webpack-dev-server": "4.15.0" + }, + "packageManager": "yarn@1.22.19", + "engines": { + "node": ">=8.9.0" + }, + "engineStrict": true, "importSort": { ".js, .jsx, .ts, .tsx": { "style": "module", diff --git a/pkgs/servers/web-apps/lemmy/pin.json b/pkgs/servers/web-apps/lemmy/pin.json index 59f6c0c8f01d..8522dbb7e015 100644 --- a/pkgs/servers/web-apps/lemmy/pin.json +++ b/pkgs/servers/web-apps/lemmy/pin.json @@ -1,7 +1,7 @@ { - "version": "0.17.4", - "serverSha256": "sha256-nztT6o5Tur64dMWII+wf5CBVJBJ59MGXKdS5OJO0SSc=", - "serverCargoSha256": "sha256-3In2W+cSVtMkaKrn1hWOVL/V/qkKlH30qGPi3rNdpQI=", - "uiSha256": "sha256-Ebc4VzuCJhPoO16qCgSVyYFXH7YcymxcGcN/Sgyg5Gs=", - "uiYarnDepsSha256": "sha256-aZAclSaFZJvuK+FpCBWboGaVEOEJTxq2jnWk0A6iAFw=" + "version": "0.18.0", + "serverSha256": "sha256-KzEelj2/+wfp570Vw1+FoqiYZd1PxELTdopGSeel97E=", + "serverCargoSha256": "sha256-p1ZytuaXouKFkKjsEsaNjndoioTSVVM2pf72qE8/qyM=", + "uiSha256": "sha256-pB6uEL9gDwvsi+FbooKBhTCJ+Qmc6Vl2bBTMiL1hUJI=", + "uiYarnDepsSha256": "sha256-NtluS6Cr39L9nGwNA17c7xsM5xoJraS02a7sp7r9KPI=" } diff --git a/pkgs/servers/web-apps/lemmy/server.nix b/pkgs/servers/web-apps/lemmy/server.nix index 2917d660ba94..d37e18224a77 100644 --- a/pkgs/servers/web-apps/lemmy/server.nix +++ b/pkgs/servers/web-apps/lemmy/server.nix @@ -26,6 +26,15 @@ rustPlatform.buildRustPackage rec { fetchSubmodules = true; }; + patches = [ + # `cargo test` fails as `tokio::test` relies on the macros feature which wasn't specified in Cargo.toml + ./tokio-macros.patch + ]; + + preConfigure = '' + echo 'pub const VERSION: &str = "${version}";' > crates/utils/src/version.rs + ''; + cargoSha256 = pinData.serverCargoSha256; buildInputs = [ postgresql ] diff --git a/pkgs/servers/web-apps/lemmy/tokio-macros.patch b/pkgs/servers/web-apps/lemmy/tokio-macros.patch new file mode 100644 index 000000000000..a37f0835d1cc --- /dev/null +++ b/pkgs/servers/web-apps/lemmy/tokio-macros.patch @@ -0,0 +1,37 @@ +From f8c83b48774d152f9bc590db83c032235ef502a9 Mon Sep 17 00:00:00 2001 +From: Jan Klass +Date: Sat, 24 Jun 2023 17:57:59 +0200 +Subject: [PATCH] test: Fix missing tokio test macro dependency + +The tests make use of the `#[tokio::test]` macro, but the tokio dependency default feature does not include them. Running cargo test fails. + +By including the `macros` feature on the tokio dependency, cargo test will work. + +--- + +cargo test fails with + +``` +error[E0433]: failed to resolve: could not find `test` in `tokio` + --> src\scheduled_tasks.rs:295:12 + | +295 | #[tokio::test] + | ^^^^ could not find `test` in `tokio` +``` +--- + Cargo.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Cargo.toml b/Cargo.toml +index 430deb082c..d4c5ab8ef0 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -89,7 +89,7 @@ anyhow = "1.0.71" + diesel_ltree = "0.3.0" + typed-builder = "0.10.0" + serial_test = "0.9.0" +-tokio = "1.28.2" ++tokio = { version = "1.28.2", features = ["macros"] } + sha2 = "0.10.6" + regex = "1.8.4" + once_cell = "1.18.0" diff --git a/pkgs/servers/web-apps/lemmy/ui.nix b/pkgs/servers/web-apps/lemmy/ui.nix index 6213b246f30f..3377b54c861f 100644 --- a/pkgs/servers/web-apps/lemmy/ui.nix +++ b/pkgs/servers/web-apps/lemmy/ui.nix @@ -7,6 +7,8 @@ , fetchFromGitHub , fetchYarnDeps , nixosTests +, vips +, nodePackages }: let @@ -21,6 +23,13 @@ let rm build/config.gypi ''; }; + sharp = { + nativeBuildInputs = [ pkg-config nodePackages.semver ]; + buildInputs = [ vips ]; + postInstall = '' + yarn --offline run install + ''; + }; }; name = "lemmy-ui"; @@ -55,6 +64,7 @@ mkYarnPackage { export HOME=$PWD/yarn_home ln -sf $PWD/node_modules $PWD/deps/lemmy-ui/ + echo 'export const VERSION = "${version}";' > $PWD/deps/lemmy-ui/src/shared/version.ts yarn --offline build:prod '';