From 9118dc8a5056ad0cdb91a0688f50ac5d6e28a1ec Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 17 Oct 2023 23:27:37 +0100 Subject: refactor(tvix/store): move deriver field into narinfo submessage This information is present in the .narinfo files, it should have gone there. Change-Id: Ib43d0cf30c2795bf1fe77c46646174353ade0458 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9794 Autosubmit: flokli Reviewed-by: Connor Brewster Tested-by: BuildkiteCI --- tvix/store-go/pathinfo.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'tvix/store-go/pathinfo.go') diff --git a/tvix/store-go/pathinfo.go b/tvix/store-go/pathinfo.go index 8c0b94f200..d0384c4fe2 100644 --- a/tvix/store-go/pathinfo.go +++ b/tvix/store-go/pathinfo.go @@ -49,6 +49,20 @@ func (p *PathInfo) Validate() (*storepath.StorePath, error) { ) } } + + // If the Deriver field is populated, ensure it parses to a StorePath. + // We can't check for it to *not* end with .drv, as the .drv files produced by + // recursive Nix end with multiple .drv suffixes, and only one is popped when + // converting to this field. + if deriver := narInfo.GetDeriver(); deriver != nil { + deriverStorePath := storepath.StorePath{ + Name: string(deriver.GetName()), + Digest: deriver.GetDigest(), + } + if err := deriverStorePath.Validate(); err != nil { + return nil, fmt.Errorf("invalid deriver field: %w", err) + } + } } // ensure there is a (root) node present @@ -81,19 +95,5 @@ func (p *PathInfo) Validate() (*storepath.StorePath, error) { return nil, fmt.Errorf("unable to parse root node name %s as StorePath: %w", rootNodeName, err) } - // If the Deriver field is populated, ensure it parses to a StorePath. - // We can't check for it to *not* end with .drv, as the .drv files produced by - // recursive Nix end with multiple .drv suffixes, and only one is popped when - // converting to this field. - if p.Deriver != nil { - deriverStorePath := storepath.StorePath{ - Name: string(p.Deriver.GetName()), - Digest: p.Deriver.GetDigest(), - } - if err := deriverStorePath.Validate(); err != nil { - return nil, fmt.Errorf("invalid deriver field: %w", err) - } - } - return storePath, nil } -- cgit 1.4.1