about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-09-07 19:09:45 -0700
committerFranck Cuny <franck@fcuny.net>2022-09-07 19:15:30 -0700
commit8d405037f941abaaa2f43b3de1d442bea1b807c6 (patch)
tree3cda30d59f8be9e5a15501d86c377049eacfa896
parentfeat(flake): use naersk to build rust projects (diff)
downloadworld-8d405037f941abaaa2f43b3de1d442bea1b807c6.tar.gz
feat(tools/sendsms): build sendsms with nix via naersk
I can now run `nix build .#tools.sendsms` to build the tool, or get it
deployed on a machine.

Change-Id: I82c733be466adb229d98414fd1229e05f355dd7d
-rw-r--r--tools/default.nix4
-rw-r--r--tools/sendsms/README.org8
-rw-r--r--tools/sendsms/default.nix15
3 files changed, 23 insertions, 4 deletions
diff --git a/tools/default.nix b/tools/default.nix
index 7a35b07..17ece45 100644
--- a/tools/default.nix
+++ b/tools/default.nix
@@ -1,4 +1,4 @@
-{ pkgs }:
+{ pkgs, naersk, ... }:
 
 pkgs.lib.makeScope pkgs.newScope (pkgs: {
   dnsupdate = pkgs.callPackage ./dnsupdate { };
@@ -10,4 +10,6 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: {
   ipconverter = pkgs.callPackage ./ipconverter { };
 
   git-blame-stats = pkgs.callPackage ./git-blame-stats { };
+
+  sendsms = pkgs.callPackage ./sendsms { inherit naersk; };
 })
diff --git a/tools/sendsms/README.org b/tools/sendsms/README.org
index 8f3ffdd..755d086 100644
--- a/tools/sendsms/README.org
+++ b/tools/sendsms/README.org
@@ -2,7 +2,9 @@
 
 A CLI to send SMS via [[https://console.twilio.com][twilio's API]].
 
-** Usage
-The tool supports subcommands, which are profiles with predefined messages.
+* Usage
+The tool supports sub-commands, which are profiles with predefined messages.
 
-For example, you can write a systemd unit that is triggered after a reboot to send an SMS with =sendsms reboot=. The SMS will contain the hostname and IP of a predefined interface.
+For example, you can write a =systemd= unit that is triggered after a reboot to send an SMS with =sendsms reboot=. The SMS will contain the host's name and the IP of a predefined interface.
+* Build
+This can be build via =nix build .#tools.sendsms= from the root of the repository, or =cargo build= from inside the directory.
diff --git a/tools/sendsms/default.nix b/tools/sendsms/default.nix
new file mode 100644
index 0000000..6c9b79c
--- /dev/null
+++ b/tools/sendsms/default.nix
@@ -0,0 +1,15 @@
+{ pkgs, naersk, ... }:
+
+naersk.lib."${pkgs.system}".buildPackage {
+  src = builtins.filterSource
+    (path: type:
+      type != "directory" || builtins.baseNameOf path != "target")
+    ./.;
+
+  nativeBuildInputs = with pkgs; [ pkg-config ];
+  buildInputs = with pkgs; [ openssl ];
+
+  remapPathPrefix = true;
+  doCheck = true;
+  copyLibs = true;
+}