Unable to set up HP Deskjet scanner after reading Wiki

I have an HP DeskJet 1510 printer/scanner.

I followed the wiki on Printing and Scanners but no luck after adding pkgs.hplipWithPlugin,

  services.printing.enable = true;
  services.printing.drivers = [ pkgs.hplipWithPlugin ];
  hardware.sane.extraBackends = [ pkgs.hplipWithPlugin ];

After a reboot, the Simple Scan app in Gnome does not show the scanner for use.

I tried running the following but get an error:

$ sudo -i
# nix run nixpkgs.hplipWithPlugin -c hp-setup
error: Package ‘hplip-3.19.6’ in /nix/store/8v0n7zn9hpmqays85zwibyfivr4ddyy4-nixos-19.09.1778.db3e8325a9b/nixos/pkgs/misc/drivers/hplip/default.nix:222 has an unfree license (‘unfree’), refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnfree = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnfree = true; }
to ~/.config/nixpkgs/config.nix.

(use '--show-trace' to show detailed location information)

However, I do have allowUnfree = true in my configuration.nix.

Then I tried opening up localhost:631 in my browser, and I was able to add the printer there. I can also see the printer in Settings > Devices > Printers.

However, I still can not scan with the Simple Scan app.

When I try

$ nix-shell -p sane-backends
$ scanimage -L 
device `v4l:/dev/video0' is a Noname Integrated_Webcam_HD: Integrate virtual device

it is looking for my webcam. When I tried it as root, there was more output:

# scanimage -L
Created directory: /var/lib/net-snmp
Created directory: /var/lib/net-snmp/mib_indexes
device `v4l:/dev/video0' is a Noname Integrated_Webcam_HD: Integrate virtual device

Looks like it ends the same. Side question, is it okay for it to create those directories that aren’t managed by Nix? Should I delete them?

Any ideas?

Why can’t it be as simple as “Printers & Scanners” in macOS? In macOS, I see HP Deskjet 1510 there, double click on it, click “Scanner”, hit the “Scan” button, and it just works. :slight_smile:

Have you also enabled it in your user level configuration?


I don’t have a user-level configuration. I only have /etc/configuration.nix and am installing everything by editing that.

As the message suggests, that only applies for the pkgs passed to NixOS modules. nixpkgs prefix passed to nix run refers to a channel, whose config needs to be set by the second method.

Alright, I think I get it, I need to set allowUnfree specifically for that nix run command. It is getting quite complicated:

[nix-shell:~]# nix-shell -p python37Packages.dbus-python

[nix-shell:~]# NIXPKGS_ALLOW_UNFREE=1 nix run nixpkgs.hplipWithPlugin -c hp-setup
Traceback (most recent call last):
  File "/nix/store/l3axd802gmbw95r0n6kxdil6y4fx0vzz-hplip-3.19.6/share/hplip/setup.py", line 49, in <module>
    from base import device, utils, tui, models, module, services, os_utils
  File "/nix/store/l3axd802gmbw95r0n6kxdil6y4fx0vzz-hplip-3.19.6/share/hplip/base/device.py", line 71, in <module>
    import dbus
  File "/nix/store/c839wy3863zl1ln6ccsx91838nk9vsbr-python3.7-dbus-python-1.2.4/lib/python3.7/site-packages/dbus/__init__.py", line 76, in <module>
    import dbus.exceptions as exceptions
AttributeError: 'module' object has no attribute 'exceptions'