diff --git a/nixos/modules/services/monitoring/cockpit.nix b/nixos/modules/services/monitoring/cockpit.nix index 8a7192f635eb..a349e2b22611 100644 --- a/nixos/modules/services/monitoring/cockpit.nix +++ b/nixos/modules/services/monitoring/cockpit.nix @@ -15,6 +15,33 @@ let mkPackageOption ; settingsFormat = pkgs.formats.ini { }; + + pathPkgs = [ cfg.package ] ++ cfg.plugins; + + resourcesEnv = pkgs.buildEnv { + name = "cockpit-plugins"; + paths = pathPkgs; + pathsToLink = [ "/share/cockpit" ]; + }; + + depsEnv = pkgs.buildEnv { + name = "cockpit-plugins-env"; + paths = lib.concatMap (p: p.passthru.cockpitPath or [ ]) pathPkgs; + pathsToLink = [ + "/bin" + "/share" + "/lib" + ]; + }; + + share = pkgs.buildEnv { + name = "cockpit-share"; + paths = [ + resourcesEnv + depsEnv + ]; + pathsToLink = [ "/share" ]; + }; in { options = { @@ -100,22 +127,11 @@ in }; # Add plugins in discoverable folder - "cockpit/share/cockpit".source = "${ - pkgs.buildEnv { - name = "cockpit-plugins"; - paths = cfg.plugins ++ [ cfg.package ]; - pathsToLink = [ "/share/cockpit" ]; - } - }/share/cockpit"; + "cockpit/share".source = "${share}/share"; # Add plugins dependencies - "cockpit/bin".source = "${ - pkgs.buildEnv { - name = "cockpit-path"; - paths = lib.concatMap (p: p.passthru.cockpitPath or [ ]) cfg.plugins; - pathsToLink = [ "/bin" ]; - } - }/bin"; + "cockpit/bin".source = "${depsEnv}/bin"; + "cockpit/lib".source = "${depsEnv}/lib"; }; security.pam.services.cockpit = { diff --git a/pkgs/by-name/co/cockpit/package.nix b/pkgs/by-name/co/cockpit/package.nix index 05ff7c45767e..a5ce3e74a015 100644 --- a/pkgs/by-name/co/cockpit/package.nix +++ b/pkgs/by-name/co/cockpit/package.nix @@ -14,6 +14,7 @@ git, glib, glib-networking, + gobject-introspection, gnused, gnutls, hostname, @@ -160,9 +161,9 @@ stdenv.mkDerivation (finalAttrs: { --replace-warn '"/usr/share' '"/run/current-system/sw/share' \ --replace-warn '"/lib/systemd' '"/run/current-system/sw/lib/systemd' - # replace reference to system python interpreter, used for e.g. sosreport - substituteInPlace pkg/lib/python.ts \ - --replace-fail /usr/libexec/platform-python ${python3Packages.python.interpreter} + # fix polkit agent helper path + substituteInPlace src/cockpit/polkit.py \ + --replace-fail "/usr/lib/polkit-1/polkit-agent-helper-1" "/run/wrappers/bin/polkit-agent-helper-1" ''; configureFlags = [ @@ -200,10 +201,10 @@ stdenv.mkDerivation (finalAttrs: { for binary in $out/bin/cockpit-bridge $out/libexec/cockpit-askpass; do chmod +x $binary wrapProgram $binary \ + --prefix PATH : "/etc/cockpit/bin" \ --prefix PYTHONPATH : ${ lib.makeSearchPath python3Packages.python.sitePackages [ "$out" - python3Packages.pygobject3 "/etc/cockpit" ] } \ @@ -271,6 +272,12 @@ stdenv.mkDerivation (finalAttrs: { passthru = { tests = { inherit (nixosTests) cockpit; }; updateScript = nix-update-script { }; + cockpitPath = [ + glib + gobject-introspection + python3Packages.python + python3Packages.pygobject3 + ]; }; meta = {