forked from urbit/urbit
-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
75 lines (71 loc) · 2.33 KB
/
flake.nix
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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
tools = {
flake = false;
url = "github:urbit/tools/d454e2482c3d4820d37db6d5625a6d40db975864";
};
};
outputs = { self, nixpkgs, flake-utils, tools }:
flake-utils.lib.eachDefaultSystem (system:
let
usableTools = pkgs.runCommand "patched-tools" { } ''
cp -r ${tools} $out
chmod +w -R $out
patchShebangs $out
'';
pkgs = import nixpkgs { inherit system; };
bootFakeShip = { pill, arvo }:
pkgs.runCommand "fake-pier" { } ''
${./urbit} --pier $out -F zod -B ${pill} -l -x -t -A ${arvo}
'';
fakePier = bootFakeShip {
pill = ./bin/solid.pill;
arvo = "${./pkg}/arvo";
};
testPier = bootFakeShip {
pill = ./bin/solid.pill;
arvo = pkgs.runCommand "test-arvo" {} ''
cp -r ${./pkg} $out
chmod +w -R $out
cp -r ${./tests} $out/arvo/tests
cp -r ${./test-desk.bill} $out/arvo/desk.bill
'' + "/arvo";
};
buildPillThread = pill:
pkgs.writeTextFile {
name = "";
text = ''
=/ m (strand ,vase)
;< [=ship =desk =case] bind:m get-beak
;< ~ bind:m (poke [ship %dojo] %lens-command !>([%$ [%dojo '+${pill}'] [%output-pill '${pill}/pill']]))
;< ~ bind:m (poke [ship %hood] %drum-exit !>(~))
(pure:m !>(~))
'';
};
buildPill = pill:
pkgs.runCommand ("${pill}.pill") { buildInputs = [ pkgs.netcat ]; } ''
cp -r ${fakePier} pier
chmod +w -R pier
${./urbit} -d pier
${usableTools}/pkg/click/click -k -p -i ${buildPillThread pill} pier
# Sleep to let urbit spin down properly
sleep 5
cp pier/.urb/put/${pill}.pill $out
'';
in {
checks = {
testFakeShip = import ./nix/test-fake-ship.nix {
inherit pkgs;
pier = testPier;
click = usableTools + "/pkg/click/click";
};
};
packages = {
inherit fakePier testPier;
brass = buildPill "brass";
ivory = buildPill "ivory";
solid = buildPill "solid";
};
});
}