shrub/flake.nix

76 lines
2.3 KiB
Nix
Raw Normal View History

2023-07-06 17:47:34 +03:00
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
tools = {
flake = false;
url = "github:urbit/tools";
};
};
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; };
2023-07-16 13:04:40 +03:00
bootFakeShip = { pill, arvo }:
2023-07-06 17:47:34 +03:00
pkgs.runCommand "fake-pier" { } ''
2023-07-16 13:04:40 +03:00
${pkgs.urbit}/bin/urbit --pier $out -F zod -B ${pill} -l -x -t -A ${arvo}
2023-07-06 17:47:34 +03:00
'';
2023-07-16 13:04:40 +03:00
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";
};
2023-07-06 17:47:34 +03:00
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
${pkgs.urbit}/bin/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 {
2023-07-16 13:04:40 +03:00
inherit pkgs;
pier = testPier;
click = usableTools + "/pkg/click/click";
2023-07-06 17:47:34 +03:00
};
};
packages = {
2023-07-16 13:04:40 +03:00
inherit fakePier testPier;
2023-07-06 17:47:34 +03:00
brass = buildPill "brass";
ivory = buildPill "ivory";
solid = buildPill "solid";
};
});
}