Unverified Commit dacfc810 authored by Jonas Heinrich's avatar Jonas Heinrich Committed by GitHub
Browse files

invoiceplane: Build from source (#353783)

parents f5c96024 19ce591f
Loading
Loading
Loading
Loading
+74 −15
Original line number Diff line number Diff line
{ lib, stdenv, fetchurl, unzip, nixosTests }:
{
  lib,
  fetchFromGitHub,
  nixosTests,
  fetchYarnDeps,
  nodejs,
  php,
  yarnConfigHook,
  yarnBuildHook,
  yarnInstallHook,
  nodePackages,
  python3,
  pkg-config,
  libsass,
  stdenv,
}:

stdenv.mkDerivation rec {
php.buildComposerProject (finalAttrs: {
  pname = "invoiceplane";
  version = "1.6.1";

  src = fetchurl {
    url = "https://github.com/InvoicePlane/InvoicePlane/releases/download/v${version}/v${version}.zip";
    hash = "sha256-66vXxE4pTUMkmPalLgJrCt2pl2BSWOJ3tiJ5K5wspYY=";
  src = fetchFromGitHub {
    owner = "InvoicePlane";
    repo = "InvoicePlane";
    rev = "refs/tags/v${finalAttrs.version}";
    hash = "sha256-rVt3HkAh3zBVwt1a4ZGiuC/Khvb3Ugk42hT5mul4qRA=";
  };

  nativeBuildInputs = [ unzip ];
  vendorHash = "sha256-qYjNn7VQGkUfJ74coUpUOfAOkgi3eLoo/ITpcOcTenk=";

  sourceRoot = ".";
  buildInputs = [ libsass ];

  installPhase = ''
    mkdir -p $out/
    cp -r ip/. $out/
  nativeBuildInputs = [
    yarnConfigHook
    yarnBuildHook
    yarnInstallHook
    # Needed for executing package.json scripts
    nodePackages.grunt-cli
    pkg-config
    (python3.withPackages (ps: with ps; [ distutils ]))
    stdenv.cc
  ];

  offlineCache = fetchYarnDeps {
    yarnLock = ./yarn.lock;
    hash = "sha256-t9GYFqKY3YZ/l5LZXIHIgehgvxIbMMuYLwXvvdQaryM=";
  };

  # Upstream yarn.lock and package.json out of sync
  # https://github.com/InvoicePlane/InvoicePlane/issues/1109
  preConfigure = ''
    cp ${./yarn.lock} ./yarn.lock
  '';

  # Upstream composer.json file is missing the name, description and license fields
  composerStrictValidation = false;

  postBuild = ''
    # Building node-sass dependency
    mkdir -p "$HOME/.node-gyp/${nodejs.version}"
    echo 9 >"$HOME/.node-gyp/${nodejs.version}/installVersion"
    ln -sfv "${nodejs}/include" "$HOME/.node-gyp/${nodejs.version}"
    export npm_config_nodedir=${nodejs}

    pushd node_modules/node-sass
    LIBSASS_EXT=auto yarn run build --offline
    popd

    # Running package.json scripts
    grunt build
  '';

  # Cleanup
  postInstall = ''
    mv $out/share/php/invoiceplane/* $out/
    rm -r $out/{composer.json,composer.lock,CONTRIBUTING.md,docker-compose.yml,Gruntfile.js,package.json,node_modules,yarn.lock,share}
  '';

  passthru.tests = {
    inherit (nixosTests) invoiceplane;
  };

  meta = with lib; {
  meta = {
    description = "Self-hosted open source application for managing your invoices, clients and payments";
    license = licenses.mit;
    changelog = "https://github.com/InvoicePlane/InvoicePlane/releases/tag/v${finalAttrs.version}";
    homepage = "https://www.invoiceplane.com";
    platforms = platforms.all;
    maintainers = with maintainers; [ onny ];
    license = lib.licenses.mit;
    platforms = lib.platforms.all;
    maintainers = with lib.maintainers; [ onny ];
  };
}
})
+2614 −0

File added.

Preview size limit exceeded, changes collapsed.