From 10e92c1832132e1a52735508ccdcdd8728f21884 Mon Sep 17 00:00:00 2001 From: Nico Felbinger Date: Sat, 14 Dec 2024 22:24:02 +0100 Subject: [PATCH 1/2] part-db: init at 1.14.5 Co-authored-by: Sandro <7258858+supersandro2000@users.noreply.github.com> Co-authored-by: Tert0 <62036464+tert0@users.noreply.github.com> --- .../pa/part-db/fix-composer-validate.diff | 24 +++++ pkgs/by-name/pa/part-db/package.nix | 90 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 pkgs/by-name/pa/part-db/fix-composer-validate.diff create mode 100644 pkgs/by-name/pa/part-db/package.nix diff --git a/pkgs/by-name/pa/part-db/fix-composer-validate.diff b/pkgs/by-name/pa/part-db/fix-composer-validate.diff new file mode 100644 index 00000000000000..73060f3e059179 --- /dev/null +++ b/pkgs/by-name/pa/part-db/fix-composer-validate.diff @@ -0,0 +1,24 @@ +diff --git a/composer.json b/composer.json +index 0659f2ee..5a2dee70 100644 +--- a/composer.json ++++ b/composer.json +@@ -1,4 +1,6 @@ + { ++ "name": "part-db/part-db-server", ++ "description": "Part-DB is an Open source inventory management system for your electronic components", + "type": "project", + "license": "AGPL-3.0-or-later", + "require": { +diff --git a/composer.lock b/composer.lock +index 614a35f7..e0c949eb 100644 +--- a/composer.lock ++++ b/composer.lock +@@ -4,7 +4,7 @@ + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], +- "content-hash": "465fa2ab7f9f8dad2b8cfbeaa640c136", ++ "content-hash": "cec123f8cbf51820ba08c5c69ec2ded4", + "packages": [ + { + "name": "amphp/amp", diff --git a/pkgs/by-name/pa/part-db/package.nix b/pkgs/by-name/pa/part-db/package.nix new file mode 100644 index 00000000000000..1d00c12f4228fe --- /dev/null +++ b/pkgs/by-name/pa/part-db/package.nix @@ -0,0 +1,90 @@ +{ + stdenv, + php, + lib, + fetchFromGitHub, + fetchYarnDeps, + nodejs, + yarnConfigHook, + yarnBuildHook, + yarnInstallHook, + envLocalPath ? "/var/lib/part-db/env.local", + cachePath ? "/var/cache/part-db/", + logPath ? "/var/log/part-db/", +}: +let + pname = "part-db"; + version = "1.14.5"; + + srcWithVendor = php.buildComposerProject ({ + inherit pname version; + + src = fetchFromGitHub { + owner = "Part-DB"; + repo = "Part-DB-server"; + tag = "v${version}"; + hash = "sha256-KtNWog4aSnmgJsFckDuBrlnd9cj1f8kmSFi+nv2cZOg="; + }; + + patches = [ + ./fix-composer-validate.diff + ]; + + php = php.buildEnv { + extensions = ( + { enabled, all }: + enabled + ++ (with all; [ + xsl + ]) + ); + }; + + vendorHash = "sha256-PJtm/3Vdm2zomUklVMKlDAe/vziJN4e+JNNf/u8N3B4="; + + composerNoPlugins = false; + + postInstall = '' + mv "$out"/share/php/part-db/* $out/ + mv "$out"/share/php/part-db/.* $out/ + cd $out/ + php -d memory_limit=256M bin/console cache:warmup + ''; + }); +in +stdenv.mkDerivation (finalAttrs: { + inherit pname version; + + src = srcWithVendor; + + yarnOfflineCache = fetchYarnDeps { + yarnLock = finalAttrs.src + "/yarn.lock"; + hash = "sha256-Mjss2UUHVUdJ4UAI3GkG6HB6g7LbJTqvgrIXFhZmw1Q="; + }; + + nativeBuildInputs = [ + yarnConfigHook + yarnBuildHook + nodejs + ]; + + installPhase = '' + rm -r node_modules + mkdir $out + mv * .* $out/ + + rm -rf $out/var/{cache,log} + ln -s ${envLocalPath} $out/.env.local + ln -s ${logPath} $out/var/log + ln -s ${cachePath} $out/var/cache + ''; + + meta = { + description = "Open source inventory management system for your electronic components"; + homepage = "https://docs.part-db.de/"; + changelog = "https://github.com/Part-DB/Part-DB-server/releases/tag/v${version}"; + license = lib.licenses.agpl3Plus; + maintainers = with lib.maintainers; [ felbinger ]; + platforms = lib.platforms.linux; + }; +}) From c4568961089f5d3448a4348612ae5377e4883a90 Mon Sep 17 00:00:00 2001 From: Nico Felbinger Date: Sat, 14 Dec 2024 22:47:08 +0100 Subject: [PATCH 2/2] nixos/part-db: init module Co-authored-by: Sandro <7258858+supersandro2000@users.noreply.github.com> Co-authored-by: Tert0 <62036464+tert0@users.noreply.github.com> --- nixos/modules/module-list.nix | 1 + nixos/modules/services/web-apps/part-db.nix | 247 ++++++++++++++++++++ 2 files changed, 248 insertions(+) create mode 100644 nixos/modules/services/web-apps/part-db.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 6408c97d222f8b..06b7abc8fc0f63 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1493,6 +1493,7 @@ ./services/web-apps/gotify-server.nix ./services/web-apps/gotosocial.nix ./services/web-apps/grocy.nix + ./services/web-apps/part-db.nix ./services/web-apps/pixelfed.nix ./services/web-apps/goatcounter.nix ./services/web-apps/guacamole-client.nix diff --git a/nixos/modules/services/web-apps/part-db.nix b/nixos/modules/services/web-apps/part-db.nix new file mode 100644 index 00000000000000..c165969aa620c8 --- /dev/null +++ b/nixos/modules/services/web-apps/part-db.nix @@ -0,0 +1,247 @@ +{ + pkgs, + config, + lib, + ... +}: +let + cfg = config.services.part-db; + pkg = cfg.package; + + inherit (lib) + mkEnableOption + mkPackageOption + mkOption + types + mkIf + ; +in +{ + meta.maintainers = with lib.maintainers; [ felbinger ]; + + options.services.part-db = { + enable = mkEnableOption "PartDB"; + + package = mkPackageOption pkgs "part-db" { }; + + phpPackage = mkPackageOption pkgs "php" { } // { + apply = + pkg: + pkg.override { + extraConfig = '' + memory_limit = 256M; + ''; + }; + }; + + enableNginx = mkOption { + type = types.bool; + default = true; + description = '' + Whether to enable nginx or not. If enabled, an nginx virtual host will + be created for access to part-db. If not enabled, then you may use + `''${config.services.part-db.package}/public` as your document root in + whichever webserver you wish to setup. + ''; + }; + + enablePostgresql = mkOption { + type = types.bool; + default = true; + description = '' + Whether to configure the postgresql database for part-db. If enabled, + a database and user will be created for part-db. + ''; + }; + + virtualHost = mkOption { + type = types.str; + default = "localhost"; + description = '' + The virtualHost at which you wish part-db to be served. + ''; + }; + + poolConfig = lib.mkOption { + type = lib.types.attrsOf ( + lib.types.oneOf [ + lib.types.str + lib.types.int + lib.types.bool + ] + ); + default = { }; + defaultText = '' + { + "pm" = "dynamic"; + "pm.max_children" = 32; + "pm.start_servers" = 2; + "pm.min_spare_servers" = 2; + "pm.max_spare_servers" = 4; + "pm.max_requests" = 500; + } + ''; + description = '' + Options for the PartDB PHP pool. See the documentation on php-fpm.conf + for details on configuration directives. + ''; + }; + + settings = lib.mkOption { + default = { }; + description = '' + Options for part-db configuration. Refer to + for + details on supported values. All