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