Need to run programm with root privileges inside nix-shell

Hi everyone!

i am very new to nix/nixos and my google fu was not strong enough to solve this.

i got this shell.nix:

{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  name="dev-environment";
  buildInputs = [
    pkgs.dotnet-sdk_3
    pkgs.unzip
    pkgs.gnumake
    pkgs.fzf
  ];
  shellHook = ''
    echo "Happy Hackin'!"
  '';
  }

i am working on an f# programm that pings some hosts, i can run ping as user but the programm fails.
So i need to run my programm with root privileges.
But:

  • If i am not inside nix-shell i can’t run the programm as i do not have dotnet installed globaly.
  • If i run nix-shell as root or with sudo i can run ‘dotnet run’ but my “ide” can’t.

How can i manage to run my programm with the privileges it needs?