31 lines
695 B
Go
31 lines
695 B
Go
package nix
|
|
|
|
import (
|
|
"context"
|
|
"iter"
|
|
"os"
|
|
)
|
|
|
|
// Copy copies installables to the binary cache store.
|
|
func Copy(ctx Context, store Store, installables iter.Seq[string]) error {
|
|
if store == nil {
|
|
return os.ErrInvalid
|
|
}
|
|
|
|
c, cancel := context.WithCancel(ctx.Unwrap())
|
|
defer cancel()
|
|
|
|
cmd := ctx.Nix(c, CommandCopy,
|
|
FlagTo, store.String(),
|
|
FlagStdin)
|
|
cmd.Env = append(os.Environ(), store.Environ()...)
|
|
if _, ok := store.(Local); ok {
|
|
// this is required for chroot stores, but does not seem to have any effect on binary cache
|
|
cmd.Args = append(cmd.Args, FlagNoCheckSigs)
|
|
}
|
|
|
|
cmd.Stdout, cmd.Stderr = ctx.Streams()
|
|
_, err := ctx.WriteStdin(cmd, installables, nil)
|
|
return err
|
|
}
|