1{ stdenv
2, fetchFromGitHub
3, pkg-config
4, glib
5, pandoc
6, systemd
7, libyaml
8, python3
9, libuuid
10, bash-completion
11, lib
12}:
13
14stdenv.mkDerivation rec {
15 pname = "netplan";
16 version = "0.106.1";
17
18 src = fetchFromGitHub {
19 owner = "canonical";
20 repo = "netplan";
21 rev = version;
22 hash = "sha256-wQ4gd9+9YU92WGRMjSiF/zLCGxhaSl8s22pH1jr+Mm0=";
23 };
24
25 nativeBuildInputs = [
26 pkg-config
27 glib
28 pandoc
29 ];
30
31 buildInputs = [
32 systemd
33 glib
34 libyaml
35 (python3.withPackages (p: with p; [ pyyaml netifaces dbus-python rich ]))
36 libuuid
37 bash-completion
38 ];
39
40 postPatch = ''
41 substituteInPlace netplan/libnetplan.py \
42 --replace "/lib/netplan/generate" "$out/lib/netplan/generate" \
43 --replace "ctypes.util.find_library('netplan')" "\"$out/lib/libnetplan.so\""
44
45 substituteInPlace Makefile \
46 --replace 'SYSTEMD_GENERATOR_DIR=' 'SYSTEMD_GENERATOR_DIR ?= ' \
47 --replace 'SYSTEMD_UNIT_DIR=' 'SYSTEMD_UNIT_DIR ?= ' \
48 --replace 'BASH_COMPLETIONS_DIR=' 'BASH_COMPLETIONS_DIR ?= ' \
49 --replace 'pkg-config' '$(PKG_CONFIG)'
50
51 # from upstream https://github.com/canonical/netplan/blob/ee0d5df7b1dfbc3197865f02c724204b955e0e58/rpm/netplan.spec#L81
52 sed -e "s/-Werror//g" -i Makefile
53 '';
54
55 makeFlags = [
56 "PREFIX="
57 "DESTDIR=$(out)"
58 "SYSTEMD_GENERATOR_DIR=lib/systemd/system-generators/"
59 "SYSTEMD_UNIT_DIR=lib/systemd/units/"
60 "BASH_COMPLETIONS_DIR=share/bash-completion/completions"
61 ];
62
63 meta = with lib; {
64 description = "Backend-agnostic network configuration in YAML";
65 homepage = "https://netplan.io";
66 license = licenses.gpl3Only;
67 maintainers = with maintainers; [ mkg20001 ];
68 platforms = platforms.linux;
69 };
70}