From 663db0249d6509b5f3e24e8d696e935c8083c170 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sun, 28 Jan 2024 13:25:23 -0600 Subject: [PATCH] abstract locking --- hosts/mannaz/default.nix | 18 ++++++++-- modules/lock/default.nix | 53 +++++++++++++++------------- modules/roles/desktop.nix | 1 + modules/window-managers/hyprland.nix | 1 + modules/window-managers/qtile.nix | 20 +++++------ 5 files changed, 54 insertions(+), 39 deletions(-) diff --git a/hosts/mannaz/default.nix b/hosts/mannaz/default.nix index cc18e5f..cf76f90 100644 --- a/hosts/mannaz/default.nix +++ b/hosts/mannaz/default.nix @@ -7,11 +7,23 @@ }: { imports = with inputs.self.nixosModules; [ desktop - nvim - gui nix-ld ]; + # Enable the X11 windowing system. + services.xserver = { + enable = true; + displayManager.startx.enable = true; + windowManager.qtile.enable = true; + }; + + cli.enable = true; users.users.daylin.extraGroups = ["docker"]; -} +programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + } + diff --git a/modules/lock/default.nix b/modules/lock/default.nix index 5eb3237..c6aa664 100644 --- a/modules/lock/default.nix +++ b/modules/lock/default.nix @@ -1,34 +1,37 @@ { - input, + inputs, pkgs, + config, + lib, ... }: let + inherit (lib) mkIf; + cfg = config.services.xserver.windowManager.qtile; lock = pkgs.writeShellApplication { - name = "lock"; - runtimeInputs = with pkgs; [i3lock-color figlet procps]; - text = builtins.readFile ./lock.sh; - }; + name = "lock"; + runtimeInputs = with pkgs; [i3lock-color figlet procps]; + text = builtins.readFile ./lock.sh; + }; + + in { - environment.systemPackages = with pkgs; [ - xss-lock + config = mkIf cfg.enable { + environment.systemPackages = with pkgs; [ + xss-lock + lock + ]; - lock - ]; + systemd.services.i3lock = { + wantedBy = ["sleep.target"]; + description = "Lock the screen using a custom lock script"; + before = ["suspend.target"]; + serviceConfig = { + User = "daylin"; + Type = "forking"; + Environment = "DISPLAY=:0"; + ExecStart = "${lock}/bin/lock"; + }; + }; - systemd.services.i3lock = { - wantedBy = ["sleep.target"]; - description = "Lock the screen using a custom lock script"; - before = ["suspend.target"]; - serviceConfig = { - User = "daylin"; - Type = "forking"; - Environment = "DISPLAY=:0"; - ExecStart = "${lock}/bin/lock"; }; - }; - - # services.logind.extraConfig = '' - # IdleAction=suspend - # IdleActionSec=1800 - # ''; -} + } diff --git a/modules/roles/desktop.nix b/modules/roles/desktop.nix index 9b3b153..53c2567 100644 --- a/modules/roles/desktop.nix +++ b/modules/roles/desktop.nix @@ -7,6 +7,7 @@ imports = with inputs.self.nixosModules; [ fonts gui + lock vscode hyprland ]; diff --git a/modules/window-managers/hyprland.nix b/modules/window-managers/hyprland.nix index 21fddfb..47a8df2 100644 --- a/modules/window-managers/hyprland.nix +++ b/modules/window-managers/hyprland.nix @@ -9,6 +9,7 @@ cfg = config.programs.hyprland; in { config = mkIf cfg.enable { + security.pam.services.swaylock = {}; programs.hyprland.package = inputs.hyprland.packages.${pkgs.system}.default; # Optional, hint electron apps to use wayland: diff --git a/modules/window-managers/qtile.nix b/modules/window-managers/qtile.nix index 49f3f2f..27d35f4 100644 --- a/modules/window-managers/qtile.nix +++ b/modules/window-managers/qtile.nix @@ -1,18 +1,14 @@ { inputs, pkgs, + config, + lib, ... -}: { - imports = with inputs.self.nixosModules; [ - lock - ]; - - # Enable the X11 windowing system. - services.xserver = { - enable = true; - displayManager.startx.enable = true; - windowManager.qtile.enable = true; - }; +}: let + inherit (lib) mkIf; + cfg = config.services.xserver.windowManager.qtile; +in { + config = mkIf cfg.enable { environment.systemPackages = with pkgs; [ brightnessctl @@ -39,5 +35,7 @@ flameshot catppuccin-cursors.mochaDark pavucontrol + ]; + }; }