aboutsummaryrefslogtreecommitdiff
path: root/pkgs/private/webapps/aten/default.nix
blob: c36e15df62fe24eca2c5f76f10525fd2fdf17f5a (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
46
47
48
49
50
51
52
53
54
55
56
57
{ environment ? "prod"
, varDir ? "/var/lib/aten_${environment}"
, mylibs, composerEnv, fetchgit, runCommand, nodejs, jq, libsass, python, fetchurl }:
let
  packagesource = mylibs.fetchedGitPrivate ./aten.json;
  packagejson = runCommand "package.json" { buildInputs = [ jq ]; } ''
    cat ${packagesource.src}/package.json | jq -r '.version = "v1.0.0"|.name="aten"' > $out
    '';
  yarnModules = mylibs.yarn2nixPackage.mkYarnModules rec {
    name = "aten-yarn";
    pname = name;
    version = "v1.0.0";
    packageJSON = packagejson;
    yarnLock = "${packagesource.src}/yarn.lock";
    yarnNix = ./yarn-packages.nix;
    pkgConfig = {
      all = {
        buildInputs = [ mylibs.yarn2nixPackage.src ];
      };
      node-sass = {
        buildInputs = [ libsass python ];
        postInstall = let
          nodeHeaders = fetchurl {
            url = "https://nodejs.org/download/release/v${nodejs.version}/node-v${nodejs.version}-headers.tar.gz";
            sha256 = "16f20ya3ys6w5w6y6l4536f7jrgk4gz46bf71w1r1xxb26a54m32";
          };
        in
          ''
            node scripts/build.js --tarball=${nodeHeaders}
          '';
      };
    };
  };
  app = composerEnv.buildPackage (
    import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
    packagesource //
    rec {
      noDev = (environment == "prod");
      preInstall = ''
        export SYMFONY_ENV="${environment}"
        export APP_ENV="${environment}"
        '';
      postInstall = ''
        ln -sf ${yarnModules}/node_modules .
        yarn run --offline encore production
        rm -rf var/{log,cache}
        ln -sf ${varDir}/{log,cache} var/
        '';
      buildInputs = [ yarnModules mylibs.yarn2nixPackage.yarn ];
      passthru = {
        inherit varDir;
        inherit environment;
        webRoot = "${app}/public";
      };
    }
  );
in app