summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2019-03-02 17:48:32 -0800
committerBen Sima <ben@bsima.me>2019-03-02 17:50:39 -0800
commitf9524766bd7eba9c429492017485d61188b76c87 (patch)
treeef67af35c3f8947a15947e4b4a7a22ffaba4c59c
parent3d0df3ed30014f22574af4b390553930ef7cbb7f (diff)
Better deploy script
-rw-r--r--.gitignore1
-rw-r--r--Makefile17
-rw-r--r--README.md18
-rwxr-xr-xchip/push41
4 files changed, 49 insertions, 28 deletions
diff --git a/.gitignore b/.gitignore
index 332bc9e..6487b7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
result*
dist
dist-newstyle
+bild/*
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 71c1a16..0000000
--- a/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-HOST = simatime.com
-USER = root
-OUT = $(shell readlink -n ./result)
-
-result:
- nix-build -A depo.nutin-madaj.system
-
-copy: result
- nix copy --to "ssh://$(USER)@$(HOST)" ./result
-
-switch:
- ssh $(USER)@$(HOST) sudo "$(OUT)/bin/switch-to-configuration" switch
-
-clean: FORCE
- rm -f ./result
-
-.PHONY: FORCE
diff --git a/README.md b/README.md
index ab47227..cac5b98 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,11 @@
This isn't totally in place yet, but it's something to work toward.
+The two special locations are 'soar' and 'bild'. The former is for images and
+other assets and is synced to digital ocean's object storage. The latter's
+contents are gitignore'd and can be deleted at any time because they will just
+be rebuilt later.
+
# Development
To get a development shell, for example to work on ibb, you can do:
@@ -55,18 +60,9 @@ not just how we write it; that is by design.
To build the production server config locally:
- make clean result
+ nix-build -A depo.nutin-madaj.system
To push the built closure and switch to the new configuration (will ask for ssh
passphrase 2x):
- make copy switch
-
-A quick deploy can be just:
-
- make clean copy switch
-
-When that damn bug gets fixed, we could just do:
-
- nix-deploy --to root@simatime.com \
- --path $(nix-build --no-out-path ./nixos.nix)
+ chip/push nutin-madaj
diff --git a/chip/push b/chip/push
new file mode 100755
index 0000000..48a7cc4
--- /dev/null
+++ b/chip/push
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import argparse
+import os
+import subprocess
+import tempfile
+import importlib.util
+
+cli = argparse.ArgumentParser(description='deploy a thing')
+cli.add_argument('depo', type=str,
+ help='the depo roun to deploy')
+
+args = cli.parse_args()
+
+cwd = os.getcwd()
+bild_dir = f"{cwd}/bild"
+
+src = f"{cwd}/depo/{args.depo}"
+out = f"{bild_dir}/{args.depo}"
+
+
+# bild
+subprocess.run(["nix-build", "-A", f"depo.{args.depo}",
+ "--out-link", out])
+print("bilt")
+
+
+p = subprocess.run(["chip/roun", args.depo, "-i"],
+ stdout=subprocess.PIPE)
+ip = p.stdout.decode()
+
+# push
+subprocess.run(["nix", "copy", "--to", f"ssh://root@{ip}", f"{out}"])
+print("sent")
+
+# switch
+subprocess.run(["ssh", f"root@{ip}", "sudo",
+ f"{os.readlink(out)}/bin/switch-to-configuration",
+ "switch"])
+
+print(f"pushed {args.depo} -> {ip}")