Class: VagrantPlugins::Nixos::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-nixos/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vagrant-nixos/config.rb', line 32

def initialize
  @inline      = UNSET_VALUE
  @path        = UNSET_VALUE
  @expression  = UNSET_VALUE
  @include     = UNSET_VALUE
  @verbose     = UNSET_VALUE
  @NIX_PATH    = UNSET_VALUE
  @imports     = [
    "./vagrant-network.nix",
    "./vagrant-hostname.nix",
    "./vagrant-provision.nix",
  ]
end

Instance Attribute Details

#expressionHash?

Some inline ruby DSL that generates nix configuration data

Returns:



14
15
16
# File 'lib/vagrant-nixos/config.rb', line 14

def expression
  @expression
end

#importsArray<String>

Configure which files to import in the vagrant.nix file

Returns:



30
31
32
# File 'lib/vagrant-nixos/config.rb', line 30

def imports
  @imports
end

#includetrue, false

Include /etc/nixos/vagrant.nix in the build

Returns:

  • (true, false)


18
19
20
# File 'lib/vagrant-nixos/config.rb', line 18

def include
  @include
end

#inlineString?

Some inline nix configuration data

Returns:



6
7
8
# File 'lib/vagrant-nixos/config.rb', line 6

def inline
  @inline
end

#NIX_PATHString?

Override the default NIX_PATH

Returns:



26
27
28
# File 'lib/vagrant-nixos/config.rb', line 26

def NIX_PATH
  @NIX_PATH
end

#pathString?

The path to some nix configuration file

Returns:



10
11
12
# File 'lib/vagrant-nixos/config.rb', line 10

def path
  @path
end

#verbosetrue, false

Show debug information during the build

Returns:

  • (true, false)


22
23
24
# File 'lib/vagrant-nixos/config.rb', line 22

def verbose
  @verbose
end

Instance Method Details

#finalize!Object



46
47
48
49
50
51
52
53
# File 'lib/vagrant-nixos/config.rb', line 46

def finalize!
  @inline      = nil    if @inline      == UNSET_VALUE
  @path        = nil    if @path        == UNSET_VALUE
  @expression  = nil    if @expression  == UNSET_VALUE
  @include     = false  if @include     == UNSET_VALUE
  @verbose     = false  if @verbose     == UNSET_VALUE
  @NIX_PATH    = nil    if @NIX_PATH    == UNSET_VALUE
end

#validate(machine) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vagrant-nixos/config.rb', line 59

def validate(machine)
  errors = _detected_errors

  if (path && inline) or (path && expression) or (inline && expression)
    errors << "You can have one and only one of :path, :expression or :inline for nixos provisioner"
  end

  if path && !File.exist?(path)
    errors << "Invalid path #{path}"
  end

  unless imports.is_a?(Array)
    errors << "Expected imports to be an array of paths"
  end

  { "nixos provisioner" => errors }
end