summary refs log tree commit diff
path: root/nixos/modules/services/misc/packagekit.nix
blob: 93bd206bd983f0075582d48b77ebe7b13aba5cf1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{ config, lib, pkgs, ... }:

let
  cfg = config.services.packagekit;

  inherit (lib)
    mkEnableOption mkOption mkIf mkRemovedOptionModule types
    listToAttrs recursiveUpdate;

  iniFmt = pkgs.formats.ini { };

  confFiles = [
    (iniFmt.generate "PackageKit.conf" (recursiveUpdate
      {
        Daemon = {
          DefaultBackend = "test_nop";
          KeepCache = false;
        };
      }
      cfg.settings))

    (iniFmt.generate "Vendor.conf" (recursiveUpdate
      {
        PackagesNotFound = rec {
          DefaultUrl = "https://github.com/NixOS/nixpkgs";
          CodecUrl = DefaultUrl;
          HardwareUrl = DefaultUrl;
          FontUrl = DefaultUrl;
          MimeUrl = DefaultUrl;
        };
      }
      cfg.vendorSettings))
  ];

in
{
  imports = [
    (mkRemovedOptionModule [ "services" "packagekit" "backend" ] "The only backend that doesn't blow up is `test_nop`.")
  ];

  options.services.packagekit = {
    enable = mkEnableOption ''
      PackageKit provides a cross-platform D-Bus abstraction layer for
      installing software. Software utilizing PackageKit can install
      software regardless of the package manager.
    '';

    settings = mkOption {
      type = iniFmt.type;
      default = { };
      description = "Additional settings passed straight through to PackageKit.conf";
    };

    vendorSettings = mkOption {
      type = iniFmt.type;
      default = { };
      description = "Additional settings passed straight through to Vendor.conf";
    };
  };

  config = mkIf cfg.enable {

    services.dbus.packages = with pkgs; [ packagekit ];

    systemd.packages = with pkgs; [ packagekit ];

    environment.etc = listToAttrs (map
      (e:
        lib.nameValuePair "PackageKit/${e.name}" { source = e; })
      confFiles);
  };
}