about summary refs log tree commit diff
path: root/pkgs/desktops/gnome/extensions/systemd-manager/default.nix
blob: 0b8e52af802b1d95c551a6c00795a83e52b25f68 (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
{
  lib,
  stdenvNoCC,
  fetchFromGitHub,
  glib,
  # These loosen security a bit, so we don't install them by default. See also:
  # https://github.com/hardpixel/systemd-manager?tab=readme-ov-file#without-password-prompt
  allowPolkitPolicy ? "none",
  config,
  systemd ? config.systemd.package,
}:

assert lib.elem allowPolkitPolicy [
  "none"
  "pkexec"
  "systemctl"
];

stdenvNoCC.mkDerivation rec {
  pname = "gnome-shell-extension-systemd-manager";
  version = "16";

  # Upstream doesn't post new versions in extensions.gnome.org anymore, see also:
  # https://github.com/hardpixel/systemd-manager/issues/19
  src = fetchFromGitHub {
    owner = "hardpixel";
    repo = "systemd-manager";
    rev = "v${version}";
    hash = "sha256-JecSIRj582jJWdrCQYBWFRkIhosxRhD3BxSAy8/0nVw=";
  };

  nativeBuildInputs = [ glib ];

  postInstall =
    ''
      rm systemd-manager@hardpixel.eu/schemas/gschemas.compiled
      glib-compile-schemas systemd-manager@hardpixel.eu/schemas

      mkdir -p $out/share/gnome-shell/extensions
      mv systemd-manager@hardpixel.eu $out/share/gnome-shell/extensions
    ''
    + lib.optionalString (allowPolkitPolicy == "pkexec") ''
      local bn=org.freedesktop.policykit.pkexec.systemctl.policy
      mkdir -p $out/share/polkit-1/actions
      substitute systemd-policies/$bn $out/share/polkit-1/actions/$bn \
        --replace-fail /usr/bin/systemctl ${lib.getBin systemd}/bin/systemctl
    ''
    + lib.optionalString (allowPolkitPolicy == "systemctl") ''
      install -Dm0644 \
        systemd-policies/10-service_status.rules \
        $out/share/polkit-1/rules.d/10-gnome-extension-systemd-manager.rules
    '';

  passthru = {
    extensionUuid = "systemd-manager@hardpixel.eu";
    extensionPortalSlug = "systemd-manager";
  };

  meta = with lib; {
    description = "GNOME Shell extension to manage systemd services";
    homepage = "https://github.com/hardpixel/systemd-manager";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [
      linsui
      doronbehar
    ];
  };
}