Skip to content

Commit

Permalink
looking-glass-client: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
j-brn authored and rycee committed Oct 18, 2022
1 parent e901c8d commit 42f81ac
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
60 changes: 60 additions & 0 deletions modules/programs/looking-glass-client.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
}
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions tests/modules/programs/looking-glass-client/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
looking-glass-client-example-settings = ./example-settings.nix;
looking-glass-client-empty-settings = ./empty-settings.nix;
}
16 changes: 16 additions & 0 deletions tests/modules/programs/looking-glass-client/empty-settings.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
}
16 changes: 16 additions & 0 deletions tests/modules/programs/looking-glass-client/example-config.ini
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions tests/modules/programs/looking-glass-client/example-settings.nix
Original file line number Diff line number Diff line change
@@ -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}
'';
};
}

0 comments on commit 42f81ac

Please sign in to comment.