From 1bc408ec3af8ae7244fccd156dc7d4bb61a3638e Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Wed, 24 Apr 2019 14:16:30 +0800 Subject: [PATCH 1/2] nixos/packagekit: make it not error out and use upstream systemd unit --- nixos/modules/services/misc/packagekit.nix | 51 ++++++++++++---------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/nixos/modules/services/misc/packagekit.nix b/nixos/modules/services/misc/packagekit.nix index bce21e8acff..325c4e84e0d 100644 --- a/nixos/modules/services/misc/packagekit.nix +++ b/nixos/modules/services/misc/packagekit.nix @@ -7,18 +7,19 @@ let cfg = config.services.packagekit; packagekitConf = '' -[Daemon] -KeepCache=false - ''; + [Daemon] + DefaultBackend=${cfg.backend} + KeepCache=false + ''; vendorConf = '' -[PackagesNotFound] -DefaultUrl=https://github.com/NixOS/nixpkgs -CodecUrl=https://github.com/NixOS/nixpkgs -HardwareUrl=https://github.com/NixOS/nixpkgs -FontUrl=https://github.com/NixOS/nixpkgs -MimeUrl=https://github.com/NixOS/nixpkgs - ''; + [PackagesNotFound] + DefaultUrl=https://github.com/NixOS/nixpkgs + CodecUrl=https://github.com/NixOS/nixpkgs + HardwareUrl=https://github.com/NixOS/nixpkgs + FontUrl=https://github.com/NixOS/nixpkgs + MimeUrl=https://github.com/NixOS/nixpkgs + ''; in @@ -33,26 +34,32 @@ in installing software. Software utilizing PackageKit can install software regardless of the package manager. ''; - }; + # TODO: integrate with PolicyKit if the nix backend matures to the point + # where it will require elevated permissions + backend = mkOption { + type = types.enum [ "test_nop" ]; + default = "test_nop"; + description = '' + PackageKit supports multiple different backends and auto which + should do the right thing. + + + On NixOS however, we do not have a backend compatible with nix 2.0 + (refer to this issue so we have to force + it to test_nop for now. + ''; + }; + }; }; config = mkIf cfg.enable { - services.dbus.packages = [ pkgs.packagekit ]; + services.dbus.packages = with pkgs; [ packagekit ]; - systemd.services.packagekit = { - description = "PackageKit Daemon"; - wantedBy = [ "multi-user.target" ]; - serviceConfig.ExecStart = "${pkgs.packagekit}/libexec/packagekitd"; - serviceConfig.User = "root"; - serviceConfig.BusName = "org.freedesktop.PackageKit"; - serviceConfig.Type = "dbus"; - }; + systemd.packages = with pkgs; [ packagekit ]; environment.etc."PackageKit/PackageKit.conf".text = packagekitConf; environment.etc."PackageKit/Vendor.conf".text = vendorConf; - }; - } From ab15949f81c80027decdb4554b1f4f8ba4fe8d03 Mon Sep 17 00:00:00 2001 From: Peter Hoeg Date: Wed, 24 Apr 2019 16:45:29 +0800 Subject: [PATCH 2/2] nixos/packagekit: add test --- nixos/tests/all-tests.nix | 1 + nixos/tests/packagekit.nix | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 nixos/tests/packagekit.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 8b27ff808e6..5efa4dc72d0 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -180,6 +180,7 @@ in osrm-backend = handleTest ./osrm-backend.nix {}; ostree = handleTest ./ostree.nix {}; overlayfs = handleTest ./overlayfs.nix {}; + packagekit = handleTest ./packagekit.nix {}; pam-oath-login = handleTest ./pam-oath-login.nix {}; pam-u2f = handleTest ./pam-u2f.nix {}; pantheon = handleTest ./pantheon.nix {}; diff --git a/nixos/tests/packagekit.nix b/nixos/tests/packagekit.nix new file mode 100644 index 00000000000..e2d68af661f --- /dev/null +++ b/nixos/tests/packagekit.nix @@ -0,0 +1,24 @@ +import ./make-test.nix ({ pkgs, ... }: { + name = "packagekit"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ peterhoeg ]; + }; + + machine = { ... }: { + environment.systemPackages = with pkgs; [ dbus ]; + services.packagekit = { + enable = true; + backend = "test_nop"; + }; + }; + + testScript = '' + startAll; + + # send a dbus message to activate the service + $machine->succeed("dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.PackageKit /org/freedesktop/PackageKit org.freedesktop.DBus.Introspectable.Introspect"); + + # so now it should be running + $machine->succeed("systemctl is-active packagekit.service"); + ''; +})