From NixOS Wiki
Proposed replacement for hp-setup example commandOn NixOS 22.05 I can't use
$ nix run nixpkgs.hplipWithPlugin -c sudo hp-setupbecause the nix run command has a different syntax that doesn't recognize the -c flag. What ended up working for me (on XFCE but not on Sway, but that's another matter) is:
$ NIXPKGS_ALLOW_UNFREE=1 nix --extra-experimental-features nix-command --extra-experimental-features --flakes shell --impure nixpkgs#hplipWithPlugin --command sudo hp-setupI arrived at this through experimentation and I don't know if it fully fits best practices, so I'm proposing it on the Talk page instead of just adding it to the article.