summary refs log tree commit diff
path: root/nixos/modules/services/hardware/fwupd.nix
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2017-10-09 15:35:52 +0200
committerJan Tojnar <jtojnar@gmail.com>2017-11-17 18:54:45 +0100
commitc47ea8ca4ec406135b9c5279f452c6891ddc1e41 (patch)
treebb90ac2d07d131d64c612aaed79b88c6e82e0eba /nixos/modules/services/hardware/fwupd.nix
parent227a92f698174422a23636c9bffa937a287f0936 (diff)
downloadnixlib-c47ea8ca4ec406135b9c5279f452c6891ddc1e41.tar
nixlib-c47ea8ca4ec406135b9c5279f452c6891ddc1e41.tar.gz
nixlib-c47ea8ca4ec406135b9c5279f452c6891ddc1e41.tar.bz2
nixlib-c47ea8ca4ec406135b9c5279f452c6891ddc1e41.tar.lz
nixlib-c47ea8ca4ec406135b9c5279f452c6891ddc1e41.tar.xz
nixlib-c47ea8ca4ec406135b9c5279f452c6891ddc1e41.tar.zst
nixlib-c47ea8ca4ec406135b9c5279f452c6891ddc1e41.zip
nixos/services.fwupd: init
Diffstat (limited to 'nixos/modules/services/hardware/fwupd.nix')
-rw-r--r--nixos/modules/services/hardware/fwupd.nix76
1 files changed, 76 insertions, 0 deletions
diff --git a/nixos/modules/services/hardware/fwupd.nix b/nixos/modules/services/hardware/fwupd.nix
new file mode 100644
index 000000000000..672ecc934543
--- /dev/null
+++ b/nixos/modules/services/hardware/fwupd.nix
@@ -0,0 +1,76 @@
+# fwupd daemon.
+
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.fwupd;
+  originalEtc =
+    let
+      isRegular = v: v == "regular";
+      listFiles = d: builtins.attrNames (filterAttrs (const isRegular) (builtins.readDir d));
+      copiedDirs = [ "fwupd/remotes.d" "pki/fwupd" "pki/fwupd-metadata" ];
+      originalFiles = concatMap (d: map (f: "${d}/${f}") (listFiles "${pkgs.fwupd}/etc/${d}")) copiedDirs;
+      mkEtcFile = n: nameValuePair n { source = "${pkgs.fwupd}/etc/${n}"; };
+    in listToAttrs (map mkEtcFile originalFiles);
+in {
+
+  ###### interface
+  options = {
+    services.fwupd = {
+      enable = mkOption {
+        type = types.bool;
+        default = true;
+        description = ''
+          Whether to enable fwupd, a DBus service that allows
+          applications to update firmware.
+        '';
+      };
+
+      blacklistDevices = mkOption {
+        type = types.listOf types.string;
+        default = [];
+        example = [ "2082b5e0-7a64-478a-b1b2-e3404fab6dad" ];
+        description = ''
+          Allow blacklisting specific devices by their GUID
+        '';
+      };
+
+      blacklistPlugins = mkOption {
+        type = types.listOf types.string;
+        default = [];
+        example = [ "udev" ];
+        description = ''
+          Allow blacklisting specific plugins
+        '';
+      };
+    };
+  };
+
+
+  ###### implementation
+  config = mkIf cfg.enable {
+    environment.systemPackages = [ pkgs.fwupd ];
+
+    environment.etc = {
+      "fwupd/daemon.conf" = {
+        source = pkgs.writeText "daemon.conf" ''
+          [fwupd]
+          BlacklistDevices=${lib.concatStringsSep ";" cfg.blacklistDevices}
+          BlacklistPlugins=${lib.concatStringsSep ";" cfg.blacklistPlugins}
+        '';
+      };
+    } // originalEtc;
+
+    services.dbus.packages = [ pkgs.fwupd ];
+
+    services.udev.packages = [ pkgs.fwupd ];
+
+    systemd.packages = [ pkgs.fwupd ];
+
+    systemd.tmpfiles.rules = [
+      "d /var/lib/fwupd 0755 root root -"
+    ];
+  };
+}