diff --git a/pkgs/by-name/gr/grav/01-nix.patch b/pkgs/by-name/gr/grav/01-nix.patch new file mode 100644 index 000000000000..31d38e1ba3d4 --- /dev/null +++ b/pkgs/by-name/gr/grav/01-nix.patch @@ -0,0 +1,36 @@ +diff -Nurp grav-src/system/src/Grav/Common/Cache.php grav-src-nixos/system/src/Grav/Common/Cache.php +--- grav-src/system/src/Grav/Common/Cache.php 1970-01-01 01:00:01.000000000 +0100 ++++ grav-src-nixos/system/src/Grav/Common/Cache.php 2024-11-22 15:46:47.481175690 +0100 +@@ -517,7 +517,7 @@ class Cache extends Getters + + $output[] = ''; + +- if (($remove === 'all' || $remove === 'standard') && file_exists($user_config)) { ++ if (($remove === 'all' || $remove === 'standard') && file_exists($user_config) && is_writable($user_config)) { + touch($user_config); + + $output[] = 'Touched: ' . $user_config; +@@ -544,7 +544,7 @@ class Cache extends Getters + { + $user_config = USER_DIR . 'config/system.yaml'; + +- if (file_exists($user_config)) { ++ if (file_exists($user_config) && is_writable($user_config)) { + touch($user_config); + } + +diff -Nurp grav-src/system/src/Grav/Console/Gpm/SelfupgradeCommand.php grav-src-nixos/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +--- grav-src/system/src/Grav/Console/Gpm/SelfupgradeCommand.php 1970-01-01 01:00:01.000000000 +0100 ++++ grav-src-nixos/system/src/Grav/Console/Gpm/SelfupgradeCommand.php 2024-11-22 16:05:13.752536788 +0100 +@@ -94,6 +94,11 @@ class SelfupgradeCommand extends GpmComm + $input = $this->getInput(); + $io = $this->getIO(); + ++ # Adopted from Arch package. ++ $io->error('Grav cannot be upgraded this way as it has been installed with a distribution package.'); ++ $io->writeln('Use Nix to upgrade.'); ++ return 1; ++ + if (!class_exists(ZipArchive::class)) { + $io->title('GPM Self Upgrade'); + $io->error('php-zip extension needs to be enabled!'); diff --git a/pkgs/by-name/gr/grav/package.nix b/pkgs/by-name/gr/grav/package.nix new file mode 100644 index 000000000000..6818d77f0501 --- /dev/null +++ b/pkgs/by-name/gr/grav/package.nix @@ -0,0 +1,38 @@ +{ + stdenvNoCC, + lib, + fetchzip, +}: + +let + version = "1.7.48"; +in +stdenvNoCC.mkDerivation { + pname = "grav"; + inherit version; + + src = fetchzip { + url = "https://github.com/getgrav/grav/releases/download/${version}/grav-admin-v${version}.zip"; + hash = "sha256-e8WpdO0n3pY4Ajs1fvMkMI+CrR6uMitswvYS5rxal4g="; + }; + + patches = [ + # Disables functionality that attempts to edit files in Nix store. Also adds + # a block of the self-upgrade command. + ./01-nix.patch + ]; + + installPhase = '' + runHook preInstall + mkdir -p $out/ + cp -R . $out/ + runHook postInstall + ''; + + meta = with lib; { + description = "Fast, simple, and flexible, file-based web platform"; + homepage = "https://getgrav.com"; + maintainers = with maintainers; [ rycee ]; + license = licenses.mit; + }; +}