@@ -20,10 +20,18 @@ type JobSpec struct {
2020 User string `json:"user"` // ssh user
2121}
2222
23- func buildClosure (flake string , spec JobSpec ) (string , error ) {
23+ func buildClosure (flake string , spec JobSpec , builder string ) (string , error ) {
2424 expr := fmt .Sprintf ("%s#%sConfigurations.%s.config.system.build.toplevel" , flake , spec .Type , spec .Output )
2525
26- data , err := runJSON ("nix" , "build" , "--no-link" , "--json" , expr )
26+ var data []byte
27+ var err error
28+
29+ if builder != "localhost" {
30+ data , err = runJSON ("nix" , "build" , "--no-link" , "--json" , "--store" , fmt .Sprintf ("ssh-ng://%s" , builder ), expr )
31+ } else {
32+ data , err = runJSON ("nix" , "build" , "--no-link" , "--json" , expr )
33+ }
34+
2735 if err != nil {
2836 return "" , fmt .Errorf ("Failed to build %s: %v" , spec .Output , err )
2937 }
@@ -36,6 +44,10 @@ func buildClosure(flake string, spec JobSpec) (string, error) {
3644 out , ok := res [0 ].Outputs ["out" ]
3745 if ! ok {
3846 return "" , fmt .Errorf ("Missing 'out' for %s" , spec .Output )
47+ } else if builder != "localhost" {
48+ if _ , err := run ("nix" , "copy" , "--from" , "ssh-ng://" + builder , out , "--no-check-sigs" ); err != nil {
49+ return "" , fmt .Errorf ("Error copying from %s: %v" , builder , err )
50+ }
3951 }
4052
4153 return out , nil
@@ -59,7 +71,7 @@ func deployClosure(name string, spec JobSpec, outs map[string]string, op string)
5971 cmds = append (cmds , []string {"ssh" , target , "sudo" , path + "/bin/switch-to-configuration" , op })
6072 }
6173
62- if _ , err := run ("nix" , "copy" , "--to" , "ssh://" + target , path ); err != nil {
74+ if _ , err := run ("nix" , "copy" , "--to" , "ssh-ng ://" + target , path ); err != nil {
6375 return fmt .Errorf ("error copying to %s: %v" , target , err )
6476 }
6577
0 commit comments