Contributing to a project that uses nix (flakes), I use nix develop to get a shell where all the dependencies and tools are available to work on the project.
However, now, to debug the binary I am working on, I am trying to get a nix shell where ASLR is disabled.
(analogously, on a project that has shell.nix and use nix-shell, I would like to be able to do the same)
Unsatisfactory solution
On other Linux distros, I would use setarch "$(uname -m)" -R $(which bash) to get such a shell.
Right now, I can use that command before typing nix develop, and it works, but I am looking for a more nix-y solution…
Question(s)
How could I modify the flake.nix, or shell.nix for the shell to have ASLR disabled?
Could shellHook be leveraged to do that? (using directly the setarch... command aforementioned with stdenv.shell, or pkgs.bash gives me a broken shell - example below).
Also fixes the broken shell (still have to exit twice), and I get a bash shell, which is nice.
However, this pretty mysterious because man setarch explicitely says:
I don’t know if pkgs.mkShell can be be used in lieu of stdenv.mkDerivation in a flake.nix;
I just tried, and it seems to be working, but I am not 100% certain it is not messing anything under the hood…