1
0
Fork 0

module(hypridle): create module

This commit is contained in:
Antoine Langlois 2024-03-24 14:08:27 +01:00
parent 64846a8f8e
commit 1c4127c1d4
Signed by: DataHearth
GPG Key ID: 946E2D0C410C7B3D
6 changed files with 140 additions and 9 deletions

View File

@ -93,7 +93,7 @@
},
"flake-utils_2": {
"inputs": {
"systems": "systems_3"
"systems": "systems_4"
},
"locked": {
"lastModified": 1701680307,
@ -111,7 +111,7 @@
},
"flake-utils_3": {
"inputs": {
"systems": "systems_4"
"systems": "systems_5"
},
"locked": {
"lastModified": 1701680307,
@ -190,7 +190,50 @@
"type": "github"
}
},
"hypridle": {
"inputs": {
"hyprlang": "hyprlang",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_2"
},
"locked": {
"lastModified": 1710180874,
"narHash": "sha256-ZSn3wXQuRz36Ta/L+UCFKuUVG6QpwK2QmRkPjpQprU4=",
"owner": "hyprwm",
"repo": "hypridle",
"rev": "4395339a2dc410bcf49f3e24f9ed3024fdb25b0a",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hypridle",
"type": "github"
}
},
"hyprlang": {
"inputs": {
"nixpkgs": [
"hypridle",
"nixpkgs"
]
},
"locked": {
"lastModified": 1708212860,
"narHash": "sha256-nW3Zrhh9RJcMTvOcXAaKADnJM/g6tDf3121lJtTHnYo=",
"owner": "hyprwm",
"repo": "hyprlang",
"rev": "11d5ccda071c153dfdc18ef65338956a51cef96a",
"type": "github"
},
"original": {
"owner": "hyprwm",
"repo": "hyprlang",
"type": "github"
}
},
"hyprlang_2": {
"inputs": {
"nixpkgs": [
"hyprlock",
@ -213,11 +256,11 @@
},
"hyprlock": {
"inputs": {
"hyprlang": "hyprlang",
"hyprlang": "hyprlang_2",
"nixpkgs": [
"nixpkgs"
],
"systems": "systems_2"
"systems": "systems_3"
},
"locked": {
"lastModified": 1711206123,
@ -348,6 +391,7 @@
"inputs": {
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"hypridle": "hypridle",
"hyprlock": "hyprlock",
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs",
@ -385,6 +429,21 @@
}
},
"systems_3": {
"locked": {
"lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
"owner": "nix-systems",
"repo": "default-linux",
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default-linux",
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@ -399,7 +458,7 @@
"type": "github"
}
},
"systems_4": {
"systems_5": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",

View File

@ -20,6 +20,10 @@
url = "github:hyprwm/hyprlock";
inputs.nixpkgs.follows = "nixpkgs";
};
hypridle = {
url = "github:hyprwm/hypridle";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{
@ -30,13 +34,14 @@
flake-utils,
nixvim,
hyprlock,
hypridle,
...
}:
{
nixosConfigurations = {
antoine-nixos = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit hyprlock; };
specialArgs = { inherit hyprlock hypridle; };
modules = [
./hosts/antoine-nixos/configuration.nix
home-manager.nixosModules.home-manager

View File

@ -1,4 +1,4 @@
{ pkgs, lib, hyprlock, ... }:
{ pkgs, lib, hyprlock, hypridle, ... }:
{
imports = [
# Modules
@ -122,7 +122,7 @@
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = { inherit hyprlock; };
extraSpecialArgs = { inherit hyprlock hypridle; };
users = {
"datahearth" = import ./home-manager/home.nix;
};

View File

@ -1,4 +1,4 @@
{ pkgs, lib, hyprlock, ... }:
{ pkgs, lib, hyprlock, hypridle, ... }:
{
imports = let
modules_base_path = ../../../modules;
@ -12,6 +12,7 @@
../../shared/hm.nix
./services.nix
hyprlock.homeManagerModules.default
hypridle.homeManagerModules.default
] ++ (import ../../../modules/home-manager);
# Almost static information
@ -67,6 +68,7 @@
dunst.enable = true;
waybar.enable = true;
ssh.enable = true;
hypridle.enable = true;
hyprlock = {
enable = true;

View File

@ -6,4 +6,5 @@
./waybar
./ssh
./hyprlock.nix
./hypridle.nix
]

View File

@ -0,0 +1,64 @@
{ config, options, lib, ...}:
with lib;
let
cfg = config.hm.hypridle;
enable = mkEnableOption "hypridle";
timeouts = {
lowerBrightness = mkOption {
type = types.int;
description = "Duration before screens brightness is lowered";
default = 120;
};
lock = mkOption {
type = types.int;
description = "Duration before locking session";
default = 180;
};
displaysOff = mkOption {
type = types.int;
description = "Duration before screens are turned off";
default = 210;
};
suspend = mkOption {
type = types.int;
description = "Duration before suspendind sessions";
default = 300;
};
};
in
{
options.hm.hypridle = {
inherit enable timeouts;
};
config = mkIf cfg.enable {
services.hypridle = {
enable = true;
lockCmd = "pidof hyprlock || hyprlock";
unlockCmd = "";
beforeSleepCmd = "loginctl lock-session";
afterSleepCmd = "hyprctl dispatch dpms on";
listeners = [
{
timeout = cfg.timeouts.lowerBrightness;
onTimeout = "brightnessctl -s set 10";
onResume = "brightnessctl -r";
}
{
timeout = cfg.timeouts.lock;
onTimeout = "loginctl lock-session";
}
{
timeout = cfg.timeouts.displaysOff;
onTimeout = "hyprctl dispatch dpms off";
onResume = "hyprctl dispatch dpms on";
}
{
timeout = cfg.timeouts.suspend;
onTimeout = "systemctl suspend";
}
];
};
};
}