From b6e49129d2a3a01dd1ad436e4144bacbe89d1c30 Mon Sep 17 00:00:00 2001
From: Ethel Morgan <eth@ethulhu.co.uk>
Date: Thu, 16 Jul 2020 12:15:25 +0100
Subject: add eth.hardware.printer NixOS module

---
 nixos/modules/hardware/printer.nix | 34 ++++++++++++++++++++++++++++++++++
 nixos/modules/module-list.nix      |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 nixos/modules/hardware/printer.nix

diff --git a/nixos/modules/hardware/printer.nix b/nixos/modules/hardware/printer.nix
new file mode 100644
index 0000000..23aa554
--- /dev/null
+++ b/nixos/modules/hardware/printer.nix
@@ -0,0 +1,34 @@
+{ config, lib, pkgs, ... }:
+with lib;
+
+let 
+  cfg = config.eth.hardware.printer;
+
+in {
+
+  options.eth.hardware.printer = {
+    enable = mkEnableOption "Whether to enable Eth's home printer";
+  };
+
+  config = mkIf cfg.enable {
+    # Avahi is needed for dnssd (mDNS / Bonjour) printers.
+    services.avahi = {
+      enable = true;
+      nssmdns = true;
+    };
+
+    services.printing = {
+      enable = true;
+      drivers = with pkgs; [ brlaser ];
+    };
+
+    hardware.printers.ensurePrinters = [
+      {
+        name = "Brother_HL-1210W";
+        description = "Brother HL-1210W";
+        deviceUri = "dnssd://Brother%20HL-1210W%20series._pdl-datastream._tcp.local/?uuid=e3248000-80ce-11db-8000-d89c67c1755c";
+        model = "drv:///brlaser.drv/br1200.ppd";
+      }
+    ];
+  };
+}
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index a734519..247d9a6 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -1,6 +1,7 @@
 [
   ./hardware/keyboard.nix
   ./hardware/linode.nix
+  ./hardware/printer.nix
   ./hardware/touchpad.nix
   ./hardware/yubikey.nix
   ./location.nix
-- 
cgit v1.2.3