forked from
lass.pds.lassul.us/superconfig
This repository has no description
5.0 kB
183 lines
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 rustPlatform,
6 fetchgit,
7 fetchurl,
8 fetchzip,
9 linkFarm,
10 runCommandLocal,
11 symlinkJoin,
12 writeShellScriptBin,
13 cmake,
14 perl,
15 tailwindcss,
16}:
17
18# Tangled (https://tangled.org) without its flake: the appview, knot 2
19# (knot-rs) and knotmirror, built the way its nix/pkgs files do. tap and goat
20# come from nixpkgs (tap, atproto-goat).
21let
22 version = "0-unstable-2026-10-18";
23
24 src = fetchgit {
25 url = "https://tangled.org/tangled.org/core";
26 rev = "dad751949f865d6189f7602e1409c5f951e75771";
27 hash = "sha256-pehXSw17JRgWA/d4t/x9ZcdxOHJaY3I0+H+3p1hVZxk=";
28 };
29
30 # The *-src inputs of the flake at that rev, generated by update.sh from
31 # its flake.lock; the hashes are the lock's narHashes.
32 assets = lib.mapAttrs (
33 name: a:
34 {
35 file = fetchurl {
36 inherit name;
37 inherit (a) url hash;
38 recursiveHash = true;
39 };
40 tarball = fetchzip {
41 inherit name;
42 inherit (a) url hash;
43 # flake tarballs only drop a single top-level directory
44 stripRoot = name != "inter-fonts-src";
45 };
46 git = fetchgit { inherit (a) url rev hash; };
47 }
48 .${a.type}
49 ) (lib.importJSON ./assets.json);
50
51 # The Go programs share the root go.mod, so one vendor directory.
52 buildTangledGo =
53 pname: args:
54 buildGoModule (
55 {
56 inherit pname version src;
57 vendorHash = "sha256-6eDNOcnMHMpdQS7M7A8O+wZOnP2/968Re7Iqn8XgGNM=";
58 overrideModAttrs = _: { name = "tangled-${version}-go-modules"; };
59 subPackages = [ "cmd/${pname}" ];
60 doCheck = false;
61 meta.mainProgram = pname;
62 }
63 // args
64 );
65
66 sqlite-lib = stdenv.mkDerivation {
67 name = "sqlite-lib";
68 src = assets.sqlite-lib-src;
69 buildPhase = ''
70 $CC -c sqlite3.c
71 $AR rcs libsqlite3.a sqlite3.o
72 $RANLIB libsqlite3.a
73 '';
74 installPhase = ''
75 mkdir -p $out/include $out/lib
76 cp *.h $out/include
77 cp libsqlite3.a $out/lib
78 '';
79 };
80
81 dolly-unwrapped = buildTangledGo "dolly" { };
82 dolly = writeShellScriptBin "dolly" ''
83 exec ${dolly-unwrapped}/bin/dolly \
84 -template ${src}/appview/pages/templates/fragments/dolly \
85 "$@"
86 '';
87
88 tailwindcss-plugins = linkFarm "tailwindcss-plugins" [
89 {
90 name = "tailwindcss-animated";
91 path = assets.tailwindcss-animated-src;
92 }
93 ];
94
95 static-files = runCommandLocal "appview-static-files" { } ''
96 mkdir -p $out/{fonts,icons,logos} && cd $out
97 cp -f ${assets.htmx-src} htmx.min.js
98 cp -f ${assets.htmx-ws-src} htmx-ext-ws.min.js
99 cp -f ${assets.mermaid-src} mermaid.min.js
100 cp -f ${assets.hls-src} hls.min.js
101 cp -f ${assets.mathjax-src} mathjax.min.js
102 cp -rf ${assets.lucide-src}/*.svg icons/
103 cp -rf ${src}/icons/*.svg icons/
104 cp -f ${assets.inter-fonts-src}/web/InterVariable*.woff2 fonts/
105 cp -f ${assets.inter-fonts-src}/web/InterDisplay*.woff2 fonts/
106 cp -f ${assets.inter-fonts-src}/InterVariable*.ttf fonts/
107 cp -f ${assets.ibm-plex-mono-src}/fonts/complete/woff2/IBMPlexMono*.woff2 fonts/
108 cp -f ${assets.actor-typeahead-src}/actor-typeahead.js .
109 cp -rf ${src}/appview/pages/profile-fx .
110
111 ${dolly}/bin/dolly -output logos/dolly.png -size 180
112 ${dolly}/bin/dolly -output logos/dolly.ico -size 48
113 ${dolly}/bin/dolly -output logos/dolly.svg -color currentColor -favicon
114 export NODE_PATH=${tailwindcss-plugins}
115 cd ${src} && ${tailwindcss}/bin/tailwindcss -i input.css -o $out/tw.css
116 '';
117
118 appview = buildTangledGo "appview" {
119 # knot2 wants the knot's did:web as listMembers subject, not its hostname
120 patches = [ ./appview-knot-members-did-web.patch ];
121 postUnpack = ''
122 mkdir -p $sourceRoot/appview/pages/static
123 cp -fr ${static-files}/* $sourceRoot/appview/pages/static
124 '';
125 tags = [ "libsqlite3" ];
126 env = {
127 CGO_ENABLED = 1;
128 CGO_CFLAGS = "-I ${sqlite-lib}/include ";
129 CGO_LDFLAGS = "-L ${sqlite-lib}/lib";
130 };
131 };
132
133 knotmirror = buildTangledGo "knotmirror" { };
134
135 knot-rs = rustPlatform.buildRustPackage {
136 pname = "knot-server";
137 inherit version src;
138 cargoHash = "sha256-3YPqGQS1yVF+Pmj0Xe2z6yITLl7RgwPMPY389MB8lw8=";
139 nativeBuildInputs = [
140 cmake
141 perl
142 ];
143 dontUseCmakeConfigure = true;
144 cargoBuildFlags = [
145 "--bin"
146 "knot-server"
147 "--package"
148 "knot-server"
149 ];
150 doCheck = false;
151 meta.mainProgram = "knot-server";
152 };
153in
154symlinkJoin {
155 pname = "tangled";
156 inherit version;
157 paths = [
158 appview
159 knot-rs
160 knotmirror
161 ];
162
163 passthru = {
164 inherit
165 src
166 assets
167 sqlite-lib
168 dolly
169 static-files
170 appview
171 knot-rs
172 knotmirror
173 ;
174 updateScript = ./update.sh;
175 };
176
177 meta = {
178 description = "Git collaboration platform on atproto: appview, knot and knotmirror";
179 homepage = "https://tangled.org/tangled.org/core";
180 license = lib.licenses.mit;
181 platforms = lib.platforms.linux;
182 };
183}