about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--internal/importer/options.go2
-rw-r--r--internal/importer/package.go7
2 files changed, 5 insertions, 4 deletions
diff --git a/internal/importer/options.go b/internal/importer/options.go
index 1247681..51a6eb4 100644
--- a/internal/importer/options.go
+++ b/internal/importer/options.go
@@ -120,7 +120,6 @@ func (i *OptionIngester) Process(parent context.Context) (<-chan nix.Importable,
 
 			var decls []*nix.Link
 			for _, decl := range x["declarations"].([]interface{}) {
-				i.optJSON = nixOptionJSON{}
 
 				switch decl := reflect.ValueOf(decl); decl.Kind() {
 				case reflect.String:
@@ -152,6 +151,7 @@ func (i *OptionIngester) Process(parent context.Context) (<-chan nix.Importable,
 				x["declarations"] = decls
 			}
 
+			i.optJSON = nixOptionJSON{}
 			err := i.ms.Decode(x) // stores in optJSON
 			if err != nil {
 				errs <- errors.WithMessagef(err, "failed to decode option %#v", x)
diff --git a/internal/importer/package.go b/internal/importer/package.go
index 4e006cb..3905016 100644
--- a/internal/importer/package.go
+++ b/internal/importer/package.go
@@ -39,7 +39,7 @@ type maintainerJSON struct {
 type PackageIngester struct {
 	dec    *jstream.Decoder
 	ms     *mapstructure.Decoder
-	pkg    *packageJSON
+	pkg    packageJSON
 	infile io.ReadCloser
 	source *config.Source
 }
@@ -62,14 +62,14 @@ func makeAdhocPlatform(v any) string {
 func NewPackageProcessor(infile io.ReadCloser, source *config.Source) (*PackageIngester, error) {
 	i := &PackageIngester{
 		dec:    jstream.NewDecoder(infile, 2).EmitKV(),
-		pkg:    &packageJSON{},
+		pkg:    packageJSON{},
 		infile: infile,
 		source: source,
 	}
 
 	ms, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
 		ZeroFields: true,
-		Result:     i.pkg,
+		Result:     &i.pkg,
 		Squash:     true,
 		DecodeHook: mapstructure.TextUnmarshallerHookFunc(),
 	})
@@ -203,6 +203,7 @@ func (i *PackageIngester) Process(parent context.Context) (<-chan nix.Importable
 				}
 			}
 
+			i.pkg = packageJSON{}
 			err = i.ms.Decode(x) // stores in i.pkg
 			if err != nil {
 				errs <- errors.WithMessagef(err, "failed to decode package %#v", x)