diff --git a/modules/module-list.nix b/modules/module-list.nix index db3ce36..1d9ec4d 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -16,6 +16,7 @@ ./environment/shell.nix ./home-manager.nix ./nixpkgs/options.nix + ./services/openssh.nix ./supervisord.nix ./terminal.nix ./time.nix diff --git a/modules/services/openssh.nix b/modules/services/openssh.nix new file mode 100644 index 0000000..08e2030 --- /dev/null +++ b/modules/services/openssh.nix @@ -0,0 +1,137 @@ +# Parts from nixpkgs/nixos/modules/services/networking/ssh/sshd.nix +# MIT Licensed. Copyright (c) 2003-2022 Eelco Dolstra and the Nixpkgs/NixOS contributors + +{ pkgs, lib, config, ... }: +let + inherit (lib) + types + flip + concatStringsSep + concatMapStrings + optionalString; + + cfg = config.services.openssh; + + uncheckedConf = '' + ${concatMapStrings (port: '' + Port ${toString port} + '') cfg.ports} + PasswordAuthentication ${if cfg.passwordAuthentication then "yes" else "no"} + ${flip concatMapStrings cfg.hostKeys (k: '' + HostKey ${k.path} + '')} + ${optionalString cfg.allowSFTP '' + Subsystem sftp ${cfg.package}/libexec/sftp-server + ''} + SetEnv PATH=${config.user.home}/.nix-profile/bin:/usr/bin:/bin + ${cfg.extraConfig} + ''; + + sshdConf = pkgs.runCommand "sshd.conf-validated" { + nativeBuildInputs = [ cfg.package ]; + } '' + cat >$out <