Class: ConfCtl::NixCopy

Inherits:
Object
  • Object
show all
Defined in:
lib/confctl/nix_copy.rb

Instance Method Summary collapse

Constructor Details

#initialize(target, store_path) ⇒ NixCopy

Returns a new instance of NixCopy.

Parameters:

  • target (String)
  • store_path (String)


5
6
7
8
9
10
# File 'lib/confctl/nix_copy.rb', line 5

def initialize(target, store_path)
  @target = target
  @store_path = store_path
  @total = nil
  @progress = 0
end

Instance Method Details

#run! {|progress, total, path| ... } ⇒ Object

Yield Parameters:

  • progress (Integer)
  • total (Integer)
  • path (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/confctl/nix_copy.rb', line 15

def run!(&block)
  cmd = SystemCommand.new

  line_buf = StdLineBuffer.new do |_out, err|
    parse_line(err, &block) if err && block
  end

  ret = cmd.run!(
    'nix-copy-closure',
    '--to', "root@#{target}",
    store_path,
    &line_buf.feed_block
  )

  line_buf.flush
  ret
end