Unverified Commit b2426bef authored by Artturi's avatar Artturi Committed by GitHub
Browse files

Merge pull request #259784 from dmytrokyrychuk/init-spice-autorandr

spice-autorandr: init at 0.0.2
parents 187c6604 d147d7fe
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4520,6 +4520,12 @@
    githubId = 1708810;
    name = "Daniel Vianna";
  };
  dmytrokyrychuk = {
    email = "dmytro@kyrych.uk";
    github = "dmytrokyrychuk";
    githubId = 699961;
    name = "Dmytro Kyrychuk";
  };
  dnr = {
    email = "dnr@dnr.im";
    github = "dnr";
+1 −0
Original line number Diff line number Diff line
@@ -737,6 +737,7 @@
  ./services/misc/soft-serve.nix
  ./services/misc/sonarr.nix
  ./services/misc/sourcehut
  ./services/misc/spice-autorandr.nix
  ./services/misc/spice-vdagentd.nix
  ./services/misc/spice-webdavd.nix
  ./services/misc/ssm-agent.nix
+26 −0
Original line number Diff line number Diff line
{ config, pkgs, lib, ... }:

let
  cfg = config.services.spice-autorandr;
in
{
  options = {
    services.spice-autorandr = {
      enable = lib.mkEnableOption (lib.mdDoc "spice-autorandr service that will automatically resize display to match SPICE client window size.");
      package = lib.mkPackageOptionMD pkgs "spice-autorandr" { };
    };
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = [ cfg.package ];

    systemd.user.services.spice-autorandr = {
      wantedBy = [ "default.target" ];
      after = [ "spice-vdagentd.service" ];
      serviceConfig = {
        ExecStart = "${cfg.package}/bin/spice-autorandr";
        Restart = "on-failure";
      };
    };
  };
}
+50 −0
Original line number Diff line number Diff line
{ lib
, stdenv
, fetchFromGitHub
, pkg-config
, autoreconfHook
, libX11
, libXrandr
}:

stdenv.mkDerivation  {
  pname = "spice-autorandr";
  version = "0.0.2";

  src = fetchFromGitHub {
    owner = "seife";
    repo = "spice-autorandr";
    rev = "0f61dc921b638761ee106b5891384c6348820b26";
    hash = "sha256-eBvzalWT3xI8+uNns0/ZyRes91ePpj0beKb8UBVqo0E=";
  };

  nativeBuildInputs = [ autoreconfHook pkg-config ];
  buildInputs = [ libX11 libXrandr ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp $pname $out/bin/

    runHook postInstall
  '';

  meta = {
    description = "Automatically adjust the client window resolution in Linux KVM guests using the SPICE driver.";
    longDescription = ''
      Some desktop environments update the display resolution automatically,
      this package is only useful when running without a DE or with a DE that
      does not update display resolution automatically.

      This package relies on `spice-vdagent` running an updating the xrandr modes. Enable
      `spice-vdagent` by adding `services.spice-autorandr.enable = true` to your `configuration.nix`.
    '';
    homepage = "https://github.com/seife/spice-autorandr";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [
      dmytrokyrychuk
    ];
    platforms = [ "x86_64-linux" ];
  };
}