Skip to content

Conversation

@gs-101
Copy link

@gs-101 gs-101 commented Dec 22, 2025

Opening up support for other init systems.

Description

This PR outlines GPU driver support for Linux distros featuring an init system other than systemd.

The first supported init system is GNU Shepherd, as it's the default init system on GNU Guix.

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt deadnix keep-sorted --run treefmt.

  • Code tested through nix run .#tests -- test-all or
    nix-shell --pure tests -A run.all.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.
    • Generate a news entry. See News
    • Basic tests added. See Tests
  • If this PR adds an exciting new feature or contains a breaking change.

    • Generate a news entry. See News

@home-manager-ci home-manager-ci bot requested a review from exzombie December 22, 2025 20:05
@gs-101 gs-101 marked this pull request as draft December 22, 2025 20:05
@gs-101
Copy link
Author

gs-101 commented Dec 22, 2025

Some things of note:

  1. I didn't install the Shepherd file because Shepherd doesn't really have a "services"
    directory, it has files1 (viz. /etc/shepherd.scm and $XDG_CONFIG_HOME/shepherd/init.scm). So we don't really have a standard place to install the file (do we place it under a /etc/shepherd/? or under $XDG_CONFIG_HOME/shepherd/init.d?).
  2. I added a iniSystem option as recommended2, but I'm not sure of how we should handle it. Lazyness took me over and I just started copying files all over (even renaming non-nixos-gpu-setup to non-nixos-gpu-setup-systemd!) but that seems impractical. Just too much duplication.

Footnotes

  1. https://shepherding.services/manual/html_node/Invoking-shepherd.html

  2. https://github.com/nix-community/home-manager/pull/8057#issuecomment-3681399116

@gs-101 gs-101 force-pushed the feat/non-nixos-gpu-shepherd branch from 291fa1d to eb7ba57 Compare December 22, 2025 20:25
@gs-101
Copy link
Author

gs-101 commented Dec 22, 2025

Changed "shepherd" to "GNU Shepherd" and reworded the long description of the
news commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I didn't install the Shepherd file because doesn't really have a "services"
    directory, it has files1 (viz. /etc/shepherd.scm and $XDG_CONFIG_HOME/shepherd/init.scm). So we don't really have a standard place to install the file (do we place it under a /etc/shepherd/? or under $XDG_CONFIG_HOME/shepherd/init.d?).

Not being a user of Guix, I can't tell you where to symlink the service definition. But you must have a symlink somewhere so that you can create a gcroot. Without it, Nix will garbage-collect the drivers at some point, and you will be left with a broken system after reboot.

Perhaps the setup script can add the link somewhere in /etc, then add the service to the Guix configuration. Or instruct the user how to do add it. And to run sudo guix system reconfigure on update, or something like that.

Perhaps Guix experts can provide some ideas on how to do this in an automated manner?

Copy link
Author

Choose a reason for hiding this comment

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

Perhaps the setup script can add the link somewhere in /etc [...]

Makes more sense, since it's a service closer to the system. /etc/shepherd/non-nixos-gpu.scm.

[...] how to do this in an automated manner?

Not sure on how to automate this, but i'll try this setup for non-nixos-gpu-setup on my system:

#!/bin/bash

set -e

# Install the Shepherd service file and ensure that the store path won't be
# garbage-collected as long as it's installed.
unit_path=/etc/shepherd/non-nixos-gpu.scm
ln -sf @@resources@@/non-nixos-gpu.scm "$unit_path"
ln -sf "$unit_path" "@@statedir@@"/gcroots/non-nixos-gpu.scm

herd load root /etc/shepherd/non-nixos-gpu.scm

I didn't run any "update" commands because just by running this herd load the files were added to /run/opengl-driver.

I'll experiment with home-manager on a test branch.

Copy link
Author

Choose a reason for hiding this comment

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

I got the service to install the drivers at /run/opengl-driver but I couldn't make it update them.
I tried to delete (rm -rf) the /run/opengl-driver, but that just nuked my graphical environment.

@gs-101 gs-101 force-pushed the feat/non-nixos-gpu-shepherd branch from eb7ba57 to d9b406a Compare December 23, 2025 19:56
@gs-101 gs-101 force-pushed the feat/non-nixos-gpu-shepherd branch 2 times, most recently from 20a669f to e858a35 Compare December 23, 2025 20:37
Also encourage contribution for other init systems.
@gs-101 gs-101 force-pushed the feat/non-nixos-gpu-shepherd branch from e858a35 to 7334f62 Compare December 23, 2025 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants