Hi
I would like to build the hostname of a machine based on its serial-number.
Before nixpkgs 24.11 was released, i used to read file from sysfs to obtain the requiered values ( e.g. /sys/class/dmi/id/chassis_serial
). However, with the new version of nixpkgs this is no longer possible and i’m searching for an alternative solution.
I’m considering using dmidecode
. To achieve this, I created a file in nix store and that can be accessed from my NixOS config. However dmidecode
requires read access to the /dev/mem
file which is restricted to users in the kmem
group. During the build process, i noticed that the nixbld
user doesn’t belong to this group.
It is possible to add nixbld
user to kmem
group ?
FYI : I tried to do this by overriding all nixbldX
user with the following config :
{ config, lib, ... }:
...
# Add nixbuild to kmem groups
users.extraUsers = builtins.listToAttrs ( lib.lists.forEach ( ( builtins.genList (x: x+1) config.nix.nrBuildUsers ) ++ [""] )
(i:{
name = "nixbld${builtins.toString i}";
value = {
uid = if i == "" then 1000 else null;
group = "nixbld";
isSystemUser = true;
extraGroups = ["kmem"];
};
})
);
Unfortunately, this approach did not work. The build user nixbld
with uid 1000, only belongs to the nixbld
group.
Thanks in advance! How can I resolve this?