Skip to content

ceph: compile with systemd support flag#440226

Merged
nh2 merged 1 commit intoNixOS:masterfrom
josh:ceph-systemd
Oct 26, 2025
Merged

ceph: compile with systemd support flag#440226
nh2 merged 1 commit intoNixOS:masterfrom
josh:ceph-systemd

Conversation

@josh
Copy link
Contributor

@josh josh commented Sep 4, 2025

This patch turns on WITH_SYSTEMD=ON so that systemd units are generated under $out/lib/systemd/system. These upstream units would be compatible with systemd.packages inclusion, potentially usable by NixOS modules in the future (a larger integration not proposed here), or useful on non‑NixOS systems via tools like system-manager. The WITH_SYSTEMD=ON flag also enables some improved journald logging support as well.

Unfortunately, the unit definitions in the Ceph 19.2.3 release are not correctly prefixed at install time. However, this has already been fixed upstream to install using @CMAKE_INSTALL_PREFIX@. This patch backports that fix, allowing the patch to be safely dropped in the future when Ceph releases with the upstream change included.

Tested with/without withSystemd and ran ceph NixOS module related tests.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

Copilot AI review requested due to automatic review settings September 4, 2025 18:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables systemd support in the Ceph package by turning on the WITH_SYSTEMD=ON flag, which generates systemd unit files and improves journald logging. The change includes a backported fix to ensure unit files are properly prefixed with the Nix store path instead of hardcoded system paths.

  • Enable systemd support compilation flag with conditional withSystemd parameter
  • Backport upstream fix for systemd unit file prefix installation
  • Add systemd dependency and configuration for proper unit file generation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkgs/tools/filesystems/ceph/default.nix Add systemd dependency, withSystemd parameter, and enable systemd compilation with proper configuration
pkgs/tools/filesystems/ceph/ceph-systemd-prefix.patch Backported patch fixing systemd unit file paths to use CMAKE_INSTALL_PREFIX instead of hardcoded /usr paths

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@josh josh requested review from benaryorg and nh2 September 4, 2025 18:42
@nixpkgs-ci nixpkgs-ci bot added 2.status: merge conflict This PR has merge conflicts with the target branch 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. labels Sep 4, 2025
@nix-owners nix-owners bot requested review from adevress, johanot and krav September 4, 2025 18:48
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 4, 2025
@josh josh mentioned this pull request Sep 22, 2025
13 tasks
@benaryorg
Copy link
Contributor

As the commit is merged upstream already, I think using fetchpatch2 would be more appropriate to avoid the unsustainable growth of the nixpkgs repo.
That is, if the patch included here is taken verbatim from upstream, if changes had to be made for it to apply then vendoring it is of course reasonable.

I may have a look at this soon-ish, given that my cluster setup takes pains to side-step some of the systemd logic (for reasons), that way I could confirm whether or not this impacts anything other than the NixOS modules.
(where "no impact" is good of course)

@josh
Copy link
Contributor Author

josh commented Sep 29, 2025

That is, if the patch included here is taken verbatim from upstream, if changes had to be made for it to apply then vendoring it is of course reasonable.

Yeah, unfortunately I did have to make a small tweak to get it to apply cleanly.

given that my cluster setup takes pains to side-step some of the systemd logic (for reasons)

Ah yes, I feel like I can guess what some of those reasons might be 😁. I'm hoping to help smooth some of those other ceph tooling systemd expectations in the future. Thanks!

@benaryorg
Copy link
Contributor

I just had a short glance over the patch and noticed something odd so I compared it with upstream.
Why does the nixpkgs patch use the install prefix directly, rather than have the bin directory in between?

diff --git a/upstream b/pr
index c4d1e4f..9ceedac 100644
--- a/upstream
+++ b/pr
@@ -191,9 +169,9 @@ index 6644508cf0dea..0933676d2aca0 100644
 -ExecStart=/usr/bin/rbdmap map
 -ExecReload=/usr/bin/rbdmap map
 -ExecStop=/usr/bin/rbdmap unmap-all
-+ExecStart=@CMAKE_INSTALL_PREFIX@/bin/rbdmap map
-+ExecReload=@CMAKE_INSTALL_PREFIX@/bin/rbdmap map
-+ExecStop=@CMAKE_INSTALL_PREFIX@/bin/rbdmap unmap-all
++ExecStart=@CMAKE_INSTALL_PREFIX@/rbdmap map
++ExecReload=@CMAKE_INSTALL_PREFIX@/rbdmap map
++ExecStop=@CMAKE_INSTALL_PREFIX@/rbdmap unmap-all

  [Install]
  WantedBy=multi-user.target

You mentioned you had to adjust something, but I'm confused as to why there's this discrepancy given that there is a bin directory on our end too:

% find /nix/store/3c9migshmrcypwsvkql98n7l72ignhw1-ceph-19.2.2 -name rbdmap
/nix/store/3c9migshmrcypwsvkql98n7l72ignhw1-ceph-19.2.2/bin/rbdmap

I believe you that it's required (again, just had a glance at it, haven't even built it), it just looks strange to me and as if there's another issue hiding in our packaging perhaps (though it could be intentional as well, I'll have to have a look).

@josh
Copy link
Contributor Author

josh commented Oct 1, 2025

I just had a short glance over the patch and noticed something odd so I compared it with upstream.

Good catch! I'm going to switch this over to fetchpatch2 and include another patch that gets everything to apply cleanly.

Fixed in 0bb5395447bbff472f8a7689d134c8d21da3e04e

result/lib/systemd/system/rbdmap.service
[Unit]
Description=Map RBD devices
After=network-online.target ceph.target
Before=remote-fs-pre.target
Wants=network-online.target remote-fs-pre.target ceph.target

[Service]
EnvironmentFile=-/etc/sysconfig/ceph
Environment=RBDMAPFILE=/etc/ceph/rbdmap
Type=oneshot
RemainAfterExit=yes
ExecStart=/nix/store/v6wg7bn7kqng5q9sdfr686b3xk9zmlm0-ceph-19.2.3/bin/rbdmap map
ExecReload=/nix/store/v6wg7bn7kqng5q9sdfr686b3xk9zmlm0-ceph-19.2.3/bin/rbdmap map
ExecStop=/nix/store/v6wg7bn7kqng5q9sdfr686b3xk9zmlm0-ceph-19.2.3/bin/rbdmap unmap-all

[Install]
WantedBy=multi-user.target

I also did find one more bug in [email protected], but I'm working to get that fixed upstream.

@josh josh force-pushed the ceph-systemd branch 2 times, most recently from 9a6f699 to 610063e Compare October 21, 2025 00:33
@josh
Copy link
Contributor Author

josh commented Oct 21, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 440226
Commit: 610063e1c875022ee55550ebb101b0a376fec3b5


x86_64-linux

✅ 14 packages built:
  • ceph (ceph-dev)
  • ceph-client
  • ceph-csi
  • ceph.dev (ceph-dev.dev)
  • ceph.doc (ceph-dev.doc)
  • libceph (ceph.lib, libceph.dev, libceph.doc, libceph.lib, libceph.man)
  • ceph.man (ceph-dev.man)
  • qemu_full
  • qemu_full.debug
  • qemu_full.doc
  • qemu_full.ga
  • sambaFull (samba4Full)
  • sambaFull.dev (samba4Full.dev)
  • sambaFull.man (samba4Full.man)

aarch64-linux

✅ 10 packages built:
  • ceph (ceph-dev)
  • ceph-client
  • ceph-csi
  • ceph.dev (ceph-dev.dev)
  • ceph.doc (ceph-dev.doc)
  • libceph (ceph.lib, libceph.dev, libceph.doc, libceph.lib, libceph.man)
  • ceph.man (ceph-dev.man)
  • qemu_full
  • qemu_full.doc
  • qemu_full.ga

@benaryorg benaryorg mentioned this pull request Oct 25, 2025
13 tasks
@nh2
Copy link
Contributor

nh2 commented Oct 26, 2025

I'm clicking "Merge when ready". Ofborg on Linux is already green.

@nh2 nh2 added this pull request to the merge queue Oct 26, 2025
Merged via the queue into NixOS:master with commit 102a9fc Oct 26, 2025
28 of 30 checks passed
@josh josh deleted the ceph-systemd branch October 26, 2025 16:53
@josh
Copy link
Contributor Author

josh commented Oct 26, 2025

Thanks @nh2 @benaryorg!

I'll be curious to hear from anyone who ends up testing these new units directly what they think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

4 participants