summaryrefslogtreecommitdiff
path: root/modules/networking/default.nix
blob: 634618e1ef835bcff4014847b9bbf52160e11f3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ config, lib, pkgs, ... }:

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

in

{
  options = {

    networking.hostName = mkOption {
      type = types.nullOr types.str;
      default = null;
      example = "myhostname";
      description = ''
        Hostname for your machine.
      '';
    };

  };

  config = {

    system.activationScripts.networking.text = ''
      # Set defaults
      echo "configuring networking..." >&2

      ${hostName}
    '';

  };
}