Commit aabb4c5b authored by Alexis Hildebrandt's avatar Alexis Hildebrandt
Browse files

drawterm: Refactor to introduce withWayland option

parent 399c9e59
Loading
Loading
Loading
Loading
+51 −51
Original line number Diff line number Diff line
@@ -15,10 +15,12 @@
  libxkbcommon,
  wlr-protocols,
  pulseaudio,
  config,
  nixosTests,
  withWayland ? false,
}:

let
  withXorg = !(withWayland || stdenv.hostPlatform.isDarwin);
in
stdenv.mkDerivation {
  pname = "drawterm";
  version = "0-unstable-2025-03-18";
@@ -33,70 +35,68 @@ stdenv.mkDerivation {
  enableParallelBuilding = true;
  strictDeps = true;
  nativeBuildInputs =
    [ installShellFiles ]
    ++ {
      linux = [
    [
      installShellFiles
      makeWrapper
    ]
    ++ lib.optionals withWayland [
      pkg-config
      wayland-scanner
    ];
      unix = [ makeWrapper ];
      osx-cocoa = [ ];
    }
    ."${config}" or (throw "unsupported CONF");

  buildInputs =
    {
      linux = [
    lib.optionals withWayland [
      pipewire
      wayland
      wayland-protocols
      libxkbcommon
      wlr-protocols
      ];
      unix = [
    ]
    ++ lib.optionals withXorg [
      xorg.libX11
      xorg.libXt
      ];
      osx-cocoa = [ apple-sdk_13 ];
    }
    ."${config}" or (throw "unsupported CONF");
    ]
    ++ lib.optional stdenv.hostPlatform.isDarwin apple-sdk_13;

  makeFlags = [ "CONF=${config}" ] ++ lib.optional (config == "osx-cocoa") "CC=clang";
  makeFlags =
    lib.optional withWayland "CONF=linux"
    ++ lib.optional (!(withWayland || stdenv.hostPlatform.isDarwin)) "CONF=unix"
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      "CONF=osx-cocoa"
      "CC=clang"
    ];

  installPhase =
    {
      linux = ''
    ''
      installManPage drawterm.1
    ''
    + lib.optionalString withWayland ''
      install -Dm755 -t $out/bin/ drawterm
      '';
      unix = ''
    ''
    + lib.optionalString (!(withWayland || stdenv.hostPlatform.isDarwin)) ''
      # wrapping the oss output with pulse seems to be the easiest
      mv drawterm drawterm.bin
      install -Dm755 -t $out/bin/ drawterm.bin
      makeWrapper ${pulseaudio}/bin/padsp $out/bin/drawterm --add-flags $out/bin/drawterm.bin
      '';
      osx-cocoa = ''
    ''
    + lib.optionalString stdenv.hostPlatform.isDarwin ''
      mkdir -p $out/{Applications,bin}
      mv gui-cocoa/drawterm.app $out/Applications/
      mv drawterm $out/Applications/drawterm.app/
      ln -s $out/Applications/drawterm.app/drawterm $out/bin/
    '';
    }
    ."${config}" or (throw "unsupported CONF")
    + ''
      installManPage drawterm.1
    '';

  passthru = {
    updateScript = unstableGitUpdater { shallowClone = false; };
    tests = nixosTests.drawterm;
  };

  meta = with lib; {
  meta = {
    description = "Connect to Plan 9 CPU servers from other operating systems";
    homepage = "https://drawterm.9front.org/";
    license = licenses.mit;
    maintainers = with maintainers; [ moody ];
    platforms = platforms.linux ++ platforms.darwin;
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ moody ];
    platforms = with lib.platforms; linux ++ darwin;
    mainProgram = "drawterm";
  };
}
+1 −3
Original line number Diff line number Diff line
@@ -14129,9 +14129,7 @@ with pkgs;
    buildServerGui = false;
  };
  drawterm = callPackage ../by-name/dr/drawterm/package.nix { config = "unix"; };
  drawterm-wayland = callPackage ../by-name/dr/drawterm/package.nix { config = "linux"; };
  drawterm-cocoa = callPackage ../by-name/dr/drawterm/package.nix { config = "osx-cocoa"; };
  drawterm-wayland = callPackage ../by-name/dr/drawterm/package.nix { withWayland = true; };
  droopy = python3Packages.callPackage ../applications/networking/droopy { };