Skip to content

Commit

Permalink
Merge pull request #328479 from NixOS/backport-322199-to-release-24.05
Browse files Browse the repository at this point in the history
[Backport release-24.05] firefly-iii: Streamlined Derivation
  • Loading branch information
drupol authored Jul 19, 2024
2 parents 069ceb6 + 14fdb87 commit 74435c9
Showing 1 changed file with 50 additions and 19 deletions.
69 changes: 50 additions & 19 deletions pkgs/by-name/fi/firefly-iii/package.nix
Original file line number Diff line number Diff line change
@@ -1,52 +1,83 @@
{ lib
, fetchFromGitHub
, buildNpmPackage
, stdenvNoCC
, nodejs
, fetchNpmDeps
, buildPackages
, php83
, nixosTests
, nix-update-script
, dataDir ? "/var/lib/firefly-iii"
}:

let
pname = "firefly-iii";
version = "6.1.18";
phpPackage = php83;
npmDepsHash = "sha256-MoxkNxfVeIFkiNVzfehQ9FpC65kBj8ZmvwaRf4MVRIg=";

src = fetchFromGitHub {
owner = "firefly-iii";
repo = "firefly-iii";
rev = "v${version}";
hash = "sha256-mA7gvKhHouUUz1Aix7253O/+VcufoEFwdcJeZxnazEo=";
};

assets = buildNpmPackage {
pname = "${pname}-assets";
inherit version src;
npmDepsHash = "sha256-MoxkNxfVeIFkiNVzfehQ9FpC65kBj8ZmvwaRf4MVRIg=";
dontNpmBuild = true;
installPhase = ''
runHook preInstall
npm run prod --workspace=v1
npm run build --workspace=v2
cp -r ./public $out/
runHook postInstall
'';
};
in

phpPackage.buildComposerProject (finalAttrs: {
stdenvNoCC.mkDerivation (finalAttrs: {
inherit pname src version;

buildInputs = [ phpPackage ];

nativeBuildInputs = [
nodejs
nodejs.python
buildPackages.npmHooks.npmConfigHook
phpPackage.composerHooks.composerInstallHook
phpPackage.packages.composer-local-repo-plugin
];

composerNoDev = true;
composerNoPlugins = true;
composerNoScripts = true;
composerStrictValidation = true;
strictDeps = true;

vendorHash = "sha256-EpMypgj6lZDz6T94bGoCUH9IVwh7VB4Ds08AcCsreRw=";

npmDeps = fetchNpmDeps {
inherit src;
name = "${pname}-npm-deps";
hash = npmDepsHash;
};

composerRepository = phpPackage.mkComposerRepository {
inherit (finalAttrs)
pname
src
vendorHash
version
;
composerNoDev = true;
composerNoPlugins = true;
composerNoScripts = true;
composerStrictValidation = true;
};

preInstall = ''
npm run prod --workspace=v1
npm run build --workspace=v2
'';

passthru = {
inherit phpPackage;
tests = nixosTests.firefly-iii;
updateScript = nix-update-script { };
};

postInstall = ''
mv $out/share/php/${pname}/* $out/
rm -R $out/share $out/storage $out/bootstrap/cache $out/public
cp -a ${assets} $out/public
rm -R $out/share $out/storage $out/bootstrap/cache $out/node_modules
ln -s ${dataDir}/storage $out/storage
ln -s ${dataDir}/cache $out/bootstrap/cache
'';
Expand All @@ -56,6 +87,6 @@ phpPackage.buildComposerProject (finalAttrs: {
description = "Firefly III: a personal finances manager";
homepage = "https://github.com/firefly-iii/firefly-iii";
license = lib.licenses.agpl3Only;
maintainers = [ lib.maintainers.savyajha ];
maintainers = [ lib.maintainers.savyajha lib.maintainers.patrickdag ];
};
})

0 comments on commit 74435c9

Please sign in to comment.