From e5934da3112d0547de0de3eb4514d8a308780742 Mon Sep 17 00:00:00 2001 From: xeals Date: Fri, 12 Jan 2024 11:49:35 +1100 Subject: [PATCH] koillection: init at 1.5.2 --- .../ko/koillection/koillection-dirs.patch | 25 +++++++ pkgs/by-name/ko/koillection/package.nix | 69 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 pkgs/by-name/ko/koillection/koillection-dirs.patch create mode 100644 pkgs/by-name/ko/koillection/package.nix diff --git a/pkgs/by-name/ko/koillection/koillection-dirs.patch b/pkgs/by-name/ko/koillection/koillection-dirs.patch new file mode 100644 index 0000000..0783c31 --- /dev/null +++ b/pkgs/by-name/ko/koillection/koillection-dirs.patch @@ -0,0 +1,25 @@ +*** a/src/Kernel.php +--- b/src/Kernel.php +@@ -8,6 +8,21 @@ class Kernel extends BaseKernel + use Symfony\Component\HttpKernel\Kernel as BaseKernel; + + class Kernel extends BaseKernel + { + use MicroKernelTrait; ++ ++ public function getDataDir(): string ++ { ++ return '@dataDir@'; ++ } ++ ++ public function getCacheDir(): string ++ { ++ return $this->getDataDir() . '/var/cache/' . $this->getEnvironment(); ++ } ++ ++ public function getLogDir(): string ++ { ++ return $this->getDataDir() . '/var/logs'; ++ } + } + diff --git a/pkgs/by-name/ko/koillection/package.nix b/pkgs/by-name/ko/koillection/package.nix new file mode 100644 index 0000000..36ea623 --- /dev/null +++ b/pkgs/by-name/ko/koillection/package.nix @@ -0,0 +1,69 @@ +{ lib +, dataDir ? "/var/lib/koillection" + # REVIEW: This supposed to be aliased by the caller, which means it shouldn't + # go in by-name, I think. +, php83 +, fetchFromGitHub +, mkYarnPackage +, fetchYarnDeps +}: + +php83.buildComposerProject (finalAttrs: { + pname = "koillection"; + version = "1.5.2"; + + src = fetchFromGitHub { + owner = "benjaminjonard"; + repo = "koillection"; + rev = finalAttrs.version; + hash = "sha256-r2rkHhp0F5QfwJuKeu4UdPoluDXxpyhYpie1zUk1h5c="; + }; + + frontend = mkYarnPackage { + inherit (finalAttrs) pname version; + + src = "${finalAttrs.src}/assets"; + + offlineCache = fetchYarnDeps { + yarnLock = "${finalAttrs.src}/assets/yarn.lock"; + hash = ""; + }; + }; + + patches = [ + ./koillection-dirs.patch + ]; + + postPatch = '' + substituteInPlace src/Kernel.php \ + --replace "@dataDir@" "${dataDir}" + ''; + + # Lock file uses exact constraints, which Composer doesn't like. + composerStrictValidation = false; + # Actually installs plugins, i.e., Symfony. + composerNoPlugins = false; + vendorHash = "sha256-LU9ZN4qUNUpSBGH6AChw3qU4RjgsoPJmLL01FS7UKRQ="; + + postInstall = '' + local koillection_out=$out/share/php/koillection + + rm -R $koillection_out/public/uploads + ln -s ${dataDir}/.env $koillection_out/.env.local + ln -s ${dataDir}/public/uploads $koillection_out/public/uploads + + cp -r ${finalAttrs.frontend} assets/ + ''; + + passthru = { + phpPackage = php83; + }; + + meta = { + description = "Self-hosted service allowing users to manage any kind of collections"; + homepage = "https://github.com/benjaminjonard/koillection"; + license = lib.licenses.mit; + platforms = lib.platforms.unix; + broken = true; # Blocked on NixOS/nixpkgs#254369 + }; +})