From b72f6ba9f7a6987f184ac510491e452c3ea855b1 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 24 May 2022 18:21:20 -0400 Subject: Init urbit harbor This is mostly stubbed out and needs some work to be functional... the idea is to run urbit ships as systemd services, and provide a simple interface for managing them. --- Urbit/Ship.nix | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Urbit/Ship.nix (limited to 'Urbit/Ship.nix') diff --git a/Urbit/Ship.nix b/Urbit/Ship.nix new file mode 100644 index 0000000..ec6a9ec --- /dev/null +++ b/Urbit/Ship.nix @@ -0,0 +1,44 @@ +{ bild ? import ../Biz/Bild.nix {} +}: + +# This represents a single ship running in a container. + +let + # bootstrap & startup process, expects two files: + # - /ship.name: containing a ship name like 'sampel-palnet' + # - /ship.key: containing the key + urbit-start = bild.pkgs.writeScript "urbit-start" '' + #!${bild.pkgs.runtimeShell} + set -xeuo pipefail + + ship=$(cat /ship.name) + pier="/$ship" + + if [ -d "$pier" ]; then + # pack pier if it exists, to save space + /bin/urbit-worker pack "$pier" + else + # otherwise, setup + /bin/urbit -c "$pier" -k /ship.key -x + fi + + /bin/urbit -tq "$pier" + ''; +in bild.image { + name = "urbit-ship"; + tag = "latest"; + + fromImage = null; # scratch + + contents = bild.pkgs.urbit; + + config = { + Cmd = [ + "${urbit-start}" + ]; + WorkingDir = "/"; + Volumes = { + "/" = { }; + }; + }; +} -- cgit v1.2.3