Change:
${cfg.extraConfig} ''; #TODO: validation on compilation (at least against typos) <del> services.dbus.packages = [ pkgs.polkit.out ]; </del> <ins> services.dbus.packages = [ cfg.package.out ]; </ins> security.pam.services.polkit-1 = {};

Discussion:
Running gives you: I don't have a graphical polkit agent running, so should fallback onto . However it doesn't seem to work in this case. Note that to make it work, I have to run in a different terminal binding to the PID of the first terminal that is running , and that terminal will show the same workflow but will have succeeded at authentication. But this shouldn't be necessary as the should just work on the original terminal when called by .
I'm trying to run hdajackretask to get the internal audio working on my system and before I downgraded back to 17.03 I couldn't even get it to run, now that it's running when I try to apply a configuration and type my password root or otherwise I'm getting this error. Can you explain a bit more how to fix?
Thanks for tip saved me some investigation time. It's probably too late but what he means is you should open two terminals. In the first terminal run the following command to get its PID.
saved me right there! just in case: if you need to do this over ssh just open 2 connections in two terminals and run code!
Any news on this?
see comment that's what worked for me. Hence all the 's.
I would rather call his solution a hack until it really get solved ;)
Yeah, i'm still having the same problem. If there is a fix, i'd be happy to know.
This only solution saved me
You've just saved my job. I'm grateful
yep same bug. Using Ubuntu 18 LTS and pkexec 0.105
Is this related with ? I use Ubuntu 18.04 with Mate and running solves the problem, but only temporary. Furthermore, when you create another admin user and log into his account, he does not observe any errors. Perhaps there is a permanent solution for my account? (Besides adding above polkit command to startup programms.)
Saved my day
Thank you very much!
Hit me up next time you're near Seattle / Lynnwood. I owe you a beer. In my case, it was an Ubuntu 18.04 VPS, after I borked a file under /etc/sudoers.d/. (Nothing to do with NixOS.)
Life saver
Amazing, you save my life.
you save me!

It seems that this is due to the authentication agent not running. I am on Ubuntu, but maybe this will help in solving this problem: I had to install policykit-1-gnome: sudo apt install policykit-1-gnome And then run it (same terminal using &, other terminal, or adding it to autostart all worked): /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 After that pkexec worked as expected.
Yup, saved my bacon.
save my life...
also fix my problem, but on gentoo the polkit agent is and need to install
With , you should see something like You can manually execute , and find logs at (a sibling file of the script).
This seems to have an upstream ticket but no significant activity or progress seems to have been made there recently
Running ubuntu 20.04 LTS headless on rpi4 aarch64, attempting to use (using ls for testing, in use it fails authenticating python3 bin) results in, the same happens with pkttyagent open in second ssh terminal: Trying to run it manually with results in: Why is it trying to connect to a display, without ever actually being connected to one?
Life saver!
patching polkit with works
found more info in the thread of the patch that introduced this bug
I'm able to enter the password from the shell now
This issue is still saving our lives and jobs. Thanks all!
I cannot thank you enough for your comment at
my god, this saved me. Thanks a ton man I'm running this on a raspberry pi, is there a way to automate this since i need to for a service that auto spawns on boot?
Is it somehow possible to use this via instead of an overlay to avoid large amounts of rebuilds? I wasnt able to get it working with a trivial attempt
It should be possible, but let's try adding a package option to the polkit module EDIT: it works so no need to overlay or replaceRuntimeDependencies
This seems to be resolved in the current development branch of polkit though that is not contained in any release yet.
I had to hide a bunch of duplicate and off-topic comments. Please keep in mind that this is the NixOS/Nixpkgs issue tracker rather than a general Linux forum and that you can silently express your gratitude for workarounds using reactions.