exec: append custom store

This is primarily for chroot stores. This might not be useful however since chroot store breaks builds.
This commit is contained in:
2025-07-23 12:09:32 +09:00
parent b6961508e8
commit 4d9d4bcef2
7 changed files with 56 additions and 12 deletions

View File

@@ -45,11 +45,14 @@ func main() {
}
}
var extraArgs []string
var (
store nix.Store
extraArgs []string
)
flagStore = strings.TrimSpace(flagStore)
if flagStore != string(os.PathSeparator) {
store = nix.Local(flagStore)
extraArgs = append(extraArgs,
"--store", flagStore,
// do not use any binary cache
nix.FlagOption, nix.OptionBuildUseSubstitutes, nix.ValueFalse,
nix.FlagOption, nix.OptionSubstituters, "",
@@ -62,7 +65,7 @@ func main() {
if flagVerbose {
stderr = os.Stderr
}
ctx = nix.New(nixCtx, extraArgs, os.Stdout, stderr)
ctx = nix.New(nixCtx, store, extraArgs, os.Stdout, stderr)
return nil
}).
@@ -111,7 +114,7 @@ func main() {
}
log.Println("copying to binary cache...")
if err := nix.Copy(ctx, flagCacheKeyPath, &nix.BinaryCache{
if err := nix.Copy(ctx, &nix.BinaryCache{
Compression: flagCacheComp,
ParallelCompression: flagCachePComp,
Bucket: flagCacheBucket,
@@ -119,6 +122,7 @@ func main() {
Region: flagCacheRegion,
Scheme: flagCacheScheme,
CredentialsPath: flagCacheCredPath,
KeyPath: flagCacheKeyPath,
}, slices.Values(collective)); err != nil {
return commandHandlerError(fmt.Sprintf("cannot copy: %v", err))
}