From 14f7199d652c5b3cfad93322a03153d5ff3db351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 9 Mar 2024 18:22:30 +0100 Subject: [PATCH] xlock: Add option --- hm/common.nix | 4 +++- hm/desktop/lock/default.nix | 6 +----- hm/gpg/default.nix | 3 +++ hm/ssh.nix | 5 ++++- install_os.sh | 1 - options.nix | 5 +++++ 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/hm/common.nix b/hm/common.nix index 91f70c6..3bc7557 100644 --- a/hm/common.nix +++ b/hm/common.nix @@ -1,5 +1,8 @@ { pkgs, config, lib, ... }: { + frogeye.hooks.lock = '' + ${pkgs.coreutils}/bin/rm -rf "/tmp/cached_pass_$UID" + ''; programs = { home-manager.enable = true; bat = { @@ -205,6 +208,5 @@ "${config.home.homeDirectory}/.config/dotfiles/hm/scripts" # Not Nix path otherwise it gets converted into store, # and then every time you want to modify a script you have to rebuild and re-login... ]; - # TODO Way to automatically setup an home-manager install }; } diff --git a/hm/desktop/lock/default.nix b/hm/desktop/lock/default.nix index 086d2da..22f0bb4 100644 --- a/hm/desktop/lock/default.nix +++ b/hm/desktop/lock/default.nix @@ -18,11 +18,7 @@ in (pkgs.writeShellApplication { name = "xlock"; text = '' - # Remove SSH and GPG keys from keystores - ${pkgs.openssh}/bin/ssh-add -D - echo RELOADAGENT | ${pkgs.gnupg}/bin/gpg-connect-agent - ${pkgs.coreutils}/bin/rm -rf "/tmp/cached_pass_$UID" - # TODO Should probably be an option and defined where relevant? + ${config.frogeye.hooks.lock} # TODO Maybe we could have a terminal lock? With vlock. # TODO Does that work for all DMs? diff --git a/hm/gpg/default.nix b/hm/gpg/default.nix index 612aebe..45413e2 100644 --- a/hm/gpg/default.nix +++ b/hm/gpg/default.nix @@ -1,6 +1,9 @@ { pkgs, lib, config, ... }: { config = lib.mkIf config.programs.gpg.enable { + frogeye.hooks.lock = '' + echo RELOADAGENT | ${pkgs.gnupg}/bin/gpg-connect-agent + ''; programs.gpg = { homedir = "${config.xdg.stateHome}/gnupg"; settings = { diff --git a/hm/ssh.nix b/hm/ssh.nix index f085041..d506641 100644 --- a/hm/ssh.nix +++ b/hm/ssh.nix @@ -1,6 +1,9 @@ -{ ... }: +{ pkgs, lib, config, ... }: { config = { + frogeye.hooks.lock = '' + ${pkgs.openssh}/bin/ssh-add -D + ''; programs.ssh = { enable = true; controlMaster = "auto"; diff --git a/install_os.sh b/install_os.sh index 62e37cd..9ebf07f 100755 --- a/install_os.sh +++ b/install_os.sh @@ -103,7 +103,6 @@ echo "{ # Install NixOS! Or create a new generation. sudo nix --extra-experimental-features "nix-command flakes" run "${SCRIPT_DIR}#nixos-install" -- --no-root-password --root "$mountpoint" --flake "${mountpoint}/etc/nixos#${name}" -# TODO Add this? --flake "$flake" set +x diff --git a/options.nix b/options.nix index 0f9f151..c127951 100644 --- a/options.nix +++ b/options.nix @@ -43,6 +43,11 @@ prose = lib.mkEnableOption "Writing stuff"; python = lib.mkEnableOption "Python dev stuff"; }; + hooks.lock = lib.mkOption { + type = lib.types.lines; + default = ""; + description = "Bash commands to execute on locking the session."; + }; }; config = {