diff options
| author | Michael Hoang <Enzime@users.noreply.github.com> | 2025-01-12 08:33:32 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-12 08:33:32 +1100 |
| commit | 6ace2f2d12bdf74235d5cbf9fbd34a71c9716685 (patch) | |
| tree | c155f6ca377f8975fcabc1fcab193a6479e69037 | |
| parent | 57733bd1dc81900e13438e5b4439239f1b29db0e (diff) | |
| parent | be4c1b897accbdfc3429e99b5bd5234c5663776e (diff) | |
Merge pull request #1172 from Enzime/push-yxtrnyuxzmny
openssh: init module
| -rw-r--r-- | modules/module-list.nix | 1 | ||||
| -rw-r--r-- | modules/services/openssh.nix | 33 |
2 files changed, 34 insertions, 0 deletions
diff --git a/modules/module-list.nix b/modules/module-list.nix index aa190c7..8b2215b 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -82,6 +82,7 @@ ./services/nix-gc ./services/nix-optimise ./services/ofborg + ./services/openssh.nix ./services/postgresql ./services/privoxy ./services/redis diff --git a/modules/services/openssh.nix b/modules/services/openssh.nix new file mode 100644 index 0000000..859f79d --- /dev/null +++ b/modules/services/openssh.nix @@ -0,0 +1,33 @@ +{ config, lib, ... }: + +let + cfg = config.services.openssh; +in +{ + options = { + services.openssh.enable = lib.mkOption { + type = lib.types.nullOr lib.types.bool; + default = null; + description = '' + Whether to enable Apple's built-in OpenSSH server. + + The default is null which means let macOS manage the OpenSSH server. + ''; + }; + }; + + config = { + # We don't use `systemsetup -setremotelogin` as it requires Full Disk Access + system.activationScripts.launchd.text = lib.mkIf (cfg.enable != null) (if cfg.enable then '' + if [[ "$(systemsetup -getremotelogin | sed 's/Remote Login: //')" == "Off" ]]; then + launchctl enable system/com.openssh.sshd + launchctl bootstrap system /System/Library/LaunchDaemons/ssh.plist + fi + '' else '' + if [[ "$(systemsetup -getremotelogin | sed 's/Remote Login: //')" == "On" ]]; then + launchctl bootout system/com.openssh.sshd + launchctl disable system/com.openssh.sshd + fi + ''); + }; +} |
