Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 1 | { lib |
| 2 | , pkgs |
| 3 | , config |
| 4 | , ... |
| 5 | }: |
| 6 | let |
Skyler Grey | a2dabd7 | 2022-10-31 00:36:05 +0000 | [diff] [blame] | 7 | lockMessage = "This computer has been locked, please authenticate to continue"; |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 8 | in |
| 9 | { |
Skyler Grey | ff3c6a2 | 2022-08-21 07:25:02 +0100 | [diff] [blame] | 10 | config = { |
| 11 | security.apparmor = { |
| 12 | enable = true; |
| 13 | killUnconfinedConfinables = true; |
| 14 | }; |
| 15 | |
| 16 | boot.initrd.availableKernelModules = [ |
| 17 | "aesni_intel" |
| 18 | "cryptd" |
| 19 | ]; |
| 20 | |
| 21 | boot.initrd.luks.devices = { |
Skyler Grey | 9193593 | 2022-09-01 23:43:06 +0100 | [diff] [blame] | 22 | nix.device = "/dev/disk/by-label/NIX"; |
| 23 | swap.device = "/dev/disk/by-label/SWAP"; |
| 24 | hdd.device = "/dev/disk/by-label/HDD"; |
Skyler Grey | 0fa154f | 2022-08-21 07:30:37 +0100 | [diff] [blame] | 25 | }; |
Skyler Grey | 9193593 | 2022-09-01 23:43:06 +0100 | [diff] [blame] | 26 | |
| 27 | services.physlock = { |
| 28 | inherit lockMessage; |
| 29 | enable = true; |
| 30 | allowAnyUser = true; |
| 31 | }; |
| 32 | }; |
| 33 | |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 34 | home = |
| 35 | let |
| 36 | lockCommand = |
| 37 | lib.pipe '' |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 38 | ${pkgs.systemd}/bin/systemd-inhibit --why="Already locked" --what=idle --who="lock script" ${config.security.wrapperDir}/physlock -s -p "${lockMessage}" |
Skyler Grey | 252927a | 2022-10-18 22:18:15 +0100 | [diff] [blame] | 39 | '' [ |
| 40 | (lib.splitString "\n") |
| 41 | (lib.filter (line: line != "")) |
| 42 | (lib.concatStringsSep " && ") |
| 43 | ]; |
| 44 | in |
| 45 | { |
| 46 | services.swayidle = { |
| 47 | enable = true; |
| 48 | timeouts = [ |
| 49 | { |
| 50 | timeout = 60; |
| 51 | command = lockCommand; |
| 52 | } |
| 53 | ]; |
| 54 | }; |
| 55 | home.packages = [ |
| 56 | (pkgs.writeScriptBin "lock" lockCommand) |
Skyler Grey | 9193593 | 2022-09-01 23:43:06 +0100 | [diff] [blame] | 57 | ]; |
| 58 | }; |
Skyler Grey | 6aa7c26 | 2022-08-20 22:22:03 +0100 | [diff] [blame] | 59 | } |