Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3247717
D5245.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5245.diff
View Options
diff --git a/nix/localstack-up.nix b/nix/localstack-up.nix
new file mode 100644
--- /dev/null
+++ b/nix/localstack-up.nix
@@ -0,0 +1,15 @@
+{ lib
+, localstack
+, writeShellApplication
+}:
+
+# writeShellApplication is a "writer helper" which
+# will create a shellchecked executable shell script located in $out/bin/<name>
+# This shell script will be used to allow for impure+stateful actions
+writeShellApplication {
+ name = "localstack-up";
+ # Docker must be installed outside of the development shell, so only
+ # pass localstack to script
+ runtimeInputs = [ localstack ];
+ text = builtins.readFile ../scripts/localstack_up.sh;
+}
diff --git a/nix/overlay.nix b/nix/overlay.nix
--- a/nix/overlay.nix
+++ b/nix/overlay.nix
@@ -54,6 +54,7 @@
devShells.default = final.callPackage ./dev-shell.nix { };
devShell = final.devShells.default;
+ localstack-up = prev.callPackage ./localstack-up.nix { };
# Make our version of mariadb the default everywhere
mariadb = prev.mariadb_108;
diff --git a/scripts/localstack_up.sh b/scripts/localstack_up.sh
new file mode 100644
--- /dev/null
+++ b/scripts/localstack_up.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+# Avoid localstack attempt to write in the nix store
+XDG_DATA_HOME=''${XDG_DATA_HOME:-$HOME/.local/share}
+export FILESYSTEM_ROOT=''${XDG_DATA_HOME}/localstack/filesystem
+
+# Since docker is installed outside of nix, need to ensure that it was
+# installed impurely
+if ! command -v docker > /dev/null; then
+ echo "Please install docker in order to use localstack" >&2
+ exit 1
+fi
+
+if ! command -v localstack > /dev/null; then
+ echo "Please install localstack cli in order to use localstack" >&2
+ exit 1
+fi
+
+# The 'localstack status' command will poll forever if you have a newer
+# docker cli, so instead use docker ps + grep to determine running container
+if ! docker ps | grep localstack &> /dev/null; then
+ echo "Starting localstack..." >&2
+ localstack start \
+ --detached \
+ --docker \
+ --no-banner > /dev/null
+else
+ echo "localstack is already running, skipping localstack initialization"
+fi
+
+# Explicitly exit this script so the parent shell can determine
+# when it's safe to return control of terminal to user
+exit 0
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 6:28 AM (21 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2496681
Default Alt Text
D5245.diff (2 KB)
Attached To
Mode
D5245: [Nix] Add localstack-up
Attached
Detach File
Event Timeline
Log In to Comment