summary refs log tree commit diff
path: root/pkgs/tools/admin/netplan/default.nix
blob: b9dc2c070731a7f2c80f321334bb9852758ebbab (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{ stdenv
, fetchFromGitHub
, pkg-config
, glib
, pandoc
, systemd
, libyaml
, python3
, libuuid
, bash-completion
, lib
}:

stdenv.mkDerivation rec {
  pname = "netplan";
  version = "0.101";

  src = fetchFromGitHub {
    owner = "CanonicalLtd";
    repo = "netplan";
    rev = version;
    hash = "sha256-bCK7J2pCQUwjZu8c1n6jhF6T/gvUGwydqAXpxUMLgMc=";
    fetchSubmodules = false;
  };

  nativeBuildInputs = [
    pkg-config
    glib
    pandoc
  ];

  buildInputs = [
    systemd
    glib
    libyaml
    (python3.withPackages (p: with p; [ pyyaml netifaces ]))
    libuuid
    bash-completion
  ];

  postPatch = ''
    substituteInPlace netplan/cli/utils.py --replace "/lib/netplan/generate" "$out/lib/netplan/generate"
    substituteInPlace netplan/cli/utils.py --replace "ctypes.util.find_library('netplan')" "\"$out/lib/libnetplan.so\""

    substituteInPlace Makefile --replace 'SYSTEMD_GENERATOR_DIR=' 'SYSTEMD_GENERATOR_DIR ?= ' \
        --replace 'SYSTEMD_UNIT_DIR=' 'SYSTEMD_UNIT_DIR ?= ' \
        --replace 'BASH_COMPLETIONS_DIR=' 'BASH_COMPLETIONS_DIR ?= '
  '';

  makeFlags = [
    "PREFIX="
    "DESTDIR=$(out)"
    "SYSTEMD_GENERATOR_DIR=lib/systemd/system-generators/"
    "SYSTEMD_UNIT_DIR=lib/systemd/units/"
    "BASH_COMPLETIONS_DIR=share/bash-completion/completions"
  ];

  meta = with lib; {
    description = "Backend-agnostic network configuration in YAML";
    homepage = "https://netplan.io";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ mkg20001 ];
    platforms = platforms.linux;
  };
}