]> Untitled Git - lemmy-ui.git/blob - default.nix
fix submodule error
[lemmy-ui.git] / default.nix
1 { lib, mkYarnPackage, libsass, nodejs, python3, pkg-config, fetchFromGitHub
2 , fetchYarnDeps, nixosTests, vips, nodePackages, lemmy-translations
3 , lemmy-js-client }:
4
5 let
6   pkgConfig = {
7     node-sass = {
8       nativeBuildInputs = [ pkg-config ];
9       buildInputs = [ libsass python3 ];
10       postInstall = ''
11         LIBSASS_EXT=auto yarn --offline run build
12         rm build/config.gypi
13       '';
14     };
15     sharp = {
16       nativeBuildInputs = [ pkg-config nodePackages.semver ];
17       buildInputs = [ vips ];
18       postInstall = ''
19         yarn --offline run install
20       '';
21     };
22   };
23
24   name = "lemmy-ui";
25   version = "0.18.4";
26
27   src = ./.;
28
29 in mkYarnPackage {
30
31   inherit src pkgConfig name version;
32
33   extraBuildInputs = [ libsass ];
34
35   packageJSON = ./package.json;
36   offlineCache = fetchYarnDeps {
37     yarnLock = src + "/yarn.lock";
38     sha256 = "sha256-EZSTYdUhb1+8GIx9UnOtImcg8ABA6RPqTrelZa3QD84=";
39   };
40
41   yarnPreBuild = ''
42     export npm_config_nodedir=${nodejs}
43   '';
44
45   buildPhase = ''
46     # Yarn writes cache directories etc to $HOME.
47     export HOME=$PWD/yarn_home
48     rm -rf node_modules/lemmy-js-client
49     ln -sf ${lemmy-js-client}/libexec/lemmy-js-client/node_modules/lemmy-js-client node_modules/lemmy-js-client
50
51     ln -sf $PWD/node_modules $PWD/deps/lemmy-ui/
52     echo 'export const VERSION = "${version}";' > $PWD/deps/lemmy-ui/src/shared/version.ts
53
54     rm -rf deps/lemmy-ui/lemmy-translations
55     ln -sf ${lemmy-translations} deps/lemmy-ui/lemmy-translations
56
57     yarn --offline build:prod
58   '';
59
60   preInstall = ''
61     mkdir $out
62     cp -R ./deps/lemmy-ui/dist $out
63     cp -R ./node_modules $out
64   '';
65
66   distPhase = "true";
67
68   passthru.updateScript = ./update.sh;
69   passthru.tests.lemmy-ui = nixosTests.lemmy;
70
71   meta = with lib; {
72     description = "Building a federated alternative to reddit in rust";
73     homepage = "https://join-lemmy.org/";
74     license = licenses.agpl3Only;
75     maintainers = with maintainers; [ happysalada billewanick ];
76     inherit (nodejs.meta) platforms;
77   };
78 }