vagrant-nixos-plugin 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +11 -0
- data/README.md +18 -7
- data/lib/vagrant-nixos/config.rb +0 -13
- data/lib/vagrant-nixos/provisioner.rb +29 -1
- data/lib/vagrant-nixos/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b888301e9de12a3856d4300228926f0f1364744
|
4
|
+
data.tar.gz: 20deffa245d0c4e9013f2d4bed593362a8ef3a5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a6b9a4375edfa85a0b9b4f445462fe758a42dbd43cdff71db8800a7297c76f99d0c320fb3d1e5283a5a4535fba44ca8cdf7c82ee50b4f6b208c3acea8e7e1bf
|
7
|
+
data.tar.gz: bea6a48fd6bb2f463f10d72fcaa6fb5b590463a303d6c41b73956ba06e8e6ab442acae6d2b785c0a549a1f525552577d789a41d515bce990333fa26c1867eee2
|
data/History.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
|
2
|
+
0.2.0 / 2015-10-27
|
3
|
+
==================
|
4
|
+
|
5
|
+
This release changes how import works.
|
6
|
+
|
7
|
+
They are no-longer a configuration option but are automatically detected from
|
8
|
+
the content of /etc/nixos/vagrant-*.nix
|
9
|
+
|
10
|
+
On top of that /etc/nixos/vagrant-{network,hostname}.nix are automatically
|
11
|
+
removed if not defined in the Vagrantfile.
|
12
|
+
|
2
13
|
0.1.1 / 2015-10-18
|
3
14
|
==================
|
4
15
|
|
data/README.md
CHANGED
@@ -35,11 +35,13 @@ Vagrant.configure("2") do |config|
|
|
35
35
|
config.vm.network "private_network", ip: "172.16.16.16"
|
36
36
|
|
37
37
|
# Add the htop package
|
38
|
-
config.vm.provision :nixos,
|
39
|
-
|
40
|
-
|
38
|
+
config.vm.provision :nixos,
|
39
|
+
run: 'always',
|
40
|
+
expression: {
|
41
|
+
environment: {
|
42
|
+
systemPackages: [ :htop ]
|
43
|
+
}
|
41
44
|
}
|
42
|
-
}
|
43
45
|
|
44
46
|
end
|
45
47
|
```
|
@@ -52,12 +54,13 @@ method.
|
|
52
54
|
|
53
55
|
```ruby
|
54
56
|
config.vm.provision :nixos,
|
57
|
+
run: 'always',
|
55
58
|
inline: %{
|
56
59
|
{config, pkgs, ...}: with pkgs; {
|
57
60
|
environment.systemPackages = [ htop ];
|
58
61
|
}
|
59
62
|
},
|
60
|
-
NIX_PATH:
|
63
|
+
NIX_PATH: '/vagrant/nixpkgs'
|
61
64
|
```
|
62
65
|
|
63
66
|
The above example also shows the optional setting of a custom `NIX_PATH` path.
|
@@ -65,13 +68,14 @@ The above example also shows the optional setting of a custom `NIX_PATH` path.
|
|
65
68
|
You can also use an external nix configuration file:
|
66
69
|
|
67
70
|
```ruby
|
68
|
-
config.vm.provision :nixos, path: "configuration.nix"
|
71
|
+
config.vm.provision :nixos, run: 'always', path: "configuration.nix"
|
69
72
|
```
|
70
73
|
|
71
74
|
If you need provisioning to be included explicitly during rebuild use:
|
72
75
|
|
73
76
|
```ruby
|
74
77
|
config.vm.provision :nixos,
|
78
|
+
run: 'always',
|
75
79
|
path: “configuration.nix”,
|
76
80
|
include: true
|
77
81
|
```
|
@@ -80,6 +84,7 @@ You can enable verbose provision output during rebuild process with:
|
|
80
84
|
|
81
85
|
```ruby
|
82
86
|
config.vm.provision :nixos,
|
87
|
+
run: 'always',
|
83
88
|
path: “configuration.nix”,
|
84
89
|
verbose: true
|
85
90
|
```
|
@@ -116,7 +121,13 @@ clean and provisioning possible.
|
|
116
121
|
|
117
122
|
Box creators should ensure that their `configuration.nix` file imports an nix
|
118
123
|
module `/etc/nixos/vagrant.nix` which will be overwritten by
|
119
|
-
`vagrant-nixos-plugin` during `vagrant up` or `vagrant provision
|
124
|
+
`vagrant-nixos-plugin` during `vagrant up` or `vagrant provision` and by
|
125
|
+
vagrant for the /etc/nixos/vagrant-hostname.nix and
|
126
|
+
/etc/nixos/vagrant-network.nix files.
|
127
|
+
|
128
|
+
When declaring the provisioner it is recommended to add the `run: 'always'`
|
129
|
+
attribute to make sure that changes to the Vagrantfile are reflected during
|
130
|
+
reload.
|
120
131
|
|
121
132
|
See the configuration in our
|
122
133
|
[NixOS packer template](http://github.com/zimbatm/nixbox) for an example.
|
data/lib/vagrant-nixos/config.rb
CHANGED
@@ -25,10 +25,6 @@ module VagrantPlugins
|
|
25
25
|
# @return [String, nil]
|
26
26
|
attr_accessor :NIX_PATH
|
27
27
|
|
28
|
-
# Configure which files to import in the vagrant.nix file
|
29
|
-
# @return [Array<String>]
|
30
|
-
attr_accessor :imports
|
31
|
-
|
32
28
|
def initialize
|
33
29
|
@inline = UNSET_VALUE
|
34
30
|
@path = UNSET_VALUE
|
@@ -36,11 +32,6 @@ module VagrantPlugins
|
|
36
32
|
@include = UNSET_VALUE
|
37
33
|
@verbose = UNSET_VALUE
|
38
34
|
@NIX_PATH = UNSET_VALUE
|
39
|
-
@imports = [
|
40
|
-
"./vagrant-network.nix",
|
41
|
-
"./vagrant-hostname.nix",
|
42
|
-
"./vagrant-provision.nix",
|
43
|
-
]
|
44
35
|
end
|
45
36
|
|
46
37
|
def finalize!
|
@@ -67,10 +58,6 @@ module VagrantPlugins
|
|
67
58
|
errors << "Invalid path #{path}"
|
68
59
|
end
|
69
60
|
|
70
|
-
unless imports.is_a?(Array)
|
71
|
-
errors << "Expected imports to be an array of paths"
|
72
|
-
end
|
73
|
-
|
74
61
|
{ "nixos provisioner" => errors }
|
75
62
|
end
|
76
63
|
end
|
@@ -55,12 +55,24 @@ module VagrantPlugins
|
|
55
55
|
|
56
56
|
# rebuild the base vagrant.nix configuration
|
57
57
|
def prepare!
|
58
|
+
cleanup_hostname!
|
59
|
+
cleanup_network!
|
60
|
+
|
61
|
+
imports = ''
|
62
|
+
|
63
|
+
# Find all /etc/nixos/vagrant-*.nix files
|
64
|
+
machine.communicate.tap do |c|
|
65
|
+
c.execute('find /etc/nixos -maxdepth 1 -type f -name "vagrant-*.nix"') do |type, data|
|
66
|
+
imports << data
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
58
70
|
# build
|
59
71
|
conf = <<CONF
|
60
72
|
{ config, pkgs, ... }:
|
61
73
|
{
|
62
74
|
imports = [
|
63
|
-
#{
|
75
|
+
#{imports.lines.join(" ").strip}
|
64
76
|
];
|
65
77
|
CONF
|
66
78
|
# default NIX_PATH
|
@@ -97,6 +109,22 @@ CONF
|
|
97
109
|
return changed
|
98
110
|
end
|
99
111
|
|
112
|
+
# Cleanup the hostname file if it hasn't been configured in the
|
113
|
+
# Vagrantfile.
|
114
|
+
def cleanup_hostname!
|
115
|
+
return unless machine.config.vm.hostname.nil?
|
116
|
+
machine.communicate.sudo("rm -f /etc/nixos/vagrant-hostname.nix")
|
117
|
+
end
|
118
|
+
|
119
|
+
# Cleanup the network file if it hasn't been set in the Vagrantfile
|
120
|
+
def cleanup_network!
|
121
|
+
# Abort if a private network has been defined
|
122
|
+
machine.config.vm.networks.each do |cfg|
|
123
|
+
return if cfg[0] == :private_network
|
124
|
+
end
|
125
|
+
machine.communicate.sudo("rm -f /etc/nixos/vagrant-network.nix")
|
126
|
+
end
|
127
|
+
|
100
128
|
def same?(f1, f2)
|
101
129
|
machine.communicate.test("cmp --silent #{f1} #{f2}")
|
102
130
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-nixos-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Farmiloe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|