Skip to content

fix: only mount the /etc entries that are actually needed#15

Open
netadr wants to merge 1 commit intoNaxdy:mainfrom
netadr:work/fix-etc-mounts
Open

fix: only mount the /etc entries that are actually needed#15
netadr wants to merge 1 commit intoNaxdy:mainfrom
netadr:work/fix-etc-mounts

Conversation

@netadr
Copy link
Copy Markdown
Contributor

@netadr netadr commented Jul 3, 2025

This patch simplifies the /etc entry mounts significantly and solves problems that can arise when /etc entries in the host are not just symlinks to the Nix store (e.g. when using systemd-resolved, /etc/resolv.conf links to /run/systemd/resolve/stub-resolv.conf -- this results in a broken symlink in the bwrapped fhsenv)

@netadr netadr force-pushed the work/fix-etc-mounts branch from 593827e to b7ee734 Compare July 3, 2025 20:09
@Naxdy
Copy link
Copy Markdown
Owner

Naxdy commented Jul 3, 2025

I'm a bit hesitant to change logic that's directly taken from nixpkgs, my thought process is that there's probably a reason as to why they did what they did.

If the problem you encounter is that some paths that you need are missing, you can always add them to your mounts FWIW (perhaps adding /run/systemd in general makes sense as well?)

@netadr
Copy link
Copy Markdown
Contributor Author

netadr commented Jul 3, 2025

I'm a bit hesitant to change logic that's directly taken from nixpkgs, my thought process is that there's probably a reason as to why they did what they did.

This is a fair concern. When I looked at it I figured they do the .host-etc redirection to support nested buildFHSEnv environments. I don't think this is a super common scenario, and other projects in the same vein (e.g. nixpak) don't provide special support for this. Probably worth investigating further before changing this behavior.

W/r/t mounting /run/systemd, I would personally rather find a smarter way to bind the /etc entries without breaking the symlinks (while maybe keeping the .host-etc bind mount that upstream buildFHSEnv uses)

@Naxdy
Copy link
Copy Markdown
Owner

Naxdy commented Jul 12, 2025

There's definitely something missing now as the CI is failing. I think a fair approach would be to list common directories within /run that might be needed by apps and mount them by default, in a similar fashion as done here:

mounts.read = [
"$HOME/.icons"
"$HOME/.fonts"
"$HOME/.themes"
"$HOME/.config/gtk-3.0"
"$HOME/.config/gtk-4.0"
"$HOME/.config/gtk-2.0"
"$HOME/.config/Kvantum"
"$HOME/.config/gtkrc-2.0"
"$HOME/.local/share/color-schemes"
];

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