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