]> Untitled Git - awful.systems.git/blob - lemmy/ui.nix
fix lemmy and lemmy-ui version info
[awful.systems.git] / lemmy / ui.nix
1 { lib, mkYarnPackage, libsass, nodejs, python3, pkg-config, fetchFromGitHub
2 , 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   postPatch = ''
43     echo "export const VERSION = '${version}';" > "src/shared/version.ts"
44   '';
45
46   yarnPreBuild = ''
47     export npm_config_nodedir=${nodejs}
48   '';
49
50   buildPhase = ''
51     # Yarn writes cache directories etc to $HOME.
52     export HOME=$PWD/yarn_home
53
54     ln -sf $PWD/node_modules $PWD/deps/lemmy-ui/
55
56     yarn --offline build:prod
57   '';
58
59   preInstall = ''
60     mkdir $out
61     cp -R ./deps/lemmy-ui/dist $out
62     cp -R ./node_modules $out
63   '';
64
65   distPhase = "true";
66
67   passthru.updateScript = ./update.sh;
68   passthru.tests.lemmy-ui = nixosTests.lemmy;
69
70   meta = with lib; {
71     description = "Building a federated alternative to reddit in rust";
72     homepage = "https://join-lemmy.org/";
73     license = licenses.agpl3Only;
74     maintainers = with maintainers; [ happysalada billewanick ];
75     inherit (nodejs.meta) platforms;
76   };
77 }