Class: OsCtld::DistConfig::NixOS

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

Instance Attribute Summary

Attributes inherited from Base

#ct, #distribution, #version

Instance Method Summary collapse

Methods inherited from Base

#add_netif, distribution, #dns_resolvers, #initialize, #passwd, #remove_netif, #rename_netif, #update_etc_hosts, #writable?

Methods included from Utils::SwitchUser

#ct_attach, #ct_syscmd

Constructor Details

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

Instance Method Details

#bin_path(_opts) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/osctld/dist_config/nixos.rb', line 30

def bin_path(_opts)
  begin
    system = File.readlink(File.join(ct.runtime_rootfs, '/run/current-system'))

  rescue RuntimeError
    system = File.readlink(File.join(ct.rootfs, '/run/current-system'))
  end

  sw = File.readlink(File.join(ct.rootfs, system, 'sw'))
  File.join(sw, 'bin')
end

#network(_opts) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/osctld/dist_config/nixos.rb', line 11

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

  %w(add del).each do |operation|

    cmds = ct.netifs.map do |netif|
      OsCtld::ErbTemplate.render(
        File.join(tpl_base, netif.type.to_s),
        {netif: netif, op: operation}
      )
    end

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

  end
end

#set_hostname(opts) ⇒ Object



7
8
9
# File 'lib/osctld/dist_config/nixos.rb', line 7

def set_hostname(opts)
  log(:warn, ct, "Unable to apply hostname to NixOS container")
end