mirror of
https://github.com/nix-community/home-manager
synced 2024-12-18 07:49:48 +01:00
hyprlock: add module
This commit is contained in:
parent
4855bfb6ce
commit
c6ddd80fb1
9 changed files with 566 additions and 0 deletions
|
@ -1618,6 +1618,17 @@ in {
|
|||
https://github.com/fastfetch-cli/fastfetch for more.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2024-05-10T11:48:34+00:00";
|
||||
condition = hostPlatform.isLinux;
|
||||
message = ''
|
||||
A new module is available: 'programs.hyprlock'.
|
||||
|
||||
Hyprland's simple, yet multi-threaded and GPU-accelerated screen
|
||||
locking utility. See https://github.com/hyprwm/hyprlock for more.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ let
|
|||
./programs/hstr.nix
|
||||
./programs/htop.nix
|
||||
./programs/hyfetch.nix
|
||||
./programs/hyprlock.nix
|
||||
./programs/i3blocks.nix
|
||||
./programs/i3status-rust.nix
|
||||
./programs/i3status.nix
|
||||
|
|
127
modules/programs/hyprlock.nix
Normal file
127
modules/programs/hyprlock.nix
Normal file
|
@ -0,0 +1,127 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.hyprlock;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ maintainers.khaneliman maintainers.fufexan ];
|
||||
|
||||
options.programs.hyprlock = {
|
||||
enable = mkEnableOption "" // {
|
||||
description = ''
|
||||
Whether to enable Hyprlock, Hyprland's GPU-accelerated lock screen
|
||||
utility.
|
||||
|
||||
Note that PAM must be configured to enable hyprlock to perform
|
||||
authentication. The package installed through home-manager will *not* be
|
||||
able to unlock the session without this configuration.
|
||||
|
||||
On NixOS, it can be enabled using:
|
||||
|
||||
```nix
|
||||
security.pam.services.hyprlock = {};
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkPackageOption pkgs "hyprlock" { };
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = with lib.types;
|
||||
let
|
||||
valueType = nullOr (oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
path
|
||||
(attrsOf valueType)
|
||||
(listOf valueType)
|
||||
]) // {
|
||||
description = "Hyprlock configuration value";
|
||||
};
|
||||
in valueType;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
general = {
|
||||
disable_loading_bar = true;
|
||||
grace = 300;
|
||||
hide_cursor = true;
|
||||
no_fade_in = false;
|
||||
};
|
||||
|
||||
background = [
|
||||
{
|
||||
path = "screenshot";
|
||||
blur_passes = 3;
|
||||
blur_size = 8;
|
||||
}
|
||||
];
|
||||
|
||||
input-field = [
|
||||
{
|
||||
size = "200, 50";
|
||||
position = "0, -80";
|
||||
monitor = "";
|
||||
dots_center = true;
|
||||
fade_on_empty = false;
|
||||
font_color = "rgb(202, 211, 245)";
|
||||
inner_color = "rgb(91, 96, 120)";
|
||||
outer_color = "rgb(24, 25, 38)";
|
||||
outline_thickness = 5;
|
||||
placeholder_text = '\'<span foreground="##cad3f5">Password...</span>'\';
|
||||
shadow_passes = 2;
|
||||
}
|
||||
];
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Hyprlock configuration written in Nix. Entries with the same key should
|
||||
be written as lists. Variables' and colors' names should be quoted. See
|
||||
<https://wiki.hyprland.org/Hypr-Ecosystem/hyprlock/> for more examples.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Extra configuration lines to add to `~/.config/hypr/hyprlock.conf`.
|
||||
'';
|
||||
};
|
||||
|
||||
sourceFirst = lib.mkEnableOption ''
|
||||
putting source entries at the top of the configuration
|
||||
'' // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
importantPrefixes = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = [ "$" "monitor" "size" ]
|
||||
++ lib.optionals cfg.sourceFirst [ "source" ];
|
||||
example = [ "$" "monitor" "size" ];
|
||||
description = ''
|
||||
List of prefix of attributes to source at the top of the config.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile."hypr/hyprlock.conf" =
|
||||
let shouldGenerate = cfg.extraConfig != "" || cfg.settings != { };
|
||||
in mkIf shouldGenerate {
|
||||
text = lib.optionalString (cfg.settings != { })
|
||||
(lib.hm.generators.toHyprconf {
|
||||
attrs = cfg.settings;
|
||||
inherit (cfg) importantPrefixes;
|
||||
}) + lib.optionalString (cfg.extraConfig != null) cfg.extraConfig;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -197,6 +197,7 @@ in import nmtSrc {
|
|||
./modules/programs/gnome-shell
|
||||
./modules/programs/gnome-terminal
|
||||
./modules/programs/hexchat
|
||||
./modules/programs/hyprlock
|
||||
./modules/programs/i3blocks
|
||||
./modules/programs/i3status-rust
|
||||
./modules/programs/imv
|
||||
|
|
27
tests/modules/programs/hyprlock/basic-configuration.conf
Normal file
27
tests/modules/programs/hyprlock/basic-configuration.conf
Normal file
|
@ -0,0 +1,27 @@
|
|||
background {
|
||||
monitor=
|
||||
blur_passes=3
|
||||
blur_size=8
|
||||
path=screenshot
|
||||
}
|
||||
|
||||
general {
|
||||
disable_loading_bar=true
|
||||
grace=300
|
||||
hide_cursor=true
|
||||
no_fade_in=false
|
||||
}
|
||||
|
||||
input-field {
|
||||
monitor=
|
||||
size=200, 50
|
||||
dots_center=true
|
||||
fade_on_empty=false
|
||||
font_color=rgb(202, 211, 245)
|
||||
inner_color=rgb(91, 96, 120)
|
||||
outer_color=rgb(24, 25, 38)
|
||||
outline_thickness=5
|
||||
placeholder_text=<span foreground="##cad3f5">Password...</span>
|
||||
position=0, -80
|
||||
shadow_passes=2
|
||||
}
|
45
tests/modules/programs/hyprlock/basic-configuration.nix
Normal file
45
tests/modules/programs/hyprlock/basic-configuration.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.hyprlock = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
general = {
|
||||
disable_loading_bar = true;
|
||||
grace = 300;
|
||||
hide_cursor = true;
|
||||
no_fade_in = false;
|
||||
};
|
||||
|
||||
background = [{
|
||||
monitor = "";
|
||||
path = "screenshot";
|
||||
blur_passes = 3;
|
||||
blur_size = 8;
|
||||
}];
|
||||
|
||||
input-field = [{
|
||||
size = "200, 50";
|
||||
position = "0, -80";
|
||||
monitor = "";
|
||||
dots_center = true;
|
||||
fade_on_empty = false;
|
||||
font_color = "rgb(202, 211, 245)";
|
||||
inner_color = "rgb(91, 96, 120)";
|
||||
outer_color = "rgb(24, 25, 38)";
|
||||
outline_thickness = 5;
|
||||
placeholder_text = ''<span foreground="##cad3f5">Password...</span>'';
|
||||
shadow_passes = 2;
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.hyprlock = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/hypr/hyprlock.conf \
|
||||
${./basic-configuration.conf}
|
||||
'';
|
||||
}
|
167
tests/modules/programs/hyprlock/complex-configuration.conf
Normal file
167
tests/modules/programs/hyprlock/complex-configuration.conf
Normal file
|
@ -0,0 +1,167 @@
|
|||
background {
|
||||
monitor=
|
||||
blur_passes=3
|
||||
blur_size=8
|
||||
brightness=0.817200
|
||||
color=rgba(25, 20, 20, 1.0)
|
||||
contrast=0.891700
|
||||
noise=0.011700
|
||||
path=screenshot
|
||||
vibrancy=0.168600
|
||||
vibrancy_darkness=0.050000
|
||||
}
|
||||
|
||||
general {
|
||||
disable_loading_bar=true
|
||||
grace=300
|
||||
hide_cursor=true
|
||||
ignore_empty_input=false
|
||||
no_fade_in=false
|
||||
no_fade_out=false
|
||||
}
|
||||
|
||||
image {
|
||||
monitor=
|
||||
size=120
|
||||
border_color=rgb(202, 211, 245)
|
||||
border_size=5
|
||||
halign=center
|
||||
path=/home/$USER/.face
|
||||
position=0, 45
|
||||
reload_cmd=
|
||||
reload_time=-1
|
||||
rotate=0.000000
|
||||
rounding=-1
|
||||
shadow_passes=1
|
||||
valign=center
|
||||
}
|
||||
|
||||
input-field {
|
||||
monitor=
|
||||
size=200, 50
|
||||
bothlock_color=-1
|
||||
capslock_color=-1
|
||||
check_color=rgb(204, 136, 34)
|
||||
dots_center=true
|
||||
dots_rounding=-1
|
||||
dots_size=0.330000
|
||||
dots_spacing=0.150000
|
||||
fade_on_empty=false
|
||||
fade_timeout=2000
|
||||
fail_color=rgb(204, 34, 34)
|
||||
fail_text=<i>$FAIL</i>
|
||||
fail_transition=300
|
||||
font_color=rgb(202, 211, 245)
|
||||
halign=center
|
||||
hide_input=false
|
||||
inner_color=rgb(91, 96, 120)
|
||||
invert_numlock=false
|
||||
numlock_color=-1
|
||||
outer_color=rgb(24, 25, 38)
|
||||
outline_thickness=5
|
||||
placeholder_text=<span foreground="##cad3f5">Password...</span>
|
||||
position=0, -80
|
||||
rounding=-1
|
||||
shadow_boost=1.200000
|
||||
shadow_color=rgba(0, 0, 0, 1.0)
|
||||
shadow_passes=2
|
||||
shadow_size=3
|
||||
swap_font_color=false
|
||||
valign=center
|
||||
}
|
||||
|
||||
label {
|
||||
monitor=
|
||||
color=rgb(202, 211, 245)
|
||||
font_family=MonaspiceNe Nerd Font
|
||||
font_size=100
|
||||
halign=center
|
||||
position=0, 330
|
||||
rotate=0.000000
|
||||
shadow_boost=1.200000
|
||||
shadow_color=rgba(0, 0, 0, 1.0)
|
||||
shadow_passes=2
|
||||
shadow_size=3
|
||||
text=<span font_weight="ultrabold">$TIME</span>
|
||||
valign=center
|
||||
}
|
||||
|
||||
label {
|
||||
monitor=
|
||||
color=rgb(202, 211, 245)
|
||||
font_family=MonaspiceNe Nerd Font
|
||||
font_size=25
|
||||
halign=left
|
||||
position=10, 0
|
||||
rotate=0.000000
|
||||
shadow_boost=1.200000
|
||||
shadow_color=rgba(0, 0, 0, 1.0)
|
||||
shadow_passes=1
|
||||
shadow_size=3
|
||||
text=<span font_weight="bold"> $USER</span>
|
||||
valign=top
|
||||
}
|
||||
|
||||
label {
|
||||
monitor=
|
||||
color=rgb(202, 211, 245)
|
||||
font_family=MonaspiceNe Nerd Font
|
||||
font_size=50
|
||||
halign=center
|
||||
position=15, -350
|
||||
rotate=0.000000
|
||||
shadow_boost=1.200000
|
||||
shadow_color=rgba(0, 0, 0, 1.0)
|
||||
shadow_passes=1
|
||||
shadow_size=3
|
||||
text=<span font_weight="ultrabold"> </span>
|
||||
valign=center
|
||||
}
|
||||
|
||||
label {
|
||||
monitor=
|
||||
color=rgb(202, 211, 245)
|
||||
font_family=MonaspiceNe Nerd Font
|
||||
font_size=25
|
||||
halign=center
|
||||
position=0, -430
|
||||
rotate=0.000000
|
||||
shadow_boost=1.200000
|
||||
shadow_color=rgba(0, 0, 0, 1.0)
|
||||
shadow_passes=1
|
||||
shadow_size=3
|
||||
text=<span font_weight="bold">Locked</span>
|
||||
valign=center
|
||||
}
|
||||
|
||||
label {
|
||||
monitor=
|
||||
color=rgb(202, 211, 245)
|
||||
font_family=MonaspiceNe Nerd Font
|
||||
font_size=30
|
||||
halign=center
|
||||
position=0, 210
|
||||
rotate=0.000000
|
||||
shadow_boost=1.200000
|
||||
shadow_color=rgba(0, 0, 0, 1.0)
|
||||
shadow_passes=1
|
||||
shadow_size=3
|
||||
text=cmd[update:120000] echo "<span font_weight='bold'>$(date +'%a %d %B')</span>"
|
||||
valign=center
|
||||
}
|
||||
|
||||
label {
|
||||
monitor=
|
||||
color=rgb(202, 211, 245)
|
||||
font_family=MonaspiceNe Nerd Font
|
||||
font_size=25
|
||||
halign=right
|
||||
position=5, 8
|
||||
rotate=0.000000
|
||||
shadow_boost=1.200000
|
||||
shadow_color=rgba(0, 0, 0, 1.0)
|
||||
shadow_passes=1
|
||||
shadow_size=3
|
||||
text=<span font_weight="ultrabold"> </span>
|
||||
valign=bottom
|
||||
}
|
183
tests/modules/programs/hyprlock/complex-configuration.nix
Normal file
183
tests/modules/programs/hyprlock/complex-configuration.nix
Normal file
|
@ -0,0 +1,183 @@
|
|||
{ ... }:
|
||||
|
||||
{
|
||||
programs.hyprlock = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
general = {
|
||||
disable_loading_bar = true;
|
||||
hide_cursor = true;
|
||||
ignore_empty_input = false;
|
||||
grace = 300;
|
||||
no_fade_in = false;
|
||||
no_fade_out = false;
|
||||
};
|
||||
|
||||
background = [{
|
||||
monitor = "";
|
||||
brightness = "0.817200";
|
||||
color = "rgba(25, 20, 20, 1.0)";
|
||||
path = "screenshot";
|
||||
blur_passes = 3;
|
||||
blur_size = 8;
|
||||
contrast = "0.891700";
|
||||
noise = "0.011700";
|
||||
vibrancy = "0.168600";
|
||||
vibrancy_darkness = "0.050000";
|
||||
}];
|
||||
|
||||
input-field = [{
|
||||
monitor = "";
|
||||
size = "200, 50";
|
||||
position = "0, -80";
|
||||
outline_thickness = 5;
|
||||
dots_center = true;
|
||||
outer_color = "rgb(24, 25, 38)";
|
||||
inner_color = "rgb(91, 96, 120)";
|
||||
font_color = "rgb(202, 211, 245)";
|
||||
fade_on_empty = false;
|
||||
placeholder_text = ''<span foreground="##cad3f5">Password...</span>'';
|
||||
shadow_passes = 2;
|
||||
bothlock_color = -1;
|
||||
capslock_color = "-1";
|
||||
check_color = "rgb(204, 136, 34)";
|
||||
dots_rounding = "-1";
|
||||
dots_size = "0.330000";
|
||||
dots_spacing = "0.150000";
|
||||
fade_timeout = "2000";
|
||||
fail_color = "rgb(204, 34, 34)";
|
||||
fail_text = "<i>$FAIL</i>";
|
||||
fail_transition = 300;
|
||||
halign = "center";
|
||||
hide_input = false;
|
||||
invert_numlock = false;
|
||||
numlock_color = -1;
|
||||
rounding = -1;
|
||||
shadow_boost = "1.200000";
|
||||
shadow_color = "rgba(0, 0, 0, 1.0)";
|
||||
shadow_size = 3;
|
||||
swap_font_color = false;
|
||||
valign = "center";
|
||||
}];
|
||||
|
||||
image = [{
|
||||
monitor = "";
|
||||
size = 120;
|
||||
position = "0, 45";
|
||||
path = "/home/$USER/.face";
|
||||
border_color = "rgb(202, 211, 245)";
|
||||
border_size = 5;
|
||||
halign = "center";
|
||||
valign = "center";
|
||||
shadow_passes = 1;
|
||||
reload_cmd = "";
|
||||
reload_time = -1;
|
||||
rotate = "0.000000";
|
||||
rounding = "-1";
|
||||
}];
|
||||
|
||||
label = [
|
||||
{
|
||||
monitor = "";
|
||||
text = ''<span font_weight="ultrabold">$TIME</span>'';
|
||||
color = "rgb(202, 211, 245)";
|
||||
font_size = 100;
|
||||
font_family = "MonaspiceNe Nerd Font";
|
||||
valign = "center";
|
||||
halign = "center";
|
||||
position = "0, 330";
|
||||
shadow_passes = 2;
|
||||
rotate = "0.000000";
|
||||
shadow_boost = "1.200000";
|
||||
shadow_color = "rgba(0, 0, 0, 1.0)";
|
||||
shadow_size = 3;
|
||||
}
|
||||
{
|
||||
monitor = "";
|
||||
text = ''<span font_weight="bold"> $USER</span>'';
|
||||
color = "rgb(202, 211, 245)";
|
||||
font_size = 25;
|
||||
font_family = "MonaspiceNe Nerd Font";
|
||||
valign = "top";
|
||||
halign = "left";
|
||||
position = "10, 0";
|
||||
rotate = "0.000000";
|
||||
shadow_boost = "1.200000";
|
||||
shadow_color = "rgba(0, 0, 0, 1.0)";
|
||||
shadow_size = 3;
|
||||
shadow_passes = 1;
|
||||
}
|
||||
{
|
||||
monitor = "";
|
||||
text = ''<span font_weight="ultrabold"> </span>'';
|
||||
color = "rgb(202, 211, 245)";
|
||||
font_size = 50;
|
||||
font_family = "MonaspiceNe Nerd Font";
|
||||
valign = "center";
|
||||
halign = "center";
|
||||
position = "15, -350";
|
||||
rotate = "0.000000";
|
||||
shadow_boost = "1.200000";
|
||||
shadow_color = "rgba(0, 0, 0, 1.0)";
|
||||
shadow_size = 3;
|
||||
shadow_passes = 1;
|
||||
}
|
||||
{
|
||||
monitor = "";
|
||||
text = ''<span font_weight="bold">Locked</span>'';
|
||||
color = "rgb(202, 211, 245)";
|
||||
font_size = 25;
|
||||
font_family = "MonaspiceNe Nerd Font";
|
||||
valign = "center";
|
||||
halign = "center";
|
||||
position = "0, -430";
|
||||
rotate = "0.000000";
|
||||
shadow_boost = "1.200000";
|
||||
shadow_color = "rgba(0, 0, 0, 1.0)";
|
||||
shadow_size = 3;
|
||||
shadow_passes = 1;
|
||||
}
|
||||
{
|
||||
monitor = "";
|
||||
text = ''
|
||||
cmd[update:120000] echo "<span font_weight='bold'>$(date +'%a %d %B')</span>"'';
|
||||
color = "rgb(202, 211, 245)";
|
||||
font_size = 30;
|
||||
font_family = "MonaspiceNe Nerd Font";
|
||||
valign = "center";
|
||||
halign = "center";
|
||||
position = "0, 210";
|
||||
rotate = "0.000000";
|
||||
shadow_boost = "1.200000";
|
||||
shadow_color = "rgba(0, 0, 0, 1.0)";
|
||||
shadow_size = 3;
|
||||
shadow_passes = 1;
|
||||
}
|
||||
{
|
||||
monitor = "";
|
||||
text = ''<span font_weight="ultrabold"> </span>'';
|
||||
color = "rgb(202, 211, 245)";
|
||||
font_size = 25;
|
||||
font_family = "MonaspiceNe Nerd Font";
|
||||
valign = "bottom";
|
||||
halign = "right";
|
||||
position = "5, 8";
|
||||
rotate = "0.000000";
|
||||
shadow_boost = "1.200000";
|
||||
shadow_color = "rgba(0, 0, 0, 1.0)";
|
||||
shadow_size = 3;
|
||||
shadow_passes = 1;
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.hyprlock = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/hypr/hyprlock.conf \
|
||||
${./complex-configuration.conf}
|
||||
'';
|
||||
}
|
4
tests/modules/programs/hyprlock/default.nix
Normal file
4
tests/modules/programs/hyprlock/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
hyprlock-basic-configuration = ./basic-configuration.nix;
|
||||
hyprlock-complex-configuration = ./complex-configuration.nix;
|
||||
}
|
Loading…
Reference in a new issue