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.
This commit is contained in:
adisbladis 2022-05-31 03:41:32 +08:00
parent fb910de8cc
commit d7830bd5b2
5 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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
}

2
go.mod
View file

@ -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

2
go.sum
View file

@ -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=

View file

@ -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="