From Fedora Project Wiki


Use systemd for managing per-user environment variables

This is a rejected Change proposal for Fedora Linux.
This document represents a proposed Change that has been rejected or withdrawn as part of the Changes process. This page is preserved for historical record.

Summary

Rely on systemd's systemd.environment-generator functionality for managing per-user environment variables (such as appending ~/local/.bin and ~/bin to a user's $PATH) instead of individual shellrc scripts (~/.bashrc, ~/.zshrc etc).

Owner

  • Name: Faeiz Mahrus
  • Email: faeizmahrus@proton.me, me@faeizmahrus.bd


Current status

Detailed Description

Currently, Fedora relies on shellrc scripts (~/.bashrc, ~/.zshrc files) for modifying an user's environment variables.
An example of such a case is appending ~/.local/bin and ~/bin directories to $PATH

Such shellrc scripts have only been packaged for the bash and zsh shells. (rpm -qf /etc/skel/{.bashrc,.zshrc} returns packages bash and zsh)
However, Fedora Linux also offers several alternative shells such as fish, nushell (nu), xonsh, dash etc, for which shellrc scripts have not been packaged.
This leads to a situation where an user might change their login shell and be unable to directly launch scripts and programs stored in ~/.local/bin and ~/bin

systemd provides a mechanism for applying environment variables to all user processes via systemd.environment-generator.
Creating simple drop-in file(s) in the /etc/skel/.config/environment.d/ directory is a simpler and much cleaner way for both managing environment variables for an user and for mitigating the $PATH environment variable propagation issue for alternative shells.

THIS PARAGRAPH IS OUT OF SCOPE FOR THE CURRENT CHANGE AND IS ONLY AN IDEA FOR A FUTURE CHANGE THAT MAY OR MAY NOT BE IMPLEMENTED: Although out of scope for this specific proposal, the broader goal will be to ultimately move as much cruft possible out of shellrc scripts scattered across the filesystem at different places and /etc/profile into environment-generators

Feedback

Will be updated later.

Benefit to Fedora

This change simplifies per-user environment variable propagation and makes environment variable changes independant of an user's default shell.

Scope

  • Proposal owners:

Modify the /etc/skel/.*rc files located in the bash and zsh packages, modifying them to either remove any environment variable modification parts or splitting those parts into separate subpackages. Search for any other packages that also modify environemt variables by shellrc scripts.

  • Other developers:

Coordinate with the respective package maintainers.

Most likely no.

  • Policies and guidelines: N/A (not needed for this Change)
  • Trademark approval: N/A (not needed for this Change)
  • Alignment with the Fedora Strategy:

Upgrade/compatibility impact

None.

Early Testing (Optional)

Do you require 'QA Blueprint' support? N

How To Test

Will be added later.


User Experience

Cleaner shellrc files will ease management for users.

Dependencies

Will be updated later.

Contingency Plan

  • Contingency mechanism: (What to do? Who will do it?)

Revert the change. (not a System Wide Change)

  • Contingency deadline: Beta freeze (not a System Wide Change)
  • Blocks release? N/A (not a System Wide Change), Yes/No

Documentation

N/A (not a System Wide Change)

Release Notes

Moved per-user environment variable handling to systemd.environment-generator