From d7830bd5b2b18689bafb763f7198315831d082c6 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Tue, 31 May 2022 03:41:32 +0800 Subject: [PATCH] Filter MacOS .DS_Store directories Now that we're hashing files directly from the Go sources on the host system we need to avoid these files. Closes #49. --- builder/fetch.sh | 2 ++ generate/generate.go | 5 ++++- go.mod | 2 +- go.sum | 2 ++ gomod2nix.toml | 4 ++-- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/builder/fetch.sh b/builder/fetch.sh index 5493a1c..2de6b08 100644 --- a/builder/fetch.sh +++ b/builder/fetch.sh @@ -8,3 +8,5 @@ go mod download "$goPackagePath@$version" dir=$(go mod download --json "$goPackagePath@$version" | jq -r .Dir) cp -r $dir $out + +find $out -iname ".ds_store" | xargs -r rm -r diff --git a/generate/generate.go b/generate/generate.go index 41365f8..4aa5f1e 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -10,6 +10,7 @@ import ( "os/exec" "path/filepath" "sort" + "strings" "sync" "github.com/nix-community/go-nix/pkg/nar" @@ -113,7 +114,9 @@ func GeneratePkgs(directory string, goMod2NixPath string, numWorkers int) ([]*sc }).Info("Calculating NAR hash") h := sha256.New() - err := nar.DumpPath(h, dl.Dir) + err := nar.DumpPathFilter(h, dl.Dir, func(name string, nodeType nar.NodeType) bool { + return strings.ToLower(filepath.Base(name)) != ".ds_store" + }) if err != nil { return err } diff --git a/go.mod b/go.mod index b2db4d3..12c959a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.14 require ( github.com/BurntSushi/toml v1.1.0 - github.com/nix-community/go-nix v0.0.0-20220528121639-b940fb0a12d8 + github.com/nix-community/go-nix v0.0.0-20220531154832-fb763dcb3ffc github.com/sirupsen/logrus v1.8.1 golang.org/x/mod v0.5.1 golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect diff --git a/go.sum b/go.sum index aeb765e..455542d 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,8 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/nix-community/go-nix v0.0.0-20220528121639-b940fb0a12d8 h1:IYr+3pldQtTwS55Xm2+3Ry81MpSKNVpMyYMNr7yQpts= github.com/nix-community/go-nix v0.0.0-20220528121639-b940fb0a12d8/go.mod h1:r5pCQAjHNSDWTsy6+UbacPN8EzMVJiCAXDWbRN2qfwU= +github.com/nix-community/go-nix v0.0.0-20220531154832-fb763dcb3ffc h1:/uRl4vxjqF0N8m8ha+TouWZxsMRCA98Fft24WNIb0L8= +github.com/nix-community/go-nix v0.0.0-20220531154832-fb763dcb3ffc/go.mod h1:r5pCQAjHNSDWTsy6+UbacPN8EzMVJiCAXDWbRN2qfwU= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/gomod2nix.toml b/gomod2nix.toml index c8322ea..968d573 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -29,8 +29,8 @@ schema = 1 version = "v0.1.0" hash = "sha256-QT65kTrNypS5GPWGvgnCpGLPlVbQAL4IYvuqAKhepb4=" [mod."github.com/nix-community/go-nix"] - version = "v0.0.0-20220528121639-b940fb0a12d8" - hash = "sha256-r6fq1mu0gRFqdI6msuAZp3ZoncAw5L16oBFPUA9vPYk=" + version = "v0.0.0-20220531154832-fb763dcb3ffc" + hash = "sha256-vCoRCe1DcyNXfz6gun9wGBu/o+j6WGcS8mbFmXZfyps=" [mod."github.com/pkg/errors"] version = "v0.9.1" hash = "sha256-mNfQtcrQmu3sNg/7IwiieKWOgFQOVVe2yXgKBpe/wZw="