From 2d5e37b1eb9fc72e0c13f2b0c14fca42c433514e Mon Sep 17 00:00:00 2001 From: Leyla Becker <git@jan-leila.com> Date: Tue, 24 Dec 2024 16:01:37 -0600 Subject: [PATCH] moved openssh config into home manager configs --- configurations/home-manager/leyla/default.nix | 4 ++++ modules/home-manager-modules/default.nix | 1 + modules/home-manager-modules/openssh.nix | 8 ++++++++ modules/nixos-modules/home-manager/default.nix | 1 + modules/nixos-modules/home-manager/openssh.nix | 11 +++++++++++ modules/nixos-modules/ssh.nix | 10 +--------- 6 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 modules/home-manager-modules/openssh.nix create mode 100644 modules/nixos-modules/home-manager/openssh.nix diff --git a/configurations/home-manager/leyla/default.nix b/configurations/home-manager/leyla/default.nix index 48d38db..8b41e3a 100644 --- a/configurations/home-manager/leyla/default.nix +++ b/configurations/home-manager/leyla/default.nix @@ -105,6 +105,10 @@ }; }; bash.enable = true; + + openssh.authorizedKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHeItmt8TRW43uNcOC+eIurYC7Eunc0V3LGocQqLaYj leyla@horizon" + ]; }; dconf = { diff --git a/modules/home-manager-modules/default.nix b/modules/home-manager-modules/default.nix index 9fb37f2..ef9bf0a 100644 --- a/modules/home-manager-modules/default.nix +++ b/modules/home-manager-modules/default.nix @@ -3,5 +3,6 @@ imports = [ ./flipperzero.nix ./i18n.nix + ./openssh.nix ]; } diff --git a/modules/home-manager-modules/openssh.nix b/modules/home-manager-modules/openssh.nix new file mode 100644 index 0000000..ef4f11f --- /dev/null +++ b/modules/home-manager-modules/openssh.nix @@ -0,0 +1,8 @@ +{lib, ...}: { + options.programs = { + openssh.authorizedKeys = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + }; + }; +} diff --git a/modules/nixos-modules/home-manager/default.nix b/modules/nixos-modules/home-manager/default.nix index 3848e1b..cab004b 100644 --- a/modules/nixos-modules/home-manager/default.nix +++ b/modules/nixos-modules/home-manager/default.nix @@ -3,5 +3,6 @@ imports = [ ./flipperzero.nix ./i18n.nix + ./openssh.nix ]; } diff --git a/modules/nixos-modules/home-manager/openssh.nix b/modules/nixos-modules/home-manager/openssh.nix new file mode 100644 index 0000000..31a785f --- /dev/null +++ b/modules/nixos-modules/home-manager/openssh.nix @@ -0,0 +1,11 @@ +{ + config, + lib, + ... +}: { + users.users = + lib.attrsets.mapAttrs (name: value: { + openssh.authorizedKeys.keys = value.programs.openssh.authorizedKeys; + }) + config.home-manager.users; +} diff --git a/modules/nixos-modules/ssh.nix b/modules/nixos-modules/ssh.nix index bda4e81..0360cfc 100644 --- a/modules/nixos-modules/ssh.nix +++ b/modules/nixos-modules/ssh.nix @@ -1,12 +1,4 @@ -{ - lib, - config, - ... -}: { - users.users.leyla.openssh.authorizedKeys.keys = lib.mkIf config.host.users.leyla.isTerminalUser [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJHeItmt8TRW43uNcOC+eIurYC7Eunc0V3LGocQqLaYj leyla@horizon" - ]; - +{...}: { services = { openssh = { enable = true;