Skip to content

nixos/k3s,rke2: clean up manifests via /etc on config changes#520433

Open
yajo wants to merge 1 commit into
NixOS:masterfrom
moduon:k3s-manifest-removal
Open

nixos/k3s,rke2: clean up manifests via /etc on config changes#520433
yajo wants to merge 1 commit into
NixOS:masterfrom
moduon:k3s-manifest-removal

Conversation

@yajo

@yajo yajo commented May 15, 2026

Copy link
Copy Markdown
Contributor

Before, when a manifest was removed from NixOS configuration, its symlink
still remained inside /var/lib/rancher/k3s/server/manifests.

Manifests are now managed declaratively through a linkFarm in the Nix store:

  • Static symlink: manifests/nixos → linkFarm in Nix store
  • k3s/rke2 scan subdirectories recursively, pick up changes within 15s

When manifests are removed from the config, the linkFarm derivation
changes, the activation script updates the symlink, and the stale files
disappear naturally — no dangling symlinks.

@moduon MT-14138

This pull request was partially written with LLM assistance (opencode). The author reviewed and maintains all generated code.

@nixpkgs-ci nixpkgs-ci Bot requested review from a team, maevii, rorosen, stefan-bordei and zimbatm May 15, 2026 13:03
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: k3s Kubernates distribution (https://k3s.io/) labels May 15, 2026
@yajo yajo force-pushed the k3s-manifest-removal branch from 59ce69a to 799b1ad Compare May 19, 2026 12:56
@yajo yajo changed the title nixos/k3s: clean up manifests when updating nixos/k3s,rke2: clean up manifests via /etc on config changes May 19, 2026

@rorosen rorosen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, this is a good improvement. It should have been done like this from the beginning tbh. Unfortunately, k3s didn't follow symlinked manifest directories back then.

However, since previous symlinks will remain in the manifest directory, users could end up with conflicting manifest contents. There should be a migration guide on how to remove previous symlinks, e.g. in the release notes.

Please check also formatting

Comment thread nixos/modules/services/cluster/rancher/default.nix Outdated
Comment thread nixos/modules/services/cluster/rancher/default.nix Outdated

@maevii maevii left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for transparency's sake, was this PR LLM-assisted? See the policy, non-trivial LLM usage should be disclosed.

Comment thread nixos/modules/services/cluster/rancher/default.nix Outdated
Comment thread nixos/tests/rancher/default.nix Outdated
@yajo

yajo commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Hi there! Thanks for the reviews. Hold on while I attend the suggestions please.

Just for transparency's sake, was this PR LLM-assisted?

Yes, the policy was merged some days after I opened the PR, I didn't know about that back then.

@yajo yajo force-pushed the k3s-manifest-removal branch from 799b1ad to 924e6b1 Compare June 18, 2026 08:04
Manifests are now managed declaratively through a linkFarm in the Nix store:
- Static symlink: manifests/nixos → linkFarm in Nix store
- k3s/rke2 scan subdirectories recursively, pick up changes within 15s

When manifests are removed from the config, the linkFarm derivation
changes, the activation script updates the symlink, and the stale files
disappear naturally — no dangling symlinks.

@moduon MT-14138
@nixpkgs-ci nixpkgs-ci Bot added 2.status: merge conflict This PR has merge conflicts with the target branch 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation labels Jun 18, 2026
@yajo yajo force-pushed the k3s-manifest-removal branch from 924e6b1 to 24444a4 Compare June 18, 2026 08:19

@yajo yajo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments attended.

  • Formatting fixed.
  • Test merged with auto-deploy.nix
  • Release notes.
  • /etc intermediate symlink removed

@yajo

yajo commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

IIUC CI failures are not related to my changes.

@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: k3s Kubernates distribution (https://k3s.io/) 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants