summaryrefslogtreecommitdiff
path: root/Urbit/Ship.nix
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-05-24 18:21:20 -0400
committerBen Sima <ben@bsima.me>2022-07-05 19:02:07 -0400
commitb72f6ba9f7a6987f184ac510491e452c3ea855b1 (patch)
tree201e1bd8d533f99fffceba6ba7310b29308160d5 /Urbit/Ship.nix
parent98963d27e5d6ed7327846471d791bcdcb9eb58b4 (diff)
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.
Diffstat (limited to 'Urbit/Ship.nix')
-rw-r--r--Urbit/Ship.nix44
1 files changed, 44 insertions, 0 deletions
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 = {
+ "/" = { };
+ };
+ };
+}