Class: VagrantPlugins::Nixos::Cap::ChangeHostName

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util
Defined in:
lib/vagrant-nixos/cap/change_host_name.rb

Class Method Summary collapse

Class Method Details

.change_host_name(machine, name) ⇒ Object



20
21
22
23
24
# File 'lib/vagrant-nixos/cap/change_host_name.rb', line 20

def self.change_host_name(machine, name)
  if Nixos.write_config(machine, "vagrant-hostname.nix", nix_module(name))
    Nixos.rebuild(machine)
  end
end

.nix_module(name) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/vagrant-nixos/cap/change_host_name.rb', line 11

def self.nix_module(name)
  "    { config, pkgs, ... }:\n    {\n      networking.hostName = \"\#{name}\";\n    }\n  NIX\nend\n"