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:
parent
3dfc5da1e7
commit
7eb4e21075
5 changed files with 33 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}
|
||||
'';
|
||||
|
|
13
modules/system/defaults/smb.nix
Normal file
13
modules/system/defaults/smb.nix
Normal 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
14
tests/networking.nix
Normal 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
|
||||
'';
|
||||
}
|
Loading…
Add table
Reference in a new issue