1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00

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

@ -28,6 +28,7 @@ let
./modules/system/defaults/LaunchServices.nix
./modules/system/defaults/dock.nix
./modules/system/defaults/finder.nix
./modules/system/defaults/smb.nix
./modules/system/defaults/trackpad.nix
./modules/system/applications.nix
./modules/system/etc.nix

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.";
};
};
}

14
tests/networking.nix Normal file
View file

@ -0,0 +1,14 @@
{ config, pkgs, ... }:
{
networking.hostName = "EVE";
test = ''
echo checking hostname in /activate >&2
grep "scutil --set ComputerName 'EVE'" ${config.out}/activate
grep "scutil --set LocalHostName 'EVE'" ${config.out}/activate
grep "scutil --set HostName 'EVE'" ${config.out}/activate
echo checking defaults write in ${config.out}/activate-user >&2
grep "defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server 'NetBIOSName' -string 'EVE'" ${config.out}/activate-user
'';
}