on master help sign in
decided to not do crypto
commit5fcb32c4d14ec11beb33fc51778af46b16d4d1e8 authoriko <mail@iko.soy> dateSun 11 Aug 2024, 00:30 (2 years ago) parent37116e8
6 files changed+332
.gitignore+1 .helix/languages.toml+4 flake.lock+163 flake.nix+144 libaes_siv/include/config.h+8 vere.patch+12
.gitignorenew file+1
@@ -0,0 +1 @@
1+result
.helix/languages.tomlnew file+4
@@ -0,0 +1,4 @@
1+[[language]]
2+name = "nix"
3+auto-format = true
4+formatter = { command = "nixfmt" }
flake.locknew file+163
@@ -0,0 +1,163 @@
1+{
2+ "nodes": {
3+ "flake-utils": {
4+ "inputs": {
5+ "systems": "systems"
6+ },
7+ "locked": {
8+ "lastModified": 1710146030,
9+ "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
10+ "owner": "numtide",
11+ "repo": "flake-utils",
12+ "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
13+ "type": "github"
14+ },
15+ "original": {
16+ "owner": "numtide",
17+ "repo": "flake-utils",
18+ "type": "github"
19+ }
20+ },
21+ "libaes_siv": {
22+ "flake": false,
23+ "locked": {
24+ "lastModified": 1602781365,
25+ "narHash": "sha256-8X9Nd2H1wM5wIoG3nPp0Kc5f4LyX0mjNPx1fXirwnLw=",
26+ "owner": "dfoxfranke",
27+ "repo": "libaes_siv",
28+ "rev": "9681279cfaa6e6399bb7ca3afbbc27fc2e19df4b",
29+ "type": "github"
30+ },
31+ "original": {
32+ "owner": "dfoxfranke",
33+ "repo": "libaes_siv",
34+ "type": "github"
35+ }
36+ },
37+ "murmur3": {
38+ "flake": false,
39+ "locked": {
40+ "lastModified": 1430543652,
41+ "narHash": "sha256-I7a5beN+4lle0CGz911PN56y+bKsJfQ7Kpim+L7PVZg=",
42+ "owner": "PeterScott",
43+ "repo": "murmur3",
44+ "rev": "dae94be0c0f54a399d23ea6cbe54bca5a4e93ce4",
45+ "type": "github"
46+ },
47+ "original": {
48+ "owner": "PeterScott",
49+ "repo": "murmur3",
50+ "type": "github"
51+ }
52+ },
53+ "nixpkgs": {
54+ "locked": {
55+ "lastModified": 1723296330,
56+ "narHash": "sha256-9XMoCBSVn2wc8AaQZxMt8FhOIoqYNtoNl1nJ9po8aYo=",
57+ "owner": "NixOS",
58+ "repo": "nixpkgs",
59+ "rev": "91f9fdc7a7a61d24f485bfa143a705cdec40a116",
60+ "type": "github"
61+ },
62+ "original": {
63+ "owner": "NixOS",
64+ "repo": "nixpkgs",
65+ "type": "github"
66+ }
67+ },
68+ "pdjson": {
69+ "flake": false,
70+ "locked": {
71+ "lastModified": 1708600372,
72+ "narHash": "sha256-EjxpYkdepKtc5UAwtsp7BVZKtSlnGveL+DTshhCTUhM=",
73+ "owner": "skeeto",
74+ "repo": "pdjson",
75+ "rev": "78fe04b820dc8817f540bdd87fb22887e0ef3981",
76+ "type": "github"
77+ },
78+ "original": {
79+ "owner": "skeeto",
80+ "repo": "pdjson",
81+ "type": "github"
82+ }
83+ },
84+ "root": {
85+ "inputs": {
86+ "flake-utils": "flake-utils",
87+ "libaes_siv": "libaes_siv",
88+ "murmur3": "murmur3",
89+ "nixpkgs": "nixpkgs",
90+ "pdjson": "pdjson",
91+ "softfloat": "softfloat",
92+ "urcrypt": "urcrypt",
93+ "vere": "vere"
94+ }
95+ },
96+ "softfloat": {
97+ "flake": false,
98+ "locked": {
99+ "lastModified": 1722814202,
100+ "narHash": "sha256-uBXfFgKuGixDIupetB/p421YmZM/AlBmJi4VgFOjbC0=",
101+ "owner": "ucb-bar",
102+ "repo": "berkeley-softfloat-3",
103+ "rev": "3b70b5d8147675932c38b36cd09af6df4eedd919",
104+ "type": "github"
105+ },
106+ "original": {
107+ "owner": "ucb-bar",
108+ "repo": "berkeley-softfloat-3",
109+ "type": "github"
110+ }
111+ },
112+ "systems": {
113+ "locked": {
114+ "lastModified": 1681028828,
115+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
116+ "owner": "nix-systems",
117+ "repo": "default",
118+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
119+ "type": "github"
120+ },
121+ "original": {
122+ "owner": "nix-systems",
123+ "repo": "default",
124+ "type": "github"
125+ }
126+ },
127+ "urcrypt": {
128+ "flake": false,
129+ "locked": {
130+ "lastModified": 1722883901,
131+ "narHash": "sha256-6T9HmqWKKxV9ivBY5jKun56s7WYmulk7y3M3heCYc3Y=",
132+ "owner": "urbit",
133+ "repo": "urcrypt",
134+ "rev": "e77a0998809f7552c455cf7bf8c1b68c141cce18",
135+ "type": "github"
136+ },
137+ "original": {
138+ "owner": "urbit",
139+ "repo": "urcrypt",
140+ "type": "github"
141+ }
142+ },
143+ "vere": {
144+ "flake": false,
145+ "locked": {
146+ "lastModified": 1710170699,
147+ "narHash": "sha256-gBF3J4WtWHVpcCfcadKTuNrkQwPz+3TJAfNB6Q6U5Hc=",
148+ "owner": "urbit",
149+ "repo": "vere",
150+ "rev": "954fd0b471105daa4b976f4088c009410536f9a8",
151+ "type": "github"
152+ },
153+ "original": {
154+ "owner": "urbit",
155+ "ref": "master",
156+ "repo": "vere",
157+ "type": "github"
158+ }
159+ }
160+ },
161+ "root": "root",
162+ "version": 7
163+}
flake.nixnew file+144
@@ -0,0 +1,144 @@
1+{
2+ inputs = {
3+ nixpkgs.url = "github:NixOS/nixpkgs";
4+ flake-utils.url = "github:numtide/flake-utils";
5+ vere = {
6+ url = "github:urbit/vere?ref=master";
7+ flake = false;
8+ };
9+ urcrypt = {
10+ url = "github:urbit/urcrypt";
11+ flake = false;
12+ };
13+ murmur3 = {
14+ url = "github:PeterScott/murmur3";
15+ flake = false;
16+ };
17+ libaes_siv = {
18+ url = "github:dfoxfranke/libaes_siv";
19+ flake = false;
20+ };
21+ pdjson = {
22+ url = "github:skeeto/pdjson";
23+ flake = false;
24+ };
25+ softfloat = {
26+ url = "github:ucb-bar/berkeley-softfloat-3";
27+ flake = false;
28+ };
29+ };
30+ outputs = inputs@{ self, nixpkgs, flake-utils, vere, murmur3, pdjson
31+ , softfloat, ... }:
32+ flake-utils.lib.eachDefaultSystem (system:
33+ let pkgs = nixpkgs.legacyPackages.${system};
34+ in {
35+ packages = rec {
36+ gmp = pkgs.runCommand "gmp" {
37+ buildInputs = with pkgs; [ gnutar emscripten gcc ];
38+ } ''
39+ tar xvf ${pkgs.gmp.src}
40+ cd "gmp-${pkgs.gmp.version}"
41+ mkdir -p $out
42+ HOME=$TMPDIR
43+ emconfigure ./configure --disable-assembly --host none HOST_CC=gcc --prefix=$out
44+ make
45+ make install
46+ '';
47+ openssl = pkgs.openssl.overrideDerivation (old: {
48+ configurePhase = ''
49+ HOME=$TMPDIR
50+ ${pkgs.emscripten}/bin/emconfigure ./Configure --no-asm --no-apps --prefix=$out ${
51+ builtins.concatStringsSep " " old.configureFlags
52+ }
53+ '';
54+ doCheck = false;
55+ });
56+ secp256k1 = pkgs.secp256k1.overrideDerivation (old: {
57+ configurePhase = ''
58+ ./autogen.sh
59+ HOME=$TMPDIR
60+ ${pkgs.emscripten}/bin/emconfigure ./configure --prefix=$out ${
61+ builtins.concatStringsSep " " old.configureFlags
62+ }
63+ '';
64+ doCheck = false;
65+ });
66+ libaes_siv = pkgs.runCommand "libaes_siv" {
67+ buildInputs = with pkgs; [ emscripten ];
68+ } ''
69+ mkdir -p $out
70+ HOME=$TMPDIR
71+ emcc ${inputs.libaes_siv}/aes_siv.c -I${
72+ ./libaes_siv/include
73+ } -o $out/lib/libaes_siv.a
74+ mkdir -p $out/include
75+ cp ${inputs.libaes_siv}/aes_siv.h $out/include
76+ '';
77+ # libaes_siv = pkgs.stdenv.mkDerivation {
78+ # name = "libaes_siv";
79+ # src = inputs.libaes_siv;
80+ # # configurePhase = ''
81+ # # HOME=$TMPDIR
82+ # # ${pkgs.emscripten}/bin/emconfigure ./configure --prefix=$out
83+ # # '';
84+ # buildInputs = with pkgs; [ cmake openssl ];
85+ # };
86+ urcrypt = pkgs.stdenv.mkDerivation {
87+ name = "urcrypt";
88+ src = inputs.urcrypt;
89+ configurePhase = ''
90+ runHook preConfigure
91+
92+ ./autogen.sh
93+ HOME=$TMPDIR
94+ emconfigure ./configure --prefix=$out
95+
96+ runHook preConfigure
97+ '';
98+ buildInputs = with pkgs; [
99+ secp256k1
100+ pkg-config
101+ libaes_siv
102+ openssl
103+ ];
104+ nativeBuildInputs = with pkgs; [
105+ emscripten
106+ autoconf
107+ automake
108+ autoconf-archive
109+ libtool
110+ ];
111+ };
112+ nock = pkgs.runCommand "nock" { } ''
113+ cp -r ${vere}/pkg .
114+ chmod -R a+w pkg
115+ cp pkg/noun/platform/linux/rsignal.h pkg/noun/platform/rsignal.h
116+ patch -p1 <${./vere.patch}
117+ rm pkg/noun/*_tests.c
118+ mkdir -p $out
119+ HOME=$TMPDIR
120+ ${pkgs.emscripten}/bin/emcc \
121+ pkg/noun/*.c pkg/noun/jets/*/*.c pkg/noun/jets/*.c pkg/c3/*.c pkg/ur/*.c ${urcrypt}/lib/liburcrypt.a \
122+ ${murmur3}/murmur3.c ${pdjson}/pdjson.c ${gmp}/lib/libgmp.a ${urcrypt}/lib/liburcrypt.a \
123+ -o $out/nock.js \
124+ -DU3_OS_linux \
125+ -DU3_OS_ENDIAN_little \
126+ -DU3_GUARD_PAGE \
127+ -sEXPORTED_RUNTIME_METHODS=cwrap \
128+ -Ipkg -Ipkg/noun -Ipkg/c3 -Ipkg/ur -Ipkg/ent -I. \
129+ -I${pdjson} -I${gmp}/include -I${murmur3} -I${urcrypt}/include -I${pkgs.libsigsegv}/include \
130+ -I${pkgs.openssl.dev}/include -I${softfloat}/source/include \
131+ -sEXPORTED_FUNCTIONS=_u3n_nock_on \
132+ # -Os
133+
134+ '';
135+ hello = pkgs.hello;
136+ default = hello;
137+ };
138+ apps = rec {
139+ hello =
140+ flake-utils.lib.mkApp { drv = self.packages.${system}.hello; };
141+ default = hello;
142+ };
143+ });
144+}
libaes_siv/include/config.hnew file+8
@@ -0,0 +1,8 @@
1+#ifndef AES_SIV_CONFIG_H_
2+#define AES_SIV_CONFIG_H_
3+
4+#define ENABLE_CTGRIND 0
5+#define ENABLE_DEBUG_WEIRD_ENDIAN 0
6+#define ENABLE_DEBUG_TINY_CHUNK_SIZE 0
7+
8+#endif
vere.patchnew file+12
@@ -0,0 +1,12 @@
1+diff --git a/pkg/c3/portable.h b/pkg/c3/portable.h
2+index 002276834b..52ebb7817d 100644
3+--- a/pkg/c3/portable.h
4++++ b/pkg/c3/portable.h
5+@@ -36,7 +36,6 @@
6+ # include <sys/time.h>
7+ # include <sys/resource.h>
8+ # include <sys/mman.h>
9+-# include <sys/sendfile.h>
10+
11+ # elif defined(U3_OS_osx)
12+ # include <ctype.h>