Difference between `pkgs.buildFHSEnv` and `pkgs.buildFHSUserEnv`

  1. Title
  2. What happens to files in the FHS-created directories (like /usr/lib and /usr/include) when the FHS environment is exited?
  3. Is there any way I can add something like a shell hook to the returned environment?
1 Like

What’s the difference between pkgs.buildFHSEnv and pkgs.buildFHSUserEnv?

None, they’re both the same thing, buildFHSUserEnv was renamed to buildFHSEnv in 23.05

What happens to files in the FHS-created directories (like /usr/lib and /usr/include) when the FHS environment is exited?

The FHS is made up of two parts:

  1. An immutable filesystem, that’s constructed as a derivation, only once. (ex: pkgs.steam.fhsenv)
  2. A script that enters that environment, using bubblewrap, mounting some directories like /etc.

So, what happens with the files inside those directories? Nothing, either the filesystem is read-only:

$ steam-run mkdir -p /usr/lib/test
mkdir: cannot create directory ‘/usr/lib/test’: Read-only file system

or it’s mounted somewhere:

$ steam-run sh -c 'echo hi! > ~/test'
$ cat ~/test
hi!

Is there any way I can add something like a shell hook to the returned environment?

I think you want the profile attribute, the opitons are documented here

6 Likes