ctucx.git: nixfiles

ctucx' nixfiles

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
{ applyPatches, fetchFromGitHub, mkYarnPackage, buildGo121Module, lib, ffmpeg, makeWrapper, installShellFiles, ... }:

buildGo121Module rec {
  pname   = "gotosocial";
  version = "0.15.0-${builtins.substring 0 6 rev}";
  rev     = "15733cddb22de81475d1934be100cd3960668c43";
  sha256  = "sha256-z0iETddkw4C2R6ig9ZO8MTvhuWnmQ37/6q3oZ4WAzd4";


  src = applyPatches {
    src = fetchFromGitHub {
      owner  = "superseriousbusiness";
      repo   = "gotosocial";
      inherit rev sha256;
    };
    patches = [];
  };

  frontend-assets =  mkYarnPackage {
    name        = "${pname}_${version}-frontend-assets";
    src         = src;

    packageJSON = "${src}/web/source/package.json";
    yarnLock    = "${src}/web/source/yarn.lock";

    configurePhase = ''
      cp -r $node_modules node_modules
      chmod +w -R node_modules
    '';

    buildPhase = ''
      mkdir -p ./web/source ./web/assets

      cp -r $src/web/source/. ./web/source
      cp -r $src/web/assets/. ./web/assets

      export NODE_OPTIONS=--openssl-legacy-provider
      node ./node_modules/ts-patch/bin/ts-patch.js install
      yarn --offline --cwd ./web/source build
    '';

    distPhase    = "true";
    installPhase = "cp -r ./web/assets $out";
  };

  ldflags = ["-s" "-w" "-extldflags '-static'" "-X 'main.Commit=${rev}'" "-X 'main.Version=${version}'"];
  tags    = ["netgo" "osusergo" "static_build"];

  vendorHash = null;

	propagatedBuildInputs = [ ffmpeg ];
  nativeBuildInputs     = [ installShellFiles ];
  buildInputs           = [ makeWrapper ];

  doCheck = false;

  installCheckPhase = ''
    runHook preCheck
    $out/bin/gotosocial --help
    runHook postCheck
  '';

  postInstall = ''
    mkdir -p $out/share/web/assets

    cp -r  ./web/template             $out/share/web/
    cp -rf ${frontend-assets}/.       $out/share/web/assets

    installShellCompletion --cmd gotosocial \
      --bash <($out/bin/gotosocial completion bash) \
      --fish <($out/bin/gotosocial completion fish) \
      --zsh <($out/bin/gotosocial completion zsh)
  '';

  meta = with lib; {
    description = "An ActivityPub social network server, written in Golang.";
    homepage    = "https://github.com/superseriousbusiness/gotosocial";
    license     = licenses.agpl3;
    platforms   = platforms.linux;
  };
}