aboutsummaryrefslogtreecommitdiff
path: root/pkgs/webapps/grocy/default.nix
blob: 3a8e55a5921a66d0dcf1bc04d41b1f6ea978e705 (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 }:
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 = mylibs.yarn2nixPackage.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 mylibs.yarn2nixPackage.src ];
      };
    };
  };
  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