about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/admin/cjdns-tools/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/admin/cjdns-tools/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/admin/cjdns-tools/default.nix46
1 files changed, 46 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/admin/cjdns-tools/default.nix b/nixpkgs/pkgs/tools/admin/cjdns-tools/default.nix
new file mode 100644
index 000000000000..2468d329548c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/admin/cjdns-tools/default.nix
@@ -0,0 +1,46 @@
+{ stdenv
+, cjdns
+, nodejs
+, makeWrapper
+, lib
+}:
+
+stdenv.mkDerivation {
+  pname = "cjdns-tools";
+  version = cjdns.version;
+
+  src = cjdns.src;
+
+  buildInputs = [
+    nodejs
+  ];
+
+  nativeBuildInputs = [
+    makeWrapper
+  ];
+
+  buildPhase = ''
+    patchShebangs tools
+
+    sed -e "s|'password': 'NONE'|'password': Fs.readFileSync('/etc/cjdns.keys').toString().split('\\\\n').map(v => v.split('=')).filter(v => v[0] === 'CJDNS_ADMIN_PASSWORD').map(v => v[1])[0]|g" \
+      -i tools/lib/cjdnsadmin/cjdnsadmin.js
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cat ${./wrapper.sh} | sed "s|@@out@@|$out|g" > $out/bin/cjdns-tools
+    chmod +x $out/bin/cjdns-tools
+
+    cp -r tools $out/tools
+    find $out/tools -maxdepth 1 -type f -exec chmod -v a+x {} \;
+    cp -r node_modules $out/node_modules
+  '';
+
+  meta = with lib; {
+    homepage = "https://github.com/cjdelisle/cjdns";
+    description = "Tools for cjdns managment";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ mkg20001 ];
+    platforms = platforms.linux;
+  };
+}