ntfy-sh: build and package web UI and docs

Fixes #188695
This commit is contained in:
Arjan Schrijver 2022-09-28 14:55:48 +02:00 committed by Winter
parent d967f5daf5
commit 0b2e48b4c1
6 changed files with 12777 additions and 2 deletions

View file

@ -1,5 +1,11 @@
{ lib, buildGoModule, fetchFromGitHub }:
{ lib, pkgs, nodejs, stdenv, buildGoModule, fetchFromGitHub, debianutils, mkdocs, python3, python3Packages }:
let
nodeDependencies = (import ./node-composition.nix {
inherit pkgs nodejs;
inherit (stdenv.hostPlatform) system;
}).nodeDependencies;
in
buildGoModule rec {
pname = "ntfy-sh";
version = "1.28.0";
@ -15,8 +21,22 @@ buildGoModule rec {
doCheck = false;
nativeBuildInputs = [
debianutils
mkdocs
nodejs
python3
python3Packages.mkdocs-material
python3Packages.mkdocs-minify
];
postPatch = ''
sed -i 's# /bin/echo# echo#' Makefile
'';
preBuild = ''
make cli-deps-static-sites
ln -s ${nodeDependencies}/lib/node_modules web/node_modules
DISABLE_ESLINT_PLUGIN=true npm_config_offline=true make web-build docs-build
'';
meta = with lib; {

View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
ROOT="$(realpath "$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")"/../../../..)"
$(nix-build $ROOT -A nodePackages.node2nix --no-out-link)/bin/node2nix \
--nodejs-14 \
--node-env ../../../development/node-packages/node-env.nix \
--development \
--lock ./package-lock-temp.json \
--output node-packages.nix \
--composition node-composition.nix

View file

@ -0,0 +1,17 @@
# This file has been generated by node2nix 1.11.1. Do not edit!
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-14_x"}:
let
nodeEnv = import ../../../development/node-packages/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
}

12660
pkgs/tools/misc/ntfy-sh/node-packages.nix generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,43 @@
{
"name": "ntfy",
"version": "1.0.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"dependencies": {
"@emotion/react": "^11.8.2",
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.4.2",
"@mui/material": "latest",
"dexie": "^3.2.1",
"dexie-react-hooks": "^1.1.1",
"i18next": "^21.6.14",
"i18next-browser-languagedetector": "^6.1.4",
"i18next-http-backend": "^1.4.0",
"js-base64": "^3.7.2",
"react": "latest",
"react-dom": "latest",
"react-i18next": "^11.16.2",
"react-infinite-scroll-component": "^6.1.0",
"react-router-dom": "^6.2.2",
"react-scripts": "^5.0.0",
"stacktrace-gps": "^3.0.4",
"stacktrace-js": "^2.0.2"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View file

@ -0,0 +1,24 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nodePackages.node2nix curl jq nix
set -euo pipefail
# cd to the folder containing this script
cd "$(dirname "$0")"
CURRENT_VERSION=$(nix-instantiate ../../../../. --eval --strict -A ntfy-sh.version | tr -d '"')
TARGET_VERSION="$(curl -sL https://api.github.com/repos/binwiederhier/ntfy/releases/latest | jq --exit-status -r ".tag_name")"
if [[ "v$CURRENT_VERSION" == "$TARGET_VERSION" ]]; then
echo "ntfy-sh is up-to-date: ${CURRENT_VERSION}"
exit 0
fi
echo "ntfy-sh: $CURRENT_VERSION -> $TARGET_VERSION"
rm -f package.json package-lock.json
curl -sLO https://github.com/binwiederhier/ntfy/raw/$TARGET_VERSION/web/package.json
curl -sL -o package-lock-temp.json https://github.com/binwiederhier/ntfy/raw/$TARGET_VERSION/web/package-lock.json
./generate-dependencies.sh
rm ./package-lock-temp.json