1{ config, lib, pkgs, ... }:
2
3let
4 cfg = config.services.packagekit;
5
6 inherit (lib)
7 mkEnableOption mkOption mkIf mkRemovedOptionModule types
8 listToAttrs recursiveUpdate;
9
10 iniFmt = pkgs.formats.ini { };
11
12 confFiles = [
13 (iniFmt.generate "PackageKit.conf" (recursiveUpdate
14 {
15 Daemon = {
16 DefaultBackend = "nix";
17 KeepCache = false;
18 };
19 }
20 cfg.settings))
21
22 (iniFmt.generate "Vendor.conf" (recursiveUpdate
23 {
24 PackagesNotFound = rec {
25 DefaultUrl = "https://github.com/NixOS/nixpkgs";
26 CodecUrl = DefaultUrl;
27 HardwareUrl = DefaultUrl;
28 FontUrl = DefaultUrl;
29 MimeUrl = DefaultUrl;
30 };
31 }
32 cfg.vendorSettings))
33 ];
34
35in
36{
37 imports = [
38 (mkRemovedOptionModule [ "services" "packagekit" "backend" ] "Always set to Nix.")
39 ];
40
41 options.services.packagekit = {
42 enable = mkEnableOption (lib.mdDoc ''
43 PackageKit provides a cross-platform D-Bus abstraction layer for
44 installing software. Software utilizing PackageKit can install
45 software regardless of the package manager.
46 '');
47
48 settings = mkOption {
49 type = iniFmt.type;
50 default = { };
51 description = lib.mdDoc "Additional settings passed straight through to PackageKit.conf";
52 };
53
54 vendorSettings = mkOption {
55 type = iniFmt.type;
56 default = { };
57 description = lib.mdDoc "Additional settings passed straight through to Vendor.conf";
58 };
59 };
60
61 config = mkIf cfg.enable {
62
63 services.dbus.packages = with pkgs; [ packagekit ];
64
65 environment.systemPackages = with pkgs; [ packagekit ];
66
67 systemd.packages = with pkgs; [ packagekit ];
68
69 environment.etc = listToAttrs (map
70 (e:
71 lib.nameValuePair "PackageKit/${e.name}" { source = e; })
72 confFiles);
73 };
74}