mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 02:41:35 +01:00
Put nix package derivations in separate file and join symlinks
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
pkgs,
|
||||
lib,
|
||||
modulesPath,
|
||||
localArchtikaPackage,
|
||||
...
|
||||
}:
|
||||
{
|
||||
@@ -42,6 +43,7 @@
|
||||
|
||||
services.archtika = {
|
||||
enable = true;
|
||||
package = localArchtikaPackage;
|
||||
jwtSecret = "test-secret";
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
archtikaPackages,
|
||||
...
|
||||
}:
|
||||
|
||||
@@ -15,6 +14,8 @@ in
|
||||
options.services.archtika = {
|
||||
enable = mkEnableOption "archtika service";
|
||||
|
||||
package = mkPackageOption pkgs "archtika" { };
|
||||
|
||||
user = mkOption {
|
||||
type = types.str;
|
||||
default = "archtika";
|
||||
@@ -78,7 +79,7 @@ in
|
||||
script = ''
|
||||
${pkgs.postgresql_16}/bin/psql postgres://postgres@localhost:5432/${cfg.databaseName} -c "ALTER DATABASE ${cfg.databaseName} SET \"app.jwt_secret\" TO '${cfg.jwtSecret}'"
|
||||
|
||||
${pkgs.dbmate}/bin/dbmate --url postgres://postgres@localhost:5432/archtika?sslmode=disable --migrations-dir ${archtikaPackages.api}/migrations up
|
||||
${pkgs.dbmate}/bin/dbmate --url postgres://postgres@localhost:5432/archtika?sslmode=disable --migrations-dir ${cfg.package}/rest-api/db/migrations up
|
||||
|
||||
PGRST_SERVER_PORT=${toString cfg.port} PGRST_DB_SCHEMAS="api" PGRST_DB_ANON_ROLE="anon" PGRST_OPENAPI_MODE="ignore-privileges" PGRST_DB_URI="postgres://authenticator@localhost:5432/${cfg.databaseName}" PGRST_JWT_SECRET="${cfg.jwtSecret}" ${pkgs.postgrest}/bin/postgrest
|
||||
'';
|
||||
@@ -96,7 +97,7 @@ in
|
||||
};
|
||||
|
||||
script = ''
|
||||
ORIGIN=http://localhost:${toString cfg.webAppPort} PORT=${toString cfg.webAppPort} ${pkgs.nodejs_22}/bin/node ${archtikaPackages.web}
|
||||
ORIGIN=http://localhost:${toString cfg.webAppPort} PORT=${toString cfg.webAppPort} ${pkgs.nodejs_22}/bin/node ${cfg.package}/web-app
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
50
nix/package.nix
Normal file
50
nix/package.nix
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
buildNpmPackage,
|
||||
symlinkJoin,
|
||||
}:
|
||||
|
||||
let
|
||||
pname = "archtika";
|
||||
version = "1.0.0";
|
||||
|
||||
web = buildNpmPackage {
|
||||
inherit pname version;
|
||||
name = "archtika-web-app";
|
||||
src = ../web-app;
|
||||
npmDepsHash = "sha256-DmIII/x5ANlEpKtnZC/JlbVAvhbgnSiNn8hkj+qVCZY=";
|
||||
npmFlags = [ "--legacy-peer-deps" ];
|
||||
installPhase = ''
|
||||
mkdir -p $out/web-app
|
||||
cp package.json $out/web-app
|
||||
cp -r node_modules $out/web-app
|
||||
cp -r build/* $out/web-app
|
||||
'';
|
||||
};
|
||||
|
||||
api = stdenv.mkDerivation {
|
||||
inherit pname version;
|
||||
name = "archtika-api";
|
||||
src = ../rest-api;
|
||||
installPhase = ''
|
||||
mkdir -p $out/rest-api/db/migrations
|
||||
cp -r db/migrations/* $out/rest-api/db/migrations
|
||||
'';
|
||||
};
|
||||
in
|
||||
symlinkJoin {
|
||||
name = pname;
|
||||
paths = [
|
||||
web
|
||||
api
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "A modern, performant and lightweight CMS";
|
||||
homepage = "https://archtika.com";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ thiloho ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user