diff options
-rw-r--r-- | internal/fetcher/nixpkgs-channel.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/internal/fetcher/nixpkgs-channel.go b/internal/fetcher/nixpkgs-channel.go index e36728c..32aaac3 100644 --- a/internal/fetcher/nixpkgs-channel.go +++ b/internal/fetcher/nixpkgs-channel.go @@ -23,11 +23,11 @@ func makeChannelURL(channel string, subPath string) (string, error) { return url, errors.WithMessagef(err, "error creating URL") } -var filesToFetch = map[string]string{ - "revision": "git-revision", - "options": "options.json.br", - "packages": "packages.json.br", -} +const ( + revisionFilename = "git-revision" + optionsFilename = "options.json.br" + packagesFileName = "packages.json.br" +) func (i *NixpkgsChannelFetcher) FetchIfNeeded( parent context.Context, @@ -44,6 +44,15 @@ func (i *NixpkgsChannelFetcher) FetchIfNeeded( return } + filesToFetch := make([]string, 2) + filesToFetch[0] = revisionFilename + switch i.Source.Importer { + case config.Packages: + filesToFetch[1] = packagesFileName + case config.Options: + filesToFetch[1] = optionsFilename + } + var fetchURL string for _, filename := range filesToFetch { fetchURL, err = makeChannelURL(i.Source.Channel, filename) |