nix-community / nix-on-droid

Nix-enabled environment for your Android device. [maintainers=@t184256,@Gerschtli]
https://nix-on-droid.unboiled.info
MIT License
1.16k stars 65 forks source link

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

Open Gerschtli opened 1 year ago

Gerschtli commented 1 year ago

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
t184256 commented 1 year ago

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.

Gerschtli commented 1 year ago

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
t184256 commented 1 year ago

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.

DrSensor commented 1 year ago

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).

Gerschtli commented 1 year ago

You are right, this fixes it:

{
  nix.package = pkgs.nixVersions.nix_2_12;
}
M05QU170 commented 1 year ago

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

Gerschtli commented 1 year ago

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.

M05QU170 commented 1 year ago

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.