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