Unverified Commit 549f5e6d authored by andre4ik3's avatar andre4ik3
Browse files

nixos/cockpit: place more dependencies into /etc/cockpit

parent f166cb37
Loading
Loading
Loading
Loading
+30 −14
Original line number Diff line number Diff line
@@ -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 = {
+11 −4
Original line number Diff line number Diff line
@@ -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 = {