diff --git a/copy.go b/copy.go index ca62909..af4c49d 100644 --- a/copy.go +++ b/copy.go @@ -19,6 +19,10 @@ func Copy(ctx Context, store Store, installables iter.Seq[string]) error { 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) diff --git a/copy_test.go b/copy_test.go index 873a082..2f84aad 100644 --- a/copy_test.go +++ b/copy_test.go @@ -14,10 +14,15 @@ import ( func init() { stubCommandInit = append(stubCommandInit, func(c command.Command) { var ( - flagCopyTo string - flagCopyStdin bool + flagCopyTo string + flagCopyStdin bool + flagNoCheckSigs bool ) c.NewCommand(nix.CommandCopy, "emit samples for various `nix copy` cases", func(args []string) error { + if flagNoCheckSigs && flagCopyStdin && flagCopyTo == "/" { + return nil + } + if flagCopyTo != "s3://example?compression=none¶llel-compression=false®ion=us-east-1&scheme=http&endpoint=s3.example.org&secret-key="+nonexistent || !flagCopyStdin { return syscall.ENOSYS } @@ -32,7 +37,8 @@ func init() { return nil }). Flag(&flagCopyTo, trimFlagName(nix.FlagTo), command.StringFlag(""), nix.FlagTo). - Flag(&flagCopyStdin, trimFlagName(nix.FlagStdin), command.BoolFlag(false), nix.FlagStdin) + Flag(&flagCopyStdin, trimFlagName(nix.FlagStdin), command.BoolFlag(false), nix.FlagStdin). + Flag(&flagNoCheckSigs, trimFlagName(nix.FlagNoCheckSigs), command.BoolFlag(false), nix.FlagNoCheckSigs) }) } @@ -64,4 +70,14 @@ func TestCopy(t *testing.T) { t.Errorf("Copy: error = %v, want %v", err, os.ErrInvalid) } }) + + t.Run("chroot store", func(t *testing.T) { + if err := nix.Copy( + newStubContext(t.Context(), nil, os.Stdout, os.Stderr), + nix.Local(os.PathSeparator), + slices.Values([]string{"/nix/store"}), + ); err != nil { + t.Errorf("Copy: error = %v", err) + } + }) }