Skip to content

Conversation

@bmrips
Copy link
Contributor

@bmrips bmrips commented Oct 31, 2025

Description

This PR accomplishes two things:

  • Replace the string-based systemd.user.tmpfiles.rules option by an RFC42-style systemd.user.tmpfiles.settings option.

  • Add an systemd.user.tmpfiles.settings.<config-name>.purgeOnChange option to purge the targets of rules on change.

    An example use case of this feature is the programs.glab module: It utilizes tmpfiles to set non-default permissions for its config file. With this PR, the module would be able to reliably remove the config file when it is empty or the module disabled.

The overall structure of the new option (including its defaults) is

systemd.user.tmpfiles.settings."<config-name>" = {
  rules."<path>"."<tmpfiles-type>" = {
    mode = "-";
    user = "-";
    group = "-";
    age = "-";
    argument = "";
  };
  purgeOnChange = false;
};

It resembles NixOS' systemd.tmpfiles.settings option; the only difference is the inserted { rules = ...; purgeOnChange = ...; } submodule to configure purging.

The reason I packed both changes in the same PR is to minimize backwards incompatibilities.

This PR is an advancement of #8084.

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

@khaneliman khaneliman merged commit b5ed4af into nix-community:master Nov 3, 2025
7 checks passed
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