mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-13 17:27:36 +00:00
artalk: build frontend from source (#357762)
This commit is contained in:
commit
8f34efc81a
@ -135,7 +135,7 @@ in {
|
||||
archi = handleTest ./archi.nix {};
|
||||
aria2 = handleTest ./aria2.nix {};
|
||||
armagetronad = handleTest ./armagetronad.nix {};
|
||||
artalk = handleTest ./artalk.nix {};
|
||||
artalk = runTest ./artalk.nix;
|
||||
atd = handleTest ./atd.nix {};
|
||||
atop = handleTest ./atop.nix {};
|
||||
atticd = runTest ./atticd.nix;
|
||||
|
@ -1,28 +1,56 @@
|
||||
import ./make-test-python.nix (
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
{ lib, pkgs, ... }:
|
||||
{
|
||||
|
||||
name = "artalk";
|
||||
name = "artalk";
|
||||
|
||||
meta = {
|
||||
maintainers = with lib.maintainers; [ moraxyc ];
|
||||
};
|
||||
meta = {
|
||||
maintainers = with lib.maintainers; [ moraxyc ];
|
||||
};
|
||||
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [ pkgs.curl ];
|
||||
services.artalk = {
|
||||
enable = true;
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [
|
||||
pkgs.curl
|
||||
pkgs.artalk
|
||||
pkgs.sudo
|
||||
];
|
||||
services.artalk = {
|
||||
enable = true;
|
||||
settings = {
|
||||
cache.enabled = true;
|
||||
admin_users = [
|
||||
{
|
||||
name = "admin";
|
||||
email = "admin@example.org";
|
||||
# md5 for 'password'
|
||||
password = "(md5)5F4DCC3B5AA765D61D8327DEB882CF99";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("artalk.service")
|
||||
testScript = ''
|
||||
import json
|
||||
machine.wait_for_unit("artalk.service")
|
||||
|
||||
machine.wait_for_open_port(23366)
|
||||
machine.wait_for_open_port(23366)
|
||||
|
||||
machine.succeed("curl --fail --max-time 10 http://127.0.0.1:23366/")
|
||||
'';
|
||||
}
|
||||
)
|
||||
assert '${pkgs.artalk.version}' in machine.succeed("curl --fail --max-time 10 http://127.0.0.1:23366/api/v2/version")
|
||||
|
||||
# Get token
|
||||
result = json.loads(machine.succeed("""
|
||||
curl --fail -X POST --json '{
|
||||
"email": "admin@example.org",
|
||||
"password": "password"
|
||||
}' 'http://127.0.0.1:23366/api/v2/auth/email/login'
|
||||
"""))
|
||||
token = result['token']
|
||||
|
||||
# Test admin
|
||||
machine.succeed(f"""
|
||||
curl --fail -X POST --header 'Authorization: {token}' 'http://127.0.0.1:23366/api/v2/cache/flush'
|
||||
""")
|
||||
'';
|
||||
}
|
||||
|
@ -2,28 +2,68 @@
|
||||
lib,
|
||||
buildGoModule,
|
||||
fetchFromGitHub,
|
||||
artalk,
|
||||
fetchurl,
|
||||
nodejs,
|
||||
pnpm_9,
|
||||
installShellFiles,
|
||||
versionCheckHook,
|
||||
stdenv,
|
||||
testers,
|
||||
nixosTests,
|
||||
}:
|
||||
buildGoModule rec {
|
||||
|
||||
let
|
||||
pname = "artalk";
|
||||
version = "2.9.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ArtalkJS";
|
||||
repo = "artalk";
|
||||
rev = "refs/tags/v${version}";
|
||||
tag = "v${version}";
|
||||
hash = "sha256-gzagE3muNpX/dwF45p11JAN9ElsGXNFQ3fCvF1QhvdU=";
|
||||
};
|
||||
web = fetchurl {
|
||||
url = "https://github.com/${src.owner}/${src.repo}/releases/download/v${version}/artalk_ui.tar.gz";
|
||||
hash = "sha256-ckKC4lErKVdJuJ+pGysmMR96a9LkrCYnWB4j6VPP8OY=";
|
||||
};
|
||||
|
||||
frontend = stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "${pname}-frontend";
|
||||
|
||||
inherit src version;
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs
|
||||
pnpm_9.configHook
|
||||
];
|
||||
|
||||
pnpmDeps = pnpm_9.fetchDeps {
|
||||
inherit (finalAttrs) pname version src;
|
||||
hash = "sha256-QIfadS2gNPtH006O86EndY/Hx2ml2FoKfUXJF5qoluw=";
|
||||
};
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
pnpm build:all
|
||||
pnpm build:auth
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/{dist/{i18n,plugins},sidebar}
|
||||
|
||||
# dist
|
||||
cp ./ui/artalk/dist/{Artalk,ArtalkLite}.{css,js} $out/dist
|
||||
cp ./ui/artalk/dist/i18n/*.js $out/dist/i18n
|
||||
cp ./ui/plugin-*/dist/*.js $out/dist/plugins
|
||||
|
||||
# sidebar
|
||||
cp -r ./ui/artalk-sidebar/dist/* $out/sidebar
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
});
|
||||
in
|
||||
buildGoModule {
|
||||
inherit src pname version;
|
||||
|
||||
vendorHash = "sha256-oAqYQzOUjly97H5L5PQ9I2SO2KqiUVxdJA+eoPrHD6Q=";
|
||||
|
||||
@ -33,8 +73,7 @@ buildGoModule rec {
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
tar -xzf ${web}
|
||||
cp -r ./artalk_ui/* ./public
|
||||
cp -r ${frontend}/* ./public
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
@ -47,13 +86,9 @@ buildGoModule rec {
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
versionCheckProgramArg = "-v";
|
||||
|
||||
nativeInstallCheckInputs = [
|
||||
versionCheckHook
|
||||
];
|
||||
|
||||
passthru.tests = {
|
||||
inherit (nixosTests) artalk;
|
||||
};
|
||||
@ -63,10 +98,6 @@ buildGoModule rec {
|
||||
homepage = "https://github.com/ArtalkJS/Artalk";
|
||||
changelog = "https://github.com/ArtalkJS/Artalk/releases/tag/v${version}";
|
||||
license = lib.licenses.mit;
|
||||
sourceProvenance = with lib.sourceTypes; [
|
||||
fromSource
|
||||
binaryBytecode
|
||||
];
|
||||
maintainers = with lib.maintainers; [ moraxyc ];
|
||||
mainProgram = "artalk";
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user