diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 9fa277b0..b38049ed 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -176,6 +176,9 @@ Makefile @thiagokokada /modules/programs/lieer.nix @tadfisher +/modules/programs/looking-glass-client.nix @j-brn +/tests/modules/programs/looking-glass-client @j-brn + /modules/programs/lsd.nix @marsam /modules/programs/matplotlib.nix @rprospero diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0cc0fe54..b88ba7e4 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -762,6 +762,14 @@ in want to automatically run scheduled backups. ''; } + + { + time = "2022-10-18T08:07:43+00:00"; + condition = hostPlatform.isLinux; + message = '' + A new module is available: 'programs.looking-glass-client'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 1bb875a4..f2c6b1e9 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -110,6 +110,7 @@ let ./programs/lf.nix ./programs/librewolf.nix ./programs/lieer.nix + ./programs/looking-glass-client.nix ./programs/lsd.nix ./programs/man.nix ./programs/mangohud.nix diff --git a/modules/programs/looking-glass-client.nix b/modules/programs/looking-glass-client.nix new file mode 100644 index 00000000..1c14282b --- /dev/null +++ b/modules/programs/looking-glass-client.nix @@ -0,0 +1,60 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.looking-glass-client; + settingsFormat = pkgs.formats.ini { }; +in { + meta.maintainers = with maintainers; [ j-brn ]; + + options.programs.looking-glass-client = { + enable = mkEnableOption "looking-glass-client"; + + package = mkPackageOption pkgs "looking-glass-client" { }; + + settings = mkOption { + type = settingsFormat.type; + default = { }; + description = "looking-glass-client settings."; + example = literalExpression '' + { + app = { + allowDMA = true; + shmFile = "/dev/kvmfr0"; + }; + + win = { + fullScreen = true; + showFPS = false; + jitRender = true; + }; + + spice = { + enable = true; + audio = true; + }; + + input = { + rawMouse = true; + escapeKey = 62; + }; + } + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "programs.looking-glass-client" pkgs + platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + xdg.configFile."looking-glass/client.ini" = mkIf (cfg.settings != { }) { + source = + settingsFormat.generate ("looking-glass-client.ini") cfg.settings; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 5621adb0..efe2356f 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -149,6 +149,7 @@ import nmt { ./modules/programs/hexchat ./modules/programs/i3status-rust ./modules/programs/kodi + ./modules/programs/looking-glass-client ./modules/programs/mangohud ./modules/programs/ncmpcpp-linux ./modules/programs/neovim # Broken package dependency on Darwin. diff --git a/tests/modules/programs/looking-glass-client/default.nix b/tests/modules/programs/looking-glass-client/default.nix new file mode 100644 index 00000000..fdbbb25a --- /dev/null +++ b/tests/modules/programs/looking-glass-client/default.nix @@ -0,0 +1,4 @@ +{ + looking-glass-client-example-settings = ./example-settings.nix; + looking-glass-client-empty-settings = ./empty-settings.nix; +} diff --git a/tests/modules/programs/looking-glass-client/empty-settings.nix b/tests/modules/programs/looking-glass-client/empty-settings.nix new file mode 100644 index 00000000..10c177a9 --- /dev/null +++ b/tests/modules/programs/looking-glass-client/empty-settings.nix @@ -0,0 +1,16 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.looking-glass-client = { + enable = true; + package = config.lib.test.mkStubPackage { }; + }; + + nmt.script = '' + assertPathNotExists home-files/.config/looking-glass/client.ini + ''; + }; +} diff --git a/tests/modules/programs/looking-glass-client/example-config.ini b/tests/modules/programs/looking-glass-client/example-config.ini new file mode 100644 index 00000000..db006d3f --- /dev/null +++ b/tests/modules/programs/looking-glass-client/example-config.ini @@ -0,0 +1,16 @@ +[app] +allowDMA=true +shmFile=/dev/kvmfr0 + +[input] +escapeKey=62 +rawMouse=true + +[spice] +audio=true +enable=true + +[win] +fullScreen=true +jitRender=true +showFPS=false diff --git a/tests/modules/programs/looking-glass-client/example-settings.nix b/tests/modules/programs/looking-glass-client/example-settings.nix new file mode 100644 index 00000000..6ac8f018 --- /dev/null +++ b/tests/modules/programs/looking-glass-client/example-settings.nix @@ -0,0 +1,41 @@ +{ config, lib, ... }: + +with lib; + +{ + config = { + programs.looking-glass-client = { + enable = true; + package = config.lib.test.mkStubPackage { }; + + settings = { + app = { + allowDMA = true; + shmFile = "/dev/kvmfr0"; + }; + + win = { + fullScreen = true; + showFPS = false; + jitRender = true; + }; + + spice = { + enable = true; + audio = true; + }; + + input = { + rawMouse = true; + escapeKey = 62; + }; + }; + }; + + nmt.script = '' + assertFileContent \ + home-files/.config/looking-glass/client.ini \ + ${./example-config.ini} + ''; + }; +}