mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-06 00:51:04 +01:00
way-displays: init module (#6791)
This commit is contained in:
parent
e15c4203ea
commit
f0c69ede70
8 changed files with 195 additions and 1 deletions
|
|
@ -57,7 +57,13 @@ let
|
||||||
isNixFile = n: v: v == "regular" && lib.hasSuffix ".nix" n;
|
isNixFile = n: v: v == "regular" && lib.hasSuffix ".nix" n;
|
||||||
# builtins.attrNames return the values in alphabetical order
|
# builtins.attrNames return the values in alphabetical order
|
||||||
newsFiles = builtins.attrNames (lib.filterAttrs isNixFile (builtins.readDir ./news));
|
newsFiles = builtins.attrNames (lib.filterAttrs isNixFile (builtins.readDir ./news));
|
||||||
newsEntries = builtins.map (newsFile: import (./news + "/${newsFile}")) newsFiles;
|
newsEntries = builtins.map (
|
||||||
|
newsFile:
|
||||||
|
let
|
||||||
|
imported = import (./news + "/${newsFile}");
|
||||||
|
in
|
||||||
|
if builtins.isFunction imported then imported { inherit pkgs; } else imported
|
||||||
|
) newsFiles;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
meta.maintainers = [ lib.maintainers.rycee ];
|
meta.maintainers = [ lib.maintainers.rycee ];
|
||||||
|
|
|
||||||
12
modules/misc/news/2025-04-10_10-10-18.nix
Normal file
12
modules/misc/news/2025-04-10_10-10-18.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2025-04-10T08:10:18+00:00";
|
||||||
|
condition = pkgs.stdenv.hostPlatform.isLinux;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'services.way-displays'.
|
||||||
|
|
||||||
|
A service to automatically configure your displays on wlroots-based
|
||||||
|
wayland compositors.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -435,6 +435,7 @@ let
|
||||||
./services/unison.nix
|
./services/unison.nix
|
||||||
./services/vdirsyncer.nix
|
./services/vdirsyncer.nix
|
||||||
./services/volnoti.nix
|
./services/volnoti.nix
|
||||||
|
./services/way-displays.nix
|
||||||
./services/window-managers/awesome.nix
|
./services/window-managers/awesome.nix
|
||||||
./services/window-managers/bspwm/default.nix
|
./services/window-managers/bspwm/default.nix
|
||||||
./services/window-managers/fluxbox.nix
|
./services/window-managers/fluxbox.nix
|
||||||
|
|
|
||||||
112
modules/services/way-displays.nix
Normal file
112
modules/services/way-displays.nix
Normal file
|
|
@ -0,0 +1,112 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
attrsets
|
||||||
|
lists
|
||||||
|
literalExpression
|
||||||
|
maintainers
|
||||||
|
mkEnableOption
|
||||||
|
mkIf
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
mergeSets = sets: lists.fold attrsets.recursiveUpdate { } sets;
|
||||||
|
cfg = config.services.way-displays;
|
||||||
|
yaml = pkgs.formats.yaml { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = [ maintainers.jolars ];
|
||||||
|
|
||||||
|
options.services.way-displays = {
|
||||||
|
enable = mkEnableOption "way-displays";
|
||||||
|
|
||||||
|
package = lib.mkPackageOption pkgs "way-displays" { };
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
type = yaml.type;
|
||||||
|
default = { };
|
||||||
|
example = literalExpression ''
|
||||||
|
{
|
||||||
|
ORDER = [
|
||||||
|
"DP-2"
|
||||||
|
"Monitor Maker ABC123"
|
||||||
|
"!^my_regex_here[0-9]+"
|
||||||
|
"'!.*$'"
|
||||||
|
];
|
||||||
|
SCALING = false;
|
||||||
|
MODE = [
|
||||||
|
{
|
||||||
|
NAME_DESC = "HDMI-A-1";
|
||||||
|
WIDTH = 1920;
|
||||||
|
HEIGHT = 1080;
|
||||||
|
HZ = 60;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
TRANSFORM = [
|
||||||
|
{
|
||||||
|
NAME_DESC = "eDP-1"
|
||||||
|
TRANSFORM = "FLIPPED-90";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
The way-displays configuration written to
|
||||||
|
{file}`$XDG_CONFIG_HOME/way-displays/cfg.yml`. See
|
||||||
|
<https://github.com/alex-courtis/way-displays/wiki/Configuration> for a
|
||||||
|
description of available options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
systemdTarget = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = config.wayland.systemd.target;
|
||||||
|
defaultText = literalExpression "config.wayland.systemd.target";
|
||||||
|
description = ''
|
||||||
|
Systemd target to bind to.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
assertions = [
|
||||||
|
(lib.hm.assertions.assertPlatform "services.way-displays" pkgs lib.platforms.linux)
|
||||||
|
];
|
||||||
|
|
||||||
|
xdg.configFile."way-displays/cfg.yaml".source =
|
||||||
|
yaml.generate "way-displays-config.yaml"
|
||||||
|
(mergeSets [
|
||||||
|
{
|
||||||
|
CALLBACK_CMD = lib.mkDefault "${pkgs.libnotify}/bin/notify-send \"way-displays \${CALLBACK_LEVEL}\" \"\${CALLBACK_MSG}\"";
|
||||||
|
}
|
||||||
|
cfg.settings
|
||||||
|
]);
|
||||||
|
|
||||||
|
systemd.user.services.way-displays = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Display configuration service";
|
||||||
|
Documentation = "man:way-displays(1)";
|
||||||
|
ConditionEnvironment = "WAYLAND_DISPLAY";
|
||||||
|
PartOf = cfg.systemdTarget;
|
||||||
|
Requires = cfg.systemdTarget;
|
||||||
|
After = cfg.systemdTarget;
|
||||||
|
};
|
||||||
|
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ cfg.systemdTarget ];
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart = "${lib.getExe cfg.package}";
|
||||||
|
Restart = "always";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -621,6 +621,7 @@ import nmtSrc {
|
||||||
./modules/services/twmn
|
./modules/services/twmn
|
||||||
./modules/services/udiskie
|
./modules/services/udiskie
|
||||||
./modules/services/volnoti
|
./modules/services/volnoti
|
||||||
|
./modules/services/way-displays
|
||||||
./modules/services/window-managers/bspwm
|
./modules/services/window-managers/bspwm
|
||||||
./modules/services/window-managers/herbstluftwm
|
./modules/services/window-managers/herbstluftwm
|
||||||
./modules/services/window-managers/hyprland
|
./modules/services/window-managers/hyprland
|
||||||
|
|
|
||||||
43
tests/modules/services/way-displays/configuration.nix
Normal file
43
tests/modules/services/way-displays/configuration.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
services.way-displays = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage { };
|
||||||
|
settings = {
|
||||||
|
CALLBACK_CMD = "notify-send \"way-displays \${CALLBACK_LEVEL}\" \"\${CALLBACK_MSG}\"";
|
||||||
|
ORDER = [
|
||||||
|
"eDP-1"
|
||||||
|
"DELL U2419HC"
|
||||||
|
"DELL U2415"
|
||||||
|
"HP E24 G5"
|
||||||
|
"HP E24 G5"
|
||||||
|
];
|
||||||
|
ALIGN = "MIDDLE";
|
||||||
|
VRR_OFF = [
|
||||||
|
"DELL U2419HC"
|
||||||
|
"DELL U2415"
|
||||||
|
];
|
||||||
|
TRANSFORM = [
|
||||||
|
{
|
||||||
|
NAME_DESC = "DELL U2419HC";
|
||||||
|
TRANSFORM = "90";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
NAME_DESC = "HP E24 G5";
|
||||||
|
TRANSFORM = "90";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
serviceFile=home-files/.config/systemd/user/way-displays.service
|
||||||
|
assertFileExists $serviceFile
|
||||||
|
|
||||||
|
assertFileExists home-files/.config/way-displays/cfg.yaml
|
||||||
|
assertFileContent home-files/.config/way-displays/cfg.yaml \
|
||||||
|
${./configuration.yaml}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
16
tests/modules/services/way-displays/configuration.yaml
Normal file
16
tests/modules/services/way-displays/configuration.yaml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
ALIGN: MIDDLE
|
||||||
|
CALLBACK_CMD: notify-send "way-displays ${CALLBACK_LEVEL}" "${CALLBACK_MSG}"
|
||||||
|
ORDER:
|
||||||
|
- eDP-1
|
||||||
|
- DELL U2419HC
|
||||||
|
- DELL U2415
|
||||||
|
- HP E24 G5
|
||||||
|
- HP E24 G5
|
||||||
|
TRANSFORM:
|
||||||
|
- NAME_DESC: DELL U2419HC
|
||||||
|
TRANSFORM: '90'
|
||||||
|
- NAME_DESC: HP E24 G5
|
||||||
|
TRANSFORM: '90'
|
||||||
|
VRR_OFF:
|
||||||
|
- DELL U2419HC
|
||||||
|
- DELL U2415
|
||||||
3
tests/modules/services/way-displays/default.nix
Normal file
3
tests/modules/services/way-displays/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
way-displays-configuration = ./configuration.nix;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue