about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/admin/cjdns-tools/default.nix
blob: 7b314e1aa1315c76e0e1a175cc13064ea3538f6e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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; [ ];
    platforms = platforms.linux;
  };
}