kini
January 6, 2022, 8:10am
1
What is the significance of the directory /etc/profiles/per-user/$USER
? It doesn’t seem to exist on my NixOS system, but it’s added to $NIX_PROFILES
(via the NixOS option environment.profiles
) by the following code from nixos/modules/config/users-groups.nix
in nixpkgs:
environment.profiles = [
"$HOME/.nix-profile"
"/etc/profiles/per-user/$USER"
];
I don’t see any mention of it in the NixOS manual, nixpkgs manual, nix manual, nixpkgs source code, or nix source code (except the above snippet from the nixpkgs source code).
/etc/profiles/per-user/$USER get created when you configure per user packages.
isNormalUser = true;
packages = [
pkgs.coway
];
};
Maybe that should be documented somewhere, it’s quite automagical.
A unrelated bug to your questions that was fixed , thats also good for info/reference.
opened 10:59PM - 21 Dec 20 UTC
closed 11:45AM - 15 Feb 21 UTC
0.kind: bug
6.topic: nixos
If you set users.users.\<name\>.packages to include a set of per-user packages, … and proceed to define a value for user.users.<name>.name, the packages will not be available on the user.
Considering this example for a configuration.nix :
```
users.users.Foo = {
isNormalUser = true;
name = "Bar";
description = "Eighty Eight";
createHome = true;
home = "/home/FooBar";
packages = [
pkgs.cmatrix
];
};
```
You would expect nixos-rebuild to:
1. create a user named 'Bar'
2. create a home-folder named 'FooBar'
3. symlink cmatrix into the per-user folder : /etc/profiles/per-user/**Bar**/
However Instead of this, it will:
1. create a user named 'Bar'
2. create a home-folder named 'FooBar'
3. symlink cmatrix into the per-user folder : /etc/profiles/per-user/**Foo**/
As such, the per user folder **Bar** does not exist, and the user does not have the expected packages available
A brief investigation shows the error appears to be Here :
https://github.com/NixOS/nixpkgs/blob/583470209f9d51f1c6884e0afb5a9949ac988bcd/nixos/modules/config/users-groups.nix#L583
A few lines above the ${name} attribute is used however:
https://github.com/NixOS/nixpkgs/blob/583470209f9d51f1c6884e0afb5a9949ac988bcd/nixos/modules/config/users-groups.nix#L572
This is using the attribute name (users.users.**Foo**) rather than the users.users.name ( value to create the relevant folder.
**Metadata**
Please run `nix-shell -p nix-info --run "nix-info -m"` and paste the result.
- system: `"x86_64-linux"`
- host os: `Linux 5.4.80, NixOS, 20.09.2122.2fbcd0b9df9 (Nightingale)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.3.9`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Maintainer information:
```yaml
# a list of nixpkgs attributes affected by the problem
attribute: users.users
# a list of nixos modules affected by the problem
module: users-groups.nix
```
1 Like