nix-on-droid icon indicating copy to clipboard operation
nix-on-droid copied to clipboard

nix error getting status of /dev/cg2_bpf/cpu.max

Open Gerschtli opened this issue 3 years ago • 8 comments

Not sure what caused this regression, but I get this error on this command (and some other nix commands) on initial bootstrap. It does not occur for nix 2.10.*.

+ /nix/store/myr6fcqa9y4y2fb83zz73dck52vcn81z-nix-2.11.0/bin/nix-env --switch-profile /nix/var/nix/profiles/per-user/nix-on-droid/profile
error (ignored): error: getting status of /dev/cg2_bpf/cpu.max: Permission denied

Gerschtli avatar Oct 27 '22 16:10 Gerschtli

cg2 sounds like cgroupv2, and I attribute the whole affair to this function: https://github.com/NixOS/nix/blob/9dadb5481cdf848c409e6a7e4953acf4861923a5/src/libutil/util.cc#L726

cpu.max seems to be a CPU consumption throttling knob. Since throttling is transparent to the application subject to it, why would nix want to read it though is beyond me.

t184256 avatar Nov 06 '22 19:11 t184256

Damn, so looks like it is fairly hard to solve. I assume the path /dev/cg2_bpf is device specific? Or do you get the same? If it is always the same path, we could a fake file for this path.

❯ grep cgroup2 /proc/mounts
none /dev/cg2_bpf cgroup2 rw,nosuid,nodev,noexec,relatime 0 0

Gerschtli avatar Nov 06 '22 20:11 Gerschtli

No idea. Tried on one of my devices, and it's on /sys/fs/cgroup/, /sys/fs/cgroup/cpu.max isn't readable.

I think it might be worth discussing with Nix folks to understand what even is this thing before we take any measures.

t184256 avatar Nov 06 '22 21:11 t184256

I've the same issue on proot-distro alpine (still nix-2.11). Looks like it got fixed on nix-2.12 when I try on archlinux (x86).

DrSensor avatar Jan 05 '23 17:01 DrSensor

You are right, this fixes it:

{
  nix.package = pkgs.nixVersions.nix_2_12;
}

Gerschtli avatar Jan 05 '23 18:01 Gerschtli

You are right, this fixes it:

{
  nix.package = pkgs.nixVersions.nix_2_12;
}

Where do you insert this line? I tried in nix-on-droid.nix but it gives me an error when I try to build

M05QU170 avatar Jan 18 '23 10:01 M05QU170

nix-on-droid.nix is the correct place. Are you using a recent version of the nixos-22.11 channel/flake input? If updating the channel does not help, please post your config, nix-channel --list (or your flake.nix) and the error.

Gerschtli avatar Jan 18 '23 11:01 Gerschtli

nix-on-droid.nix is the correct place. Are you using a recent version of the nixos-22.11 channel/flake input? If updating the channel does not help, please post your config, nix-channel --list (or your flake.nix) and the error.

I have sorted out this. I didn't need curly brackets.

M05QU170 avatar Jan 18 '23 16:01 M05QU170