defaults: add option for NetBIOSName

This commit is contained in:
Daiderd Jordan 2018-01-05 00:15:11 +01:00
parent 3dfc5da1e7
commit 7eb4e21075
No known key found for this signature in database
GPG key ID: D02435D05B810C96
5 changed files with 33 additions and 8 deletions

View file

@ -3,34 +3,29 @@
with lib;
let
cfg = config.networking;
hostName = optionalString (cfg.hostName != null) ''
scutil --set ComputerName '${cfg.hostName}'
scutil --set LocalHostName '${cfg.hostName}'
scutil --set HostName '${cfg.hostName}'
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string '${cfg.hostName}'
'';
in
{
options = {
networking.hostName = mkOption {
type = types.nullOr types.str;
default = null;
example = "myhostname";
description = ''
Hostname for your machine.
'';
description = "Hostname for your machine.";
};
};
config = {
system.defaults.smb.NetBIOSName = cfg.hostName;
system.activationScripts.networking.text = ''
# Set defaults
echo "configuring networking..." >&2

View file

@ -26,6 +26,7 @@ let
LaunchServices = defaultsToList "com.apple.LaunchServices" cfg.LaunchServices;
dock = defaultsToList "com.apple.dock" cfg.dock;
finder = defaultsToList "com.apple.finder" cfg.finder;
smb = defaultsToList "/Library/Preferences/SystemConfiguration/com.apple.smb.server" cfg.smb;
trackpad = defaultsToList "com.apple.AppleMultitouchTrackpad" cfg.trackpad;
trackpadBluetooth = defaultsToList "com.apple.driver.AppleBluetoothMultitouch.trackpad" cfg.trackpad;
@ -45,6 +46,7 @@ in
${concatStringsSep "\n" LaunchServices}
${concatStringsSep "\n" dock}
${concatStringsSep "\n" finder}
${concatStringsSep "\n" smb}
${concatStringsSep "\n" trackpad}
${concatStringsSep "\n" trackpadBluetooth}
'';

View file

@ -0,0 +1,13 @@
{ config, lib, ... }:
with lib;
{
options = {
system.defaults.smb.NetBIOSName = mkOption {
type = types.nullOr types.str;
default = null;
description = "Hostname to use for NetBIOS.";
};
};
}