diff options
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/autounlock.nix | 40 | ||||
-rw-r--r-- | nixos/modules/default.nix | 1 | ||||
-rw-r--r-- | nixos/modules/desktop.nix | 20 | ||||
-rw-r--r-- | nixos/modules/generic.nix | 2 |
4 files changed, 62 insertions, 1 deletions
diff --git a/nixos/modules/autounlock.nix b/nixos/modules/autounlock.nix new file mode 100644 index 0000000..2e40bb2 --- /dev/null +++ b/nixos/modules/autounlock.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cnf = config.cynerd.autounlock; + +in { + + options = { + cynerd.autounlock = mkOption { + type = with types; attrsOf string; + default = {}; + description = "Devices to be auto-unlocked."; + }; + }; + + config = mkIf (cnf != {}) { + + environment.systemPackages = [ pkgs.luks-hw-password ]; + boot.initrd = { + extraFiles."/bin/luks-password" = pkgs.luks-hw-password + "/bin/luks-hw-password"; + luks.devices = mapAttrs (name: value: { + device = value; + keyFile = "/keys/${name}.key"; + fallbackToPassword = true; + preOpenCommands = '' + mkdir -p /keys + luks-hw-password > /keys/${name}.key + ''; + postOpenCommands = '' + rm -rf /keys + ''; + }) cnf; + }; + + }; + +} diff --git a/nixos/modules/default.nix b/nixos/modules/default.nix index 1077dc7..278f2d8 100644 --- a/nixos/modules/default.nix +++ b/nixos/modules/default.nix @@ -1,4 +1,5 @@ nixpkgs: { + cynerd-autounlock = import ./autounlock.nix; cynerd-compile = import ./compile.nix; cynerd-desktop = import ./desktop.nix; cynerd-develop = import ./develop.nix nixpkgs; diff --git a/nixos/modules/desktop.nix b/nixos/modules/desktop.nix index 184c52d..d04b1fb 100644 --- a/nixos/modules/desktop.nix +++ b/nixos/modules/desktop.nix @@ -5,6 +5,14 @@ let cnf = config.cynerd.desktop; + autologinScript = pkgs.writeText "login-program.sh" '' + if [[ "$(tty)" == '/dev/tty1' ]]; then + ${pkgs.shadow}/bin/login -f cynerd; + else + ${pkgs.shadow}/bin/login; + fi + ''; + in { options = { @@ -197,5 +205,17 @@ in { }; }; + services.getty = { + extraArgs = [ "--skip-login" ]; + loginProgram = "${pkgs.bash}/bin/sh"; + loginOptions = toString (pkgs.writeText "login-program.sh" '' + if [[ "$(tty)" == '/dev/tty1' ]]; then + ${pkgs.shadow}/bin/login -f cynerd; + else + ${pkgs.shadow}/bin/login; + fi + ''); + }; + }; } diff --git a/nixos/modules/generic.nix b/nixos/modules/generic.nix index 67a80f8..ab47f19 100644 --- a/nixos/modules/generic.nix +++ b/nixos/modules/generic.nix @@ -30,7 +30,7 @@ with lib; git # We need git for this repository to even work # Administration tools coreutils moreutils psmisc progress lshw file - dig + drill gnumake exfat exfatprogs nix-index |