Fix incorrect hostname in flake URI on "hey ssh"

This commit is contained in:
Henrik Lissner 2021-02-14 14:43:48 -05:00
parent 4352f2362f
commit 82bab563cd

View file

@ -67,9 +67,10 @@ module Hey
noerror ? result : exit($?.exitstatus) noerror ? result : exit($?.exitstatus)
end end
end end
def self.rebuild(*args, sudo: false) def self.rebuild(*args, sudo: false, host: nil)
host ||= ENV['HOST'] || `hostname`.rstrip
sh ["nixos-rebuild", sh ["nixos-rebuild",
"--flake", @@opts[:flake], "--flake", "#{@@opts[:flake]}##{host}",
"--option", "pure-eval", "no", "--option", "pure-eval", "no",
*args], sudo: sudo *args], sudo: sudo
end end
@ -128,14 +129,14 @@ module Hey
opts '--fast', "TODO" opts '--fast', "TODO"
lambda do |args| lambda do |args|
Dir.chdir(@@opts[:flake]) do Dir.chdir(@@opts[:flake]) do
@@opts[:host] ||= ENV["HOST"] || `hostname`.rstrip
args = ["switch"] unless args.length > 0 args = ["switch"] unless args.length > 0
rebuild(*(@@opts[:"build-host"] ? ["--build-host", @@opts[:"build-host"]] : []), rebuild(*(@@opts[:"build-host"] ? ["--build-host", @@opts[:"build-host"]] : []),
*(@@opts[:"target-host"] ? ["--target-host", @@opts[:"target-host"]] : []), *(@@opts[:"target-host"] ? ["--target-host", @@opts[:"target-host"]] : []),
@@opts[:fast] ? "--fast" : nil, @@opts[:fast] ? "--fast" : nil,
@@opts[:debug] ? "--show-trace" : nil, @@opts[:debug] ? "--show-trace" : nil,
*args, *args,
sudo: !@@opts[:user]) sudo: !@@opts[:user],
host: @@opts[:host])
end end
end end
end end