From 9e9774ee89f3e84794e8bdd3496d75f822fd4e2f Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 16 Nov 2024 18:33:28 -0500 Subject: [PATCH 01/13] containerd: format with nixfmt --- pkgs/by-name/co/containerd/package.nix | 34 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index ad2a338ba8fb..7e0f530f8a4e 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -1,12 +1,13 @@ -{ lib -, fetchFromGitHub -, buildGoModule -, btrfs-progs -, go-md2man -, installShellFiles -, util-linux -, nixosTests -, kubernetes +{ + lib, + btrfs-progs, + buildGoModule, + fetchFromGitHub, + go-md2man, + installShellFiles, + kubernetes, + nixosTests, + util-linux, }: buildGoModule rec { @@ -22,7 +23,11 @@ buildGoModule rec { vendorHash = null; - nativeBuildInputs = [ go-md2man installShellFiles util-linux ]; + nativeBuildInputs = [ + go-md2man + installShellFiles + util-linux + ]; buildInputs = [ btrfs-progs ]; @@ -43,14 +48,19 @@ buildGoModule rec { runHook postInstall ''; - passthru.tests = { inherit (nixosTests) docker; } // kubernetes.tests; + passthru.tests = { + inherit (nixosTests) docker; + } // kubernetes.tests; meta = with lib; { changelog = "https://github.com/containerd/containerd/releases/tag/${src.rev}"; homepage = "https://containerd.io/"; description = "Daemon to control runC"; license = licenses.asl20; - maintainers = with maintainers; [ offline vdemeester ]; + maintainers = with maintainers; [ + offline + vdemeester + ]; platforms = platforms.linux; }; } From d697b384d57a5cb26ca5e600da02288a88f4cc9e Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 16 Nov 2024 18:33:49 -0500 Subject: [PATCH 02/13] containerd: 1.7.23 -> 2.0.0 This release contains breaking changes. See the full [containerd 2.0](https://github.com/containerd/containerd/blob/main/docs/containerd-2.0.md) documentation for more Diff: https://github.com/containerd/containerd/compare/v1.7.23...v2.0.0 Changelog: https://github.com/containerd/containerd/releases/tag/v2.0.0 --- nixos/doc/manual/release-notes/rl-2505.section.md | 4 ++++ pkgs/by-name/co/containerd/package.nix | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index d55b5bfd42a7..c9760938b750 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -35,6 +35,10 @@ [v1.7.0](https://github.com/jtroo/kanata/releases/tag/v1.7.0) for more information. +- `containerd` has been updated to v2, which contains breaking changes. See the [containerd + 2.0](https://github.com/containerd/containerd/blob/main/docs/containerd-2.0.md) documentation for more + details. + - the notmuch vim plugin now lives in a separate output of the `notmuch` package. Installing `notmuch` will not bring the notmuch vim package anymore, add `vimPlugins.notmuch-vim` to your (Neo)vim configuration if you want the diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index 7e0f530f8a4e..9fcc063343ca 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -12,13 +12,13 @@ buildGoModule rec { pname = "containerd"; - version = "1.7.23"; + version = "2.0.0"; src = fetchFromGitHub { owner = "containerd"; repo = "containerd"; rev = "v${version}"; - hash = "sha256-vuOefU1cZr1pKCYHKyDBx/ohghgPlXhK3a38PQKH0pc="; + hash = "sha256-DFAP+zjBYP2SpyD8KXGvI3i/PUZ6d4jdzGyFfr1lzj4="; }; vendorHash = null; From 5db7ee7410228267ec448abe6413e98e901b813c Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 16 Nov 2024 20:19:30 -0500 Subject: [PATCH 03/13] containerd: use standard attributes for make Instead of inlining flags and targets, we can use standard attributes and emulate `mkDerivations`'s default build and install phases to make maintaining and overriding the expression much easier --- pkgs/by-name/co/containerd/package.nix | 27 ++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index 9fcc063343ca..25f067e14d23 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -4,7 +4,6 @@ buildGoModule, fetchFromGitHub, go-md2man, - installShellFiles, kubernetes, nixosTests, util-linux, @@ -21,30 +20,42 @@ buildGoModule rec { hash = "sha256-DFAP+zjBYP2SpyD8KXGvI3i/PUZ6d4jdzGyFfr1lzj4="; }; + postPatch = "patchShebangs ."; + vendorHash = null; nativeBuildInputs = [ go-md2man - installShellFiles util-linux ]; buildInputs = [ btrfs-progs ]; - BUILDTAGS = lib.optionals (btrfs-progs == null) [ "no_btrfs" ]; + tags = lib.optionals (btrfs-progs == null) [ "no_btrfs" ]; + + makeFlags = [ + "PREFIX=${placeholder "out"}" + + "BUILDTAGS=${toString tags}" + "REVISION=${src.rev}" + "VERSION=v${version}" + ]; + + installTargets = [ + "install" + "install-doc" + "install-man" + ]; buildPhase = '' runHook preBuild - patchShebangs . - make binaries "VERSION=v${version}" "REVISION=${src.rev}" + make $makeFlags runHook postBuild ''; installPhase = '' runHook preInstall - install -Dm555 bin/* -t $out/bin - installShellCompletion --bash contrib/autocomplete/ctr - installShellCompletion --zsh --name _ctr contrib/autocomplete/zsh_autocomplete + make $makeFlags $installTargets runHook postInstall ''; From 7d3a899c10541faeb495d201f0e25dd99c8d5fc5 Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 16 Nov 2024 20:36:59 -0500 Subject: [PATCH 04/13] containerd: use best practices --- pkgs/by-name/co/containerd/package.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index 25f067e14d23..61e7ecd407e8 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -16,7 +16,7 @@ buildGoModule rec { src = fetchFromGitHub { owner = "containerd"; repo = "containerd"; - rev = "v${version}"; + rev = "refs/tags/v${version}"; hash = "sha256-DFAP+zjBYP2SpyD8KXGvI3i/PUZ6d4jdzGyFfr1lzj4="; }; @@ -24,6 +24,8 @@ buildGoModule rec { vendorHash = null; + strictDeps = true; + nativeBuildInputs = [ go-md2man util-linux @@ -63,15 +65,15 @@ buildGoModule rec { inherit (nixosTests) docker; } // kubernetes.tests; - meta = with lib; { - changelog = "https://github.com/containerd/containerd/releases/tag/${src.rev}"; - homepage = "https://containerd.io/"; + meta = { description = "Daemon to control runC"; - license = licenses.asl20; - maintainers = with maintainers; [ + homepage = "https://containerd.io/"; + changelog = "https://github.com/containerd/containerd/releases/tag/${version}"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ offline vdemeester ]; - platforms = platforms.linux; + platforms = lib.platforms.linux; }; } From 429c01fff2abe089924fa8ea24ef166e8d0ef873 Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 16 Nov 2024 20:37:34 -0500 Subject: [PATCH 05/13] containerd: add updateScript --- pkgs/by-name/co/containerd/package.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index 61e7ecd407e8..e508cdedaecc 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -5,6 +5,7 @@ fetchFromGitHub, go-md2man, kubernetes, + nix-update-script, nixosTests, util-linux, }: @@ -61,9 +62,13 @@ buildGoModule rec { runHook postInstall ''; - passthru.tests = { - inherit (nixosTests) docker; - } // kubernetes.tests; + passthru = { + tests = { + inherit (nixosTests) docker; + } // kubernetes.tests; + + updateScript = nix-update-script { }; + }; meta = { description = "Daemon to control runC"; From 5fe62be1168b9f885dd192fdb0e6dc68704bdb73 Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 16 Nov 2024 20:38:06 -0500 Subject: [PATCH 06/13] containerd: add override for btrfs support Having an explicit attribute to override for btrfs support is much more user friendly --- pkgs/by-name/co/containerd/package.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index e508cdedaecc..a1e387aa94c7 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -8,6 +8,7 @@ nix-update-script, nixosTests, util-linux, + btrfsSupport ? btrfs-progs != null, }: buildGoModule rec { @@ -32,9 +33,9 @@ buildGoModule rec { util-linux ]; - buildInputs = [ btrfs-progs ]; + buildInputs = lib.optional btrfsSupport btrfs-progs; - tags = lib.optionals (btrfs-progs == null) [ "no_btrfs" ]; + tags = lib.optional (!btrfsSupport) "no_btrfs"; makeFlags = [ "PREFIX=${placeholder "out"}" From 514c2e5835739e57326a0eb6172e182249d5824c Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 16 Nov 2024 20:54:20 -0500 Subject: [PATCH 07/13] containerd: split outputs --- pkgs/by-name/co/containerd/package.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index a1e387aa94c7..e2e812d646f7 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -15,6 +15,12 @@ buildGoModule rec { pname = "containerd"; version = "2.0.0"; + outputs = [ + "out" + "doc" + "man" + ]; + src = fetchFromGitHub { owner = "containerd"; repo = "containerd"; From eb399ae2b22273b93f2aa889f57ea61629f09ec4 Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 16 Nov 2024 20:58:37 -0500 Subject: [PATCH 08/13] containerd: add meta.mainProgram --- pkgs/by-name/co/containerd/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index e2e812d646f7..c2033f38cdeb 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -86,6 +86,7 @@ buildGoModule rec { offline vdemeester ]; + mainProgram = "containerd"; platforms = lib.platforms.linux; }; } From 845831e7822fa2ba8e964c8e9f0292ac11c2aac3 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 17 Nov 2024 16:08:43 -0500 Subject: [PATCH 09/13] docker: only install containerd binaries Previously this override was broken as it was trying to use `make install-doc` in a v1 source, while that target was introduced in v2. This is fixed by only running `make install` for the binaries -- as documentation is pointless in this build anyways --- pkgs/applications/virtualization/docker/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/applications/virtualization/docker/default.nix b/pkgs/applications/virtualization/docker/default.nix index 36afd5bedcdf..75ef93f3d139 100644 --- a/pkgs/applications/virtualization/docker/default.nix +++ b/pkgs/applications/virtualization/docker/default.nix @@ -53,6 +53,9 @@ rec { pname = "docker-containerd"; inherit version; + # We only need binaries + outputs = [ "out" ]; + src = fetchFromGitHub { owner = "containerd"; repo = "containerd"; @@ -62,6 +65,9 @@ rec { buildInputs = oldAttrs.buildInputs ++ lib.optionals withSeccomp [ libseccomp ]; + + # See above + installTargets = "install"; }); docker-tini = tini.overrideAttrs { From 0422fd66356ad4adcc9c53cd05deabd6bbd89f49 Mon Sep 17 00:00:00 2001 From: seth Date: Sun, 17 Nov 2024 16:26:18 -0500 Subject: [PATCH 10/13] containerd: add getchoo to maintainers --- pkgs/by-name/co/containerd/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index c2033f38cdeb..33d9a5f335c0 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -85,6 +85,7 @@ buildGoModule rec { maintainers = with lib.maintainers; [ offline vdemeester + getchoo ]; mainProgram = "containerd"; platforms = lib.platforms.linux; From 3f48f68ef056e8163334ebb64721282e4a05c188 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 18 Nov 2024 22:02:41 -0500 Subject: [PATCH 11/13] containerd: conditionally build manpages An in-tree binary is used to build some manpages, which won't work when cross compiling unless the buildPlatform can execute code for the hostPlatform --- pkgs/by-name/co/containerd/package.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index 33d9a5f335c0..801243e5bfce 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -1,5 +1,6 @@ { lib, + stdenv, btrfs-progs, buildGoModule, fetchFromGitHub, @@ -9,6 +10,7 @@ nixosTests, util-linux, btrfsSupport ? btrfs-progs != null, + withMan ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, }: buildGoModule rec { @@ -18,8 +20,7 @@ buildGoModule rec { outputs = [ "out" "doc" - "man" - ]; + ] ++ lib.optional withMan "man"; src = fetchFromGitHub { owner = "containerd"; @@ -35,9 +36,8 @@ buildGoModule rec { strictDeps = true; nativeBuildInputs = [ - go-md2man util-linux - ]; + ] ++ lib.optional withMan go-md2man; buildInputs = lib.optional btrfsSupport btrfs-progs; @@ -54,8 +54,7 @@ buildGoModule rec { installTargets = [ "install" "install-doc" - "install-man" - ]; + ] ++ lib.optional withMan "install-man"; buildPhase = '' runHook preBuild From 711aab6d45fc590c91d7b70eaf2e5f9bb31a4597 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 18 Nov 2024 22:05:05 -0500 Subject: [PATCH 12/13] containerd: add cross compilation tests --- pkgs/by-name/co/containerd/package.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/co/containerd/package.nix b/pkgs/by-name/co/containerd/package.nix index 801243e5bfce..d11a60b9e064 100644 --- a/pkgs/by-name/co/containerd/package.nix +++ b/pkgs/by-name/co/containerd/package.nix @@ -1,6 +1,7 @@ { lib, stdenv, + pkgsCross, btrfs-progs, buildGoModule, fetchFromGitHub, @@ -69,9 +70,18 @@ buildGoModule rec { ''; passthru = { - tests = { - inherit (nixosTests) docker; - } // kubernetes.tests; + tests = lib.optionalAttrs stdenv.hostPlatform.isLinux ( + { + cross = + let + systemString = if stdenv.buildPlatform.isAarch64 then "gnu64" else "aarch64-multiplatform"; + in + pkgsCross.${systemString}.containerd; + + inherit (nixosTests) docker; + } + // kubernetes.tests + ); updateScript = nix-update-script { }; }; From 328ebf20943c882e6727d6f99061e31f8395f864 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 18 Nov 2024 22:21:42 -0500 Subject: [PATCH 13/13] nixos/containerd: load after `local-fs.target` & `dbus.service` https://github.com/containerd/containerd/commit/18e4ea9a6c5378a175e5090ca4052d0b2ff742df --- nixos/modules/virtualisation/containerd.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/containerd.nix b/nixos/modules/virtualisation/containerd.nix index 73fb9f3b55d2..edb22a855d54 100644 --- a/nixos/modules/virtualisation/containerd.nix +++ b/nixos/modules/virtualisation/containerd.nix @@ -67,7 +67,7 @@ in systemd.services.containerd = { description = "containerd - container runtime"; wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; + after = [ "network.target" "local-fs.target" "dbus.service" ]; path = with pkgs; [ containerd runc