]> Untitled Git - awful.systems.git/blob - lemmy/ui.nix
Initial commit
[awful.systems.git] / lemmy / ui.nix
1 { lib, mkYarnPackage, libsass, nodejs, python3, pkg-config
2 , fetchFromGitHub, fetchYarnDeps, nixosTests }:
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   };
17
18   name = "lemmy-ui";
19   version = pinData.version;
20
21   src = fetchFromGitHub {
22     owner = "LemmyNet";
23     repo = name;
24     rev = version;
25     fetchSubmodules = true;
26     sha256 = pinData.uiSha256;
27   };
28
29   patches = [ ./disable-sharp.patch ];
30 in mkYarnPackage {
31
32   inherit src pkgConfig name version patches;
33
34   extraBuildInputs = [ libsass ];
35
36   packageJSON = ./package.json;
37   offlineCache = fetchYarnDeps {
38     yarnLock = src + "/yarn.lock";
39     sha256 = pinData.uiYarnDepsSha256;
40   };
41
42   yarnPreBuild = ''
43     export npm_config_nodedir=${nodejs}
44   '';
45
46   buildPhase = ''
47     # Yarn writes cache directories etc to $HOME.
48     export HOME=$PWD/yarn_home
49
50     ln -sf $PWD/node_modules $PWD/deps/lemmy-ui/
51
52     yarn --offline build:prod
53   '';
54
55   preInstall = ''
56     mkdir $out
57     cp -R ./deps/lemmy-ui/dist $out
58     cp -R ./node_modules $out
59   '';
60
61   distPhase = "true";
62
63   passthru.updateScript = ./update.sh;
64   passthru.tests.lemmy-ui = nixosTests.lemmy;
65
66   meta = with lib; {
67     description = "Building a federated alternative to reddit in rust";
68     homepage = "https://join-lemmy.org/";
69     license = licenses.agpl3Only;
70     maintainers = with maintainers; [ happysalada billewanick ];
71     inherit (nodejs.meta) platforms;
72   };
73 }