From 2195292bcc055bb5e08f086924911b48d7261773 Mon Sep 17 00:00:00 2001 From: Dmytro Kyrychuk Date: Sun, 8 Oct 2023 14:21:18 +0000 Subject: [PATCH 1/3] maintainers: add dmytrokyrychuk --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index a7041571a97b..24bd91c6675c 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -4483,6 +4483,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"; From 965f09efa46a37ade8b8133011f2f8727a634a63 Mon Sep 17 00:00:00 2001 From: Dmytro Kyrychuk Date: Sun, 8 Oct 2023 20:22:13 +0000 Subject: [PATCH 2/3] spice-autorandr: init at 0.0.2 --- pkgs/by-name/sp/spice-autorandr/package.nix | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pkgs/by-name/sp/spice-autorandr/package.nix diff --git a/pkgs/by-name/sp/spice-autorandr/package.nix b/pkgs/by-name/sp/spice-autorandr/package.nix new file mode 100644 index 000000000000..e79f4cb18bd9 --- /dev/null +++ b/pkgs/by-name/sp/spice-autorandr/package.nix @@ -0,0 +1,50 @@ +{ 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" ]; + }; +} From d147d7feed63ba43e80a103d278d5ad4bb12b1fd Mon Sep 17 00:00:00 2001 From: Dmytro Kyrychuk Date: Sun, 8 Oct 2023 20:22:45 +0000 Subject: [PATCH 3/3] nixos/spice-autorandr: init --- nixos/modules/module-list.nix | 1 + .../modules/services/misc/spice-autorandr.nix | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 nixos/modules/services/misc/spice-autorandr.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 811b82f28ce1..20a7d06d0f9d 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -731,6 +731,7 @@ ./services/misc/snapper.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 diff --git a/nixos/modules/services/misc/spice-autorandr.nix b/nixos/modules/services/misc/spice-autorandr.nix new file mode 100644 index 000000000000..8437441c752a --- /dev/null +++ b/nixos/modules/services/misc/spice-autorandr.nix @@ -0,0 +1,26 @@ +{ 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"; + }; + }; + }; +}