about summary refs log tree commit diff
path: root/tools/ipconverter/default.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-10-04 17:53:28 -0700
committerFranck Cuny <franck@fcuny.net>2022-10-04 17:53:28 -0700
commit5da35c9ae3396002e3c8d4de8edbdf85ecf2569d (patch)
treef108d6fe7e0133130b1a1a639b36ecf703b9121d /tools/ipconverter/default.nix
parentops(terraform): individual actions for init/plan/apply (diff)
downloadworld-5da35c9ae3396002e3c8d4de8edbdf85ecf2569d.tar.gz
ref(tools/ipconverter): rewrite the tool in python
No need to do this with Go, a python script is fine.

We also don't need to set shell aliases for this: when we install the
tool, we can create symbolic links to `ip2int` and `int2ip`.
Diffstat (limited to 'tools/ipconverter/default.nix')
-rw-r--r--tools/ipconverter/default.nix39
1 files changed, 26 insertions, 13 deletions
diff --git a/tools/ipconverter/default.nix b/tools/ipconverter/default.nix
index c4d2f3a..ae08d0f 100644
--- a/tools/ipconverter/default.nix
+++ b/tools/ipconverter/default.nix
@@ -1,15 +1,28 @@
-{ pkgs, buildGoModule, ... }:
-
-buildGoModule rec {
-  name = "ipconverter";
-  src = ./.;
-  vendorSha256 = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";
-  nativeBuildInputs = with pkgs; [ go ];
-
-  meta = with pkgs.lib; {
-    description = "CLI to convert IP addresses to integer and vice versa";
-    license = licenses.mit;
-    platforms = platforms.linux;
-    maintainers = [ ];
+{ lib, python3, stdenvNoCC, pkgs }:
+
+stdenvNoCC.mkDerivation rec {
+  pname = "ipconverter";
+  version = "0.1.0";
+
+  src = ./ipconverter.py;
+
+  buildInputs = [ python3 ];
+
+  dontUnpack = true;
+  dontBuild = true;
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp $src $out/bin/${pname}
+    chmod a+x $out/bin/${pname}
+    ln -s $out/bin/${pname} $out/bin/ip2int
+    ln -s $out/bin/${pname} $out/bin/int2ip
+  '';
+
+  meta = with lib; {
+    description = "Helper script to convert an IP address to an integer.";
+    license = with licenses; [ mit ];
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ fcuny ];
   };
 }