mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-06 08:47:00 +00:00
openssh: init module
This commit is contained in:
parent
57733bd1dc
commit
be4c1b897a
2 changed files with 34 additions and 0 deletions
|
@ -82,6 +82,7 @@
|
||||||
./services/nix-gc
|
./services/nix-gc
|
||||||
./services/nix-optimise
|
./services/nix-optimise
|
||||||
./services/ofborg
|
./services/ofborg
|
||||||
|
./services/openssh.nix
|
||||||
./services/postgresql
|
./services/postgresql
|
||||||
./services/privoxy
|
./services/privoxy
|
||||||
./services/redis
|
./services/redis
|
||||||
|
|
33
modules/services/openssh.nix
Normal file
33
modules/services/openssh.nix
Normal file
|
@ -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
|
||||||
|
'');
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue