Profpatsch/third_party/overlays/sam/pkgs/by-name/synit-network-utils/package.nix
 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ lib
, fetchFromSyndicateLang
, stdenvNoCC
, tcl9Packages
, execline
, iproute2
, jq
, s6-portable-utils
}:

let
  inherit (tcl9Packages) tcl sycl;
in
stdenvNoCC.mkDerivation {
  pname = "synit-network-utils";
  version = "0.20250826";

  src = fetchFromSyndicateLang {
    owner = "synit";
    repo = "synit-network-utils";
    rev = "e829cbfd0690ff9c1bb7677149a6f8a3336e5a1f";
    hash = "sha256-Q+WpN/Nf0VXXbPDxxg7B+RtGD6k9EJIkoEqxnIzLpIY=";
  };

  buildInputs = [
    tcl
    sycl
  ];

  buildPhase = ''
    runHook preBuild
    sed '2i lappend auto_path ${sycl}/lib/${sycl.name}' \
      <network-configurator.tcl \
      >network-configurator
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/{bin,etc,lib}

    # Install the configurator.
    install -m755 -D -t $out/bin network-configurator

    # Install the mdev hook.
    substitute "$src/mdev-hook.el" "$out/lib/mdev-hook.el" \
      --replace-fail @execlineb@ '${execline}/bin/execlineb' \
      --replace-fail @PATH@ '${
        lib.makeBinPath [
          iproute2
          jq
          s6-portable-utils
        ]
      }' \
      --replace-fail @ASSDIR@ /run/synit/config/machine \
      ;

    # Install the dhcpcd hook.
    substitute "$src/dhcpcd-hook.tcl" "$out/lib/dhcpcd-hook.tcl" \
      --replace-fail @tclsh@ '${tcl}/bin/tclsh' \
      --replace-fail @ASSDIR@ /run/synit/config/network \

    chmod +x $out/bin/* $out/lib/*

    runHook postInstall
  '';
}