opentabletdriver: 0.6.5.0 -> 0.6.5.1 (#379384)
[NixPkgs.git] / pkgs / by-name / op / opengist / package.nix
blob459b7b2d29d6ec4439ce0dedeaa04ef7dae4068e
2   lib,
3   stdenv,
4   buildGoModule,
5   buildNpmPackage,
6   fetchFromGitHub,
7   fetchpatch,
8   moreutils,
9   jq,
10   git,
12 let
13   # finalAttrs when ðŸ¥º (buildGoModule does not support them)
14   # https://github.com/NixOS/nixpkgs/issues/273815
15   version = "1.8.4";
16   src = fetchFromGitHub {
17     owner = "thomiceli";
18     repo = "opengist";
19     tag = "v${version}";
20     hash = "sha256-vpl3ztLHeVZndAwDgobfiI+3Xu3CFU38qgXy83p06As=";
21   };
23   frontend = buildNpmPackage {
24     pname = "opengist-frontend";
25     inherit version src;
26     # npm complains of "invalid package". shrug. we can give it a version.
27     postPatch = ''
28       ${lib.getExe jq} '.version = "${version}"' package.json | ${lib.getExe' moreutils "sponge"} package.json
29     '';
31     # copy pasta from the Makefile upstream, seems to be a workaround of sass
32     # issues, unsure why it is not done in vite:
33     # https://github.com/thomiceli/opengist/blob/05eccfa8e728335514a40476cd8116cfd1ca61dd/Makefile#L16-L19
34     postBuild = ''
35       EMBED=1 npx postcss 'public/assets/embed-*.css' -c public/postcss.config.js --replace
36     '';
38     installPhase = ''
39       mkdir -p $out
40       cp -R public $out
41     '';
43     npmDepsHash = "sha256-l09TPGBGhWcsl3x14ovilDd1zZWv4XzFCAmAfapKtAE=";
44   };
46 buildGoModule {
47   pname = "opengist";
48   inherit version src;
49   vendorHash = "sha256-mLFjRL4spAWuPLVOtt88KH+p2g9lGCYzaHokVxdrLOw=";
50   tags = [ "fs_embed" ];
51   ldflags = [
52     "-s"
53     "-X github.com/thomiceli/opengist/internal/config.OpengistVersion=v${version}"
54   ];
56   # required for tests
57   nativeCheckInputs = [
58     git
59   ];
61   # required for tests to not try to write into $HOME and fail
62   preCheck = ''
63     export OG_OPENGIST_HOME=$(mktemp -d)
64   '';
66   doCheck = !stdenv.hostPlatform.isDarwin;
68   checkPhase = ''
69     runHook preCheck
70     make test
71     runHook postCheck
72   '';
74   postPatch = ''
75     cp -R ${frontend}/public/{manifest.json,assets} public/
76   '';
78   passthru = {
79     inherit frontend;
80     updateScript = ./update.sh;
81   };
83   meta = {
84     description = "Self-hosted pastebin powered by Git";
85     homepage = "https://github.com/thomiceli/opengist";
86     license = lib.licenses.agpl3Only;
87     changelog = "https://github.com/thomiceli/opengist/blob/${src.tag}/CHANGELOG.md";
88     platforms = lib.platforms.unix;
89     maintainers = with lib.maintainers; [ phanirithvij ];
90     mainProgram = "opengist";
91   };