summaryrefslogtreecommitdiffstats
path: root/docs/package.nix
blob: 4ac6c26a63b99e72c43ff7ee02c17bc04666d922 (plain)
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
{
  buildNpmPackage,
  importNpmLock,
  optionsJSON,
}:
buildNpmPackage {
  name = "mnw-docs";
  src = ./.;

  npmDeps = importNpmLock {
    npmRoot = ./.;
  };

  inherit (importNpmLock) npmConfigHook;
  env.MNW_OPTIONS_JSON = optionsJSON;

  # VitePress hangs if you don't pipe the output into a file
  buildPhase = ''
    runHook preBuild

      local exit_status=0
      npm run build > build.log 2>&1 || {
          exit_status=$?
          :
      }
      cat build.log
      return $exit_status

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mv .vitepress/dist $out

    runHook postInstall
  '';
}