Unverified Commit 1caba3e5 authored by andre4ik3's avatar andre4ik3
Browse files

cockpit: add branding, fix app visibility conditions, add andre4ik3 as maintainer

parent fbc97dcd
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
#badge {
    inline-size: 225px;
    block-size: 80px;
    background-image: url("logo.png");
    background-size: contain;
    background-repeat: no-repeat;
}

#brand::before {
    content: "${PRETTY_NAME}";
}
+32 −2
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
  systemd,
  udev,
  xmlto,
  # Enables lightweight NixOS branding, replacing the default Cockpit icons
  withBranding ? true,
  nixos-icons,
}:

stdenv.mkDerivation (finalAttrs: {
@@ -148,6 +151,17 @@ stdenv.mkDerivation (finalAttrs: {

    # hardcode libexecdir, I am assuming that cockpit only use it to find it's binaries
    printf 'def get_libexecdir() -> str:\n\treturn "%s"' "$out/libexec" >> src/cockpit/packages.py

    # patch paths used as visibility conditions in apps
    substituteInPlace pkg/*/manifest.json \
      --replace-warn '"/usr/bin' '"/run/current-system/sw/bin' \
      --replace-warn '"/usr/sbin' '"/run/current-system/sw/bin' \
      --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}
  '';

  configureFlags = [
@@ -200,6 +214,19 @@ stdenv.mkDerivation (finalAttrs: {
    substituteInPlace $out/lib/systemd/*/* \
      --replace-warn /bin /run/current-system/sw/bin

    ${lib.optionalString withBranding ''
      mkdir -p "$out/share/cockpit/branding/nixos"
      pushd "$out/share/cockpit/branding/nixos"

      icons="${nixos-icons}/share/icons/hicolor"
      ln -s "$icons/16x16/apps/nix-snowflake.png" favicon.ico
      ln -s "$icons/256x256/apps/nix-snowflake.png" logo.png
      ln -s "$icons/256x256/apps/nix-snowflake.png" apple-touch-icon.png
      cp "${./branding.css}" branding.css

      popd
    ''}

    runHook postFixup
  '';

@@ -235,6 +262,9 @@ stdenv.mkDerivation (finalAttrs: {
    homepage = "https://cockpit-project.org/";
    changelog = "https://cockpit-project.org/blog/cockpit-${finalAttrs.version}.html";
    license = lib.licenses.lgpl21;
    maintainers = [ lib.maintainers.lucasew ];
    maintainers = with lib.maintainers; [
      lucasew
      andre4ik3
    ];
  };
})