lemmy: use pin.json to prepare for update script

lemmy: add initial update script

lemmy: remove use of upstream package.json

lemmy: add update script

lemmy: fixes

lemmy: use importJSON

lemmy: use correct import json ref
This commit is contained in:
happysalada 2021-10-29 10:07:48 +09:00 committed by Raphael Megzari
parent 9a3e6e2253
commit f1d3cdcf58
5 changed files with 66 additions and 124 deletions

View File

@ -1,113 +0,0 @@
{
"name": "lemmy-ui",
"version": "0.12.2",
"description": "An isomorphic UI for lemmy",
"author": "Dessalines <tyhou13@gmx.com>",
"license": "AGPL-3.0",
"scripts": {
"build:dev": "webpack --mode=development",
"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",
"prebuild:dev": "yarn clean && node generate_translations.js",
"prebuild:prod": "yarn clean && node generate_translations.js",
"start": "yarn build:dev --watch"
},
"repository": "https://github.com/LemmyNet/lemmy-ui",
"dependencies": {
"@typescript-eslint/parser": "^4.28.3",
"autosize": "^5.0.1",
"choices.js": "^9.0.1",
"emoji-short-name": "^1.0.0",
"express": "~4.17.1",
"i18next": "^20.3.3",
"inferno": "^7.4.9",
"inferno-create-element": "^7.4.9",
"inferno-helmet": "^5.2.1",
"inferno-hydrate": "^7.4.9",
"inferno-i18next": "github:nimbusec-oss/inferno-i18next#semver:^7.4.2",
"inferno-router": "^7.4.9",
"inferno-server": "^7.4.9",
"isomorphic-cookie": "^1.2.4",
"jwt-decode": "^3.1.2",
"markdown-it": "^12.1.0",
"markdown-it-container": "^3.0.0",
"markdown-it-sub": "^1.0.0",
"markdown-it-sup": "^1.0.0",
"moment": "^2.29.1",
"reconnecting-websocket": "^4.4.0",
"register-service-worker": "^1.7.2",
"rxjs": "^7.2.0",
"serialize-javascript": "^6.0.0",
"tippy.js": "^6.3.1",
"toastify-js": "^1.11.1",
"tributejs": "^5.1.3",
"ws": "^8.2.0"
},
"devDependencies": {
"@babel/core": "^7.14.6",
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/plugin-transform-typescript": "^7.14.6",
"@babel/preset-env": "7.15.0",
"@babel/preset-typescript": "^7.14.5",
"@babel/runtime": "^7.14.6",
"@types/autosize": "^4.0.0",
"@types/express": "^4.17.13",
"@types/node": "^16.7.1",
"@types/node-fetch": "^2.5.11",
"@types/serialize-javascript": "^5.0.1",
"@typescript-eslint/eslint-plugin": "^4.28.3",
"babel-loader": "^8.2.2",
"babel-plugin-inferno": "^6.3.0",
"bootstrap": "^5.0.2",
"bootswatch": "^5.0.2",
"clean-webpack-plugin": "^4.0.0-alpha.0",
"copy-webpack-plugin": "^9.0.1",
"css-loader": "^6.0.0",
"eslint": "^7.30.0",
"eslint-plugin-prettier": "^3.4.1",
"husky": "^7.0.1",
"import-sort-style-module": "^6.0.0",
"iso-639-1": "^2.1.9",
"lemmy-js-client": "0.12.0",
"lint-staged": "^11.0.1",
"mini-css-extract-plugin": "^2.1.0",
"node-fetch": "^2.6.1",
"node-sass": "^6.0.1",
"prettier": "^2.3.2",
"prettier-plugin-import-sort": "^0.0.7",
"prettier-plugin-organize-imports": "^2.2.0",
"prettier-plugin-packagejson": "^2.2.11",
"rimraf": "^3.0.2",
"run-node-webpack-plugin": "^1.3.0",
"sass-loader": "^12.1.0",
"sortpack": "^2.2.0",
"style-loader": "^3.1.0",
"terser": "^5.7.1",
"typescript": "^4.3.5",
"webpack": "5.51.1",
"webpack-cli": "^4.7.2",
"webpack-dev-server": "4.0.0",
"webpack-node-externals": "^3.0.0"
},
"engines": {
"node": ">=8.9.0"
},
"engineStrict": true,
"lint-staged": {
"*.{ts,tsx,js}": [
"prettier --write",
"eslint --fix"
],
"package.json": [
"sortpack"
]
},
"importSort": {
".js, .jsx, .ts, .tsx": {
"style": "module",
"parser": "typescript"
}
}
}

View File

@ -0,0 +1,7 @@
{
"version": "0.12.2",
"serverSha256": "sha256-jhUpQ2f+b0BEXVfQOIujxam2PQA44wluUraJVJxL6LU=",
"serverCargoSha256": "sha256-2i8zCwd33LtUKxOChx/SLP9sWMRmxGkKK8xzaJImMHM=",
"uiSha256": "sha256-iFLJqUnz4m9/JTSaJSUugzY5KkiKtH0sMYY4ALm2Ebk=",
"uiYarnDepsSha256": "sha256-i12J+Qi7Nsjr5JipeRXdkFkh+I/ROsgRw4Vty2cMNyU="
}

View File

@ -7,19 +7,22 @@
, libiconv
, Security
}:
let
pinData = lib.importJSON ./pin.json;
version = pinData.version;
in
rustPlatform.buildRustPackage rec {
inherit version;
pname = "lemmy-server";
version = "0.12.2";
src = fetchFromGitHub {
owner = "LemmyNet";
repo = "lemmy";
rev = version;
sha256 = "sha256-jhUpQ2f+b0BEXVfQOIujxam2PQA44wluUraJVJxL6LU=";
sha256 = pinData.serverSha256;
};
cargoSha256 = "sha256-2i8zCwd33LtUKxOChx/SLP9sWMRmxGkKK8xzaJImMHM=";
cargoSha256 = pinData.serverCargoSha256;
buildInputs = [ postgresql ]
++ lib.optionals stdenv.isDarwin [ libiconv Security ];
@ -31,6 +34,8 @@ rustPlatform.buildRustPackage rec {
OPENSSL_LIB_DIR = "${openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${openssl.dev}/include";
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "🐀 Building a federated alternative to reddit in rust";
homepage = "https://join-lemmy.org/";

View File

@ -9,6 +9,8 @@
}:
let
pinData = lib.importJSON ./pin.json;
pkgConfig = {
node-sass = {
nativeBuildInputs = [ ];
@ -21,14 +23,14 @@ let
};
name = "lemmy-ui";
version = "0.12.2";
version = pinData.version;
src = fetchFromGitHub {
owner = "LemmyNet";
repo = name;
rev = version;
fetchSubmodules = true;
sha256 = "sha256-iFLJqUnz4m9/JTSaJSUugzY5KkiKtH0sMYY4ALm2Ebk=";
sha256 = pinData.uiSha256;
};
in
mkYarnPackage {
@ -39,13 +41,9 @@ mkYarnPackage {
offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
sha256 = "sha256-i12J+Qi7Nsjr5JipeRXdkFkh+I/ROsgRw4Vty2cMNyU=";
sha256 = pinData.uiYarnDepsSha256;
};
# Fails mysteriously on source/package.json
# Upstream package.json is missing a newline at the end
packageJSON = ./package.json;
yarnPreBuild = ''
export npm_config_nodedir=${nodejs}
'';
@ -67,6 +65,8 @@ mkYarnPackage {
distPhase = "true";
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "Building a federated alternative to reddit in rust";
homepage = "https://join-lemmy.org/";

View File

@ -0,0 +1,43 @@
#!/usr/bin/env nix-shell
#! nix-shell -i oil -p jq sd nix-prefetch-github ripgrep moreutils
# TODO set to `verbose` or `extdebug` once implemented in oil
shopt --set xtrace
var directory = $(dirname $0 | xargs realpath)
var owner = "LemmyNet"
var ui_repo = "lemmy-ui"
var server_repo = "lemmy"
var latest_rev = $(curl -q https://api.github.com/repos/${owner}/${server_repo}/releases/latest | \
jq -r '.tag_name')
var latest_version = $(echo $latest_rev)
var current_version = $(jq -r '.version' $directory/pin.json)
if ($latest_version === $current_version) {
echo "lemmy is already up-to-date"
return 0
} else {
var server_tarball_meta = $(nix-prefetch-github $owner $server_repo --rev "$latest_rev")
var server_tarball_hash = "sha256-$(echo $server_tarball_meta | jq -r '.sha256')"
var ui_tarball_meta = $(nix-prefetch-github $owner $ui_repo --rev "$latest_rev")
var ui_tarball_hash = "sha256-$(echo $ui_tarball_meta | jq -r '.sha256')"
jq ".version = \"$latest_version\" | \
.\"serverSha256\" = \"$server_tarball_hash\" | \
.\"uiSha256\" = \"$ui_tarball_hash\" | \
.\"serverCargoSha256\" = \"\" | \
.\"uiYarnDepsSha256\" = \"\"" $directory/pin.json | sponge $directory/pin.json
var new_cargo_sha256 = $(nix-build -A lemmy-server 2>&1 | \
tail -n 2 | \
head -n 1 | \
sd '\s+got:\s+' '')
var new_offline_cache_sha256 = $(nix-build -A lemmy-ui 2>&1 | \
tail -n 2 | \
head -n 1 | \
sd '\s+got:\s+' '')
jq ".\"serverCargoSha256\" = \"$new_cargo_sha256\" | \
.\"uiYarnDepsSha256\" = \"$new_offline_cache_sha256\"" \
$directory/pin.json | sponge $directory/pin.json
}