nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5
6 bashInteractive,
7 dbus,
8 docbook2x,
9 libapparmor,
10 libcap,
11 libseccomp,
12 libselinux,
13 meson,
14 ninja,
15 nixosTests,
16 openssl,
17 pkg-config,
18 systemd,
19
20 nix-update-script,
21}:
22
23stdenv.mkDerivation (finalAttrs: {
24 pname = "lxc";
25 version = "6.0.5";
26
27 src = fetchFromGitHub {
28 owner = "lxc";
29 repo = "lxc";
30 tag = "v${finalAttrs.version}";
31 hash = "sha256-bnvKSs7w1cq3vP2BzX4kfDrGUIFhU4Fnu5pM81jPVQ8=";
32 };
33
34 nativeBuildInputs = [
35 docbook2x
36 meson
37 ninja
38 pkg-config
39 ];
40
41 buildInputs = [
42 # some hooks use compgen
43 bashInteractive
44 dbus
45 libapparmor
46 libcap
47 libseccomp
48 libselinux
49 openssl
50 systemd
51 ];
52
53 patches = [
54 # fix docbook2man version detection
55 ./docbook-hack.patch
56
57 # Fix hardcoded path of lxc-user-nic
58 # This is needed to use unprivileged containers
59 ./user-nic.diff
60 ];
61
62 mesonFlags = [
63 "-Dinstall-init-files=true"
64 "-Dinstall-state-dirs=false"
65 "-Dspecfile=false"
66 "-Dtools-multicall=true"
67 "-Dtools=false"
68 "-Dusernet-config-path=/etc/lxc/lxc-usernet"
69 "-Ddistrosysconfdir=${placeholder "out"}/etc/lxc"
70 "-Dsystemd-unitdir=${placeholder "out"}/lib/systemd/system"
71 ];
72
73 # /run/current-system/sw/share
74 postInstall = ''
75 substituteInPlace $out/etc/lxc/lxc --replace-fail "$out/etc/lxc" "/etc/lxc"
76 substituteInPlace $out/libexec/lxc/lxc-net --replace-fail "$out/etc/lxc" "/etc/lxc"
77
78 substituteInPlace $out/share/lxc/templates/lxc-download --replace-fail "$out/share" "/run/current-system/sw/share"
79 substituteInPlace $out/share/lxc/templates/lxc-local --replace-fail "$out/share" "/run/current-system/sw/share"
80 substituteInPlace $out/share/lxc/templates/lxc-oci --replace-fail "$out/share" "/run/current-system/sw/share"
81
82 substituteInPlace $out/share/lxc/config/common.conf --replace-fail "$out/share" "/run/current-system/sw/share"
83 substituteInPlace $out/share/lxc/config/userns.conf --replace-fail "$out/share" "/run/current-system/sw/share"
84 substituteInPlace $out/share/lxc/config/oci.common.conf --replace-fail "$out/share" "/run/current-system/sw/share"
85 '';
86
87 enableParallelBuilding = true;
88
89 doCheck = true;
90
91 passthru = {
92 tests = {
93 incus-lts = nixosTests.incus-lts.container;
94 lxc = nixosTests.lxc;
95 };
96
97 updateScript = nix-update-script {
98 extraArgs = [
99 "--version-regex"
100 "v(6\\.0\\.*)"
101 ];
102 };
103 };
104
105 meta = {
106 homepage = "https://linuxcontainers.org/";
107 description = "Userspace tools for Linux Containers, a lightweight virtualization system";
108 license = lib.licenses.gpl2;
109
110 longDescription = ''
111 LXC containers are often considered as something in the middle between a chroot and a
112 full fledged virtual machine. The goal of LXC is to create an environment as close as
113 possible to a standard Linux installation but without the need for a separate kernel.
114 '';
115
116 platforms = lib.platforms.linux;
117 teams = [ lib.teams.lxc ];
118 };
119})