Referring to a user's UID in NixOS
Solution
Please note:
- If referring to a user's UID this way, the UID needs to be explicitly defined (see example below)
- This example also shows how to convert the UID to a string for services that need it
{ config, pkgs, lib, ... }:
{
users.users = {
exampleuser = {
uid = 1005;
};
};
virtualisation.oci-containers.containers = {
exampleservice = {
environment = {
PUID = builtins.toString config.users.users.exampleuser.uid;
};
};
};
}