copy: no check sigs for chroot store

This commit is contained in:
Ophestra 2025-07-29 22:59:42 +09:00
parent 87382aebed
commit 2f5e75ae25
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
2 changed files with 23 additions and 3 deletions

View File

@ -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)

View File

@ -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&parallel-compression=false&region=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)
}
})
}