aboutsummaryrefslogtreecommitdiff
path: root/pkgs/webapps/grocy/default.nix
blob: f87f6ec0df20672dcac2ed16b0c497e366934eaa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ varDir ? "/var/lib/grocy", stdenv, callPackage, composerEnv, fetchurl, mylibs, runCommand, git, which, jq, yarn2nix-moretea }:
let
  version = "2.6.1-1";
  packagesource = mylibs.fetchedGithub ./grocy.json;
  patchedPackages = stdenv.mkDerivation (packagesource // rec {
    buildInputs = [ jq ];
    patches = [ ./yarn.patch ];
    installPhase = ''
      mkdir $out
      cat package.json | jq -r '.version = "${version}"' > $out/package.json
      cp yarn.lock $out/
      '';
  });
  yarnModules = yarn2nix-moretea.mkYarnModules rec {
    name = "grocy-yarn";
    pname = name;
    version = version;
    packageJSON = "${patchedPackages}/package.json";
    yarnLock = "${patchedPackages}/yarn.lock";
    yarnNix = ./yarn-packages.nix;
    pkgConfig = {
      all = {
        buildInputs = [ git which ];
      };
    };
  };
  app = composerEnv.buildPackage (
    import ./php-packages.nix { inherit composerEnv fetchurl; } //
    packagesource //
    {
      noDev = true;
      buildInputs = [ yarnModules ];
      postInstall = ''
        rm -rf data
        ln -sf ${varDir}/data data
        ln -sf ${yarnModules}/node_modules public
      '';
      passthru = {
        inherit varDir yarnModules;
        webRoot = "${app}/public";
      };
    }
  );
in
  app