freshrss: patchShebangs instead of specifying interpreter at use site

this makes it easier for one to manually administer freshrss.
for example, i can import OPML from the CLI like:

```
$ nix build .#freshrss
$ freshrss FRESHRSS_DATA_PATH=/var/lib/freshrss ./result/cli/import-for-user.php --user admin --file my-opml.opml
```

whereas previously i would have needed to include
`environment.systemPackages = [ php ];` in my system for that to work.
This commit is contained in:
colin 2022-10-13 21:46:04 -07:00
parent b4facda895
commit 9443d83e6f
2 changed files with 19 additions and 7 deletions

View File

@ -238,17 +238,17 @@ in
# do installation or reconfigure
if test -f ${cfg.dataDir}/config.php; then
# reconfigure with settings
${pkgs.php}/bin/php ./cli/reconfigure.php ${settingsFlags}
${pkgs.php}/bin/php ./cli/update-user.php --user ${cfg.defaultUser} --password "$(cat ${cfg.passwordFile})"
./cli/reconfigure.php ${settingsFlags}
./cli/update-user.php --user ${cfg.defaultUser} --password "$(cat ${cfg.passwordFile})"
else
# Copy the user data template directory
cp -r ./data ${cfg.dataDir}
# check correct folders in data folder
${pkgs.php}/bin/php ./cli/prepare.php
./cli/prepare.php
# install with settings
${pkgs.php}/bin/php ./cli/do-install.php ${settingsFlags}
${pkgs.php}/bin/php ./cli/create-user.php --user ${cfg.defaultUser} --password "$(cat ${cfg.passwordFile})"
./cli/do-install.php ${settingsFlags}
./cli/create-user.php --user ${cfg.defaultUser} --password "$(cat ${cfg.passwordFile})"
fi
'';
};
@ -267,7 +267,7 @@ in
Group = "freshrss";
StateDirectory = "freshrss";
WorkingDirectory = cfg.package;
ExecStart = "${pkgs.php}/bin/php ./app/actualize_script.php";
ExecStart = "./app/actualize_script.php";
} // systemd-hardening;
};
};

View File

@ -1,4 +1,10 @@
{ stdenvNoCC, lib, fetchFromGitHub, nixosTests, pkgs }:
{ stdenvNoCC
, lib
, fetchFromGitHub
, nixosTests
, php
, pkgs
}:
stdenvNoCC.mkDerivation rec {
pname = "FreshRSS";
@ -13,6 +19,8 @@ stdenvNoCC.mkDerivation rec {
passthru.tests = nixosTests.freshrss;
buildInputs = [ php ];
# There's nothing to build.
dontBuild = true;
@ -22,6 +30,10 @@ stdenvNoCC.mkDerivation rec {
define('DATA_PATH', getenv('FRESHRSS_DATA_PATH'));
'';
postPatch = ''
patchShebangs cli/*.php app/actualize_script.php
'';
installPhase = ''
mkdir -p $out
cp -vr * $out/