Class: OsCtld::DistConfig::Distributions::NixOS::Configurator

Inherits:
Configurator
  • Object
show all
Defined in:
lib/osctld/dist_config/distributions/nixos.rb

Instance Attribute Summary

Attributes inherited from Configurator

#ctid, #distribution, #network_backend, #rootfs, #version

Instance Method Summary collapse

Methods inherited from Configurator

#add_netif, #dns_resolvers, #initialize, #instantiate_network_class, #log_type, #remove_netif, #rename_netif, #set_hostname, #unset_etc_hosts, #update_etc_hosts

Methods included from Helpers::Common

#systemd_service_enabled?, #systemd_service_masked?, #writable?

Constructor Details

This class inherits a constructor from OsCtld::DistConfig::Configurator

Instance Method Details

#network(netifs) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/osctld/dist_config/distributions/nixos.rb', line 8

def network(netifs)
  tpl_base = 'dist_config/network/nixos'

  %w[add del].each do |operation|
    cmds = netifs.map do |netif|
      OsCtld::ErbTemplate.render(
        File.join(tpl_base, netif.type.to_s),
        { netif:, op: operation }
      )
    end

    writable?(File.join(rootfs, "ifcfg.#{operation}")) do |path|
      File.write(path, cmds.join("\n"))
    end
  end
end

#network_classObject (protected)



27
28
29
# File 'lib/osctld/dist_config/distributions/nixos.rb', line 27

def network_class
  nil
end