vagrant-nixos 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,10 +26,13 @@ module Nix
26
26
 
27
27
  def to_nix(indent = 0)
28
28
  s = ""
29
+ s << "(" if @exprs[0] == :import
29
30
  if @parent
30
31
  s = @parent.to_nix << "."
31
32
  end
32
33
  s << @exprs.map{|e| e.to_nix}.join(" ")
34
+ s << ")" if @exprs[0] == :import
35
+ s
33
36
  end
34
37
  end
35
38
  end
@@ -66,8 +69,9 @@ end
66
69
 
67
70
  class String
68
71
  def to_nix(indent = 0)
69
- # TODO: escape ${var} in string
70
- "''#{self}''"
72
+ return self if self.slice(0,2) == "./"
73
+ return %{''#{self}''} if self =~ /\n/
74
+ %{"#{self}"}
71
75
  end
72
76
  end
73
77
 
@@ -66,6 +66,11 @@ module VagrantPlugins
66
66
 
67
67
  # just do nixos-rebuild
68
68
  def self.rebuild!(machine, nix_env=nil)
69
+ # Add a tmp vagreant.nix file if it is missing
70
+ if !machine.communicate.test("grep 'provision' </etc/nixos/vagrant.nix")
71
+ _write_config(machine, "vagrant.nix", %{{ config, pkgs, ... }: { imports = [ ./vagrant-provision.nix ];}})
72
+ end
73
+ # rebuild
69
74
  rebuild_cmd = "nixos-rebuild switch"
70
75
  rebuild_cmd = "NIX_PATH=#{nix_env}:$NIX_PATH #{rebuild_cmd}" if nix_env
71
76
  machine.communicate.tap do |comm|
@@ -74,7 +79,7 @@ module VagrantPlugins
74
79
  end
75
80
 
76
81
  def self.same?(machine, f1, f2)
77
- machine.communicate.test("cmp --silent '#{f1}' '#{f2}'")
82
+ machine.communicate.test("cmp --silent #{f1} #{f2}")
78
83
  end
79
84
 
80
85
  protected
@@ -92,10 +97,12 @@ module VagrantPlugins
92
97
  source = "/tmp/#{filename}"
93
98
  target = "/etc/nixos/#{filename}"
94
99
  comm.upload(temp.path, source)
100
+ puts conf
95
101
  if same?(machine, source, target)
102
+ puts "SAME"
96
103
  changed = false
97
104
  else
98
- comm.sudo("mv '#{source}' '#{target}'")
105
+ comm.sudo("mv #{source} #{target}")
99
106
  end
100
107
  end
101
108
  return changed
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Nixos
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-nixos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -82,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  segments:
84
84
  - 0
85
- hash: 3098690903915324060
85
+ hash: 3612314916842241992
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  none: false
88
88
  requirements:
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  segments:
93
93
  - 0
94
- hash: 3098690903915324060
94
+ hash: 3612314916842241992
95
95
  requirements: []
96
96
  rubyforge_project:
97
97
  rubygems_version: 1.8.23