bcacheup: port to jamespfennell/xz, which is a wrapper around the C LZMA library rather than a Go reimplementation
This commit is contained in:
parent
e92bff517c
commit
aae1c8bea0
5 changed files with 36 additions and 12 deletions
|
@ -16,8 +16,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/jamespfennell/xz"
|
||||||
"github.com/numtide/go-nix/nixbase32"
|
"github.com/numtide/go-nix/nixbase32"
|
||||||
"github.com/ulikunitz/xz"
|
|
||||||
"gocloud.dev/blob"
|
"gocloud.dev/blob"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"golang.org/x/sync/singleflight"
|
"golang.org/x/sync/singleflight"
|
||||||
|
@ -236,10 +236,7 @@ func (u *uploader) uploadContent(ctx context.Context, ni *narinfo.NarInfo, path
|
||||||
|
|
||||||
fileByteCounter := &byteCounterWriter{}
|
fileByteCounter := &byteCounterWriter{}
|
||||||
|
|
||||||
xzWriter, err := xz.NewWriter(io.MultiWriter(fileHasher, fileByteCounter, dst))
|
xzWriter := xz.NewWriter(io.MultiWriter(fileHasher, fileByteCounter, dst))
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("creating xz writer: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
w := io.MultiWriter(narHasher, xzWriter)
|
w := io.MultiWriter(narHasher, xzWriter)
|
||||||
narSize, err := nar.Pack(w, nar.DirFS(u.storePath), filepath.Base(path))
|
narSize, err := nar.Pack(w, nar.DirFS(u.storePath), filepath.Base(path))
|
||||||
|
|
|
@ -14,7 +14,7 @@ depot.third_party.buildGo.program {
|
||||||
third_party.gopkgs."gocloud.dev".blob.gcsblob
|
third_party.gopkgs."gocloud.dev".blob.gcsblob
|
||||||
third_party.gopkgs."golang.org".x.sync.errgroup
|
third_party.gopkgs."golang.org".x.sync.errgroup
|
||||||
third_party.gopkgs."golang.org".x.sync.singleflight
|
third_party.gopkgs."golang.org".x.sync.singleflight
|
||||||
third_party.gopkgs."github.com".ulikunitz.xz
|
third_party.gopkgs."github.com".jamespfennell.xz
|
||||||
go.nix.nar
|
go.nix.nar
|
||||||
go.nix.nar.narinfo
|
go.nix.nar.narinfo
|
||||||
go.nix.nixstore
|
go.nix.nixstore
|
||||||
|
|
18
third_party/gopkgs/github.com/jamespfennell/xz/default.nix
vendored
Normal file
18
third_party/gopkgs/github.com/jamespfennell/xz/default.nix
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# SPDX-FileCopyrightText: 2022 Luke Granger-Brown <depot@lukegb.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
{ depot, pkgs, ... }:
|
||||||
|
depot.third_party.buildGo.external {
|
||||||
|
path = "github.com/jamespfennell/xz";
|
||||||
|
src = depot.third_party.nixpkgs.fetchFromGitHub {
|
||||||
|
owner = "jamespfennell";
|
||||||
|
repo = "xz";
|
||||||
|
rev = "v0.1.2";
|
||||||
|
hash = "sha256:0wdxda81zvzvxvkxazkn48qlw62nhyc4am9vj2yvv9ncas4gp7av";
|
||||||
|
};
|
||||||
|
cgo = true;
|
||||||
|
cgodeps = [ pkgs.lzma ];
|
||||||
|
cgocflags = [ "-DGOXZ_SKIP_C_COMPILATION" ];
|
||||||
|
cgoldflags = [ "-llzma" ];
|
||||||
|
}
|
10
third_party/tvl/nix/buildGo/external/default.nix
vendored
10
third_party/tvl/nix/buildGo/external/default.nix
vendored
|
@ -50,7 +50,7 @@ let
|
||||||
|
|
||||||
last = l: elemAt l ((length l) - 1);
|
last = l: elemAt l ((length l) - 1);
|
||||||
|
|
||||||
toPackage = self: src: path: depMap: entry: cgodeps:
|
toPackage = self: src: path: depMap: entry: cgodeps: cgocflags: cgoldflags:
|
||||||
let
|
let
|
||||||
localDeps = map
|
localDeps = map
|
||||||
(d: lib.attrByPath (d ++ [ "gopkg" ])
|
(d: lib.attrByPath (d ++ [ "gopkg" ])
|
||||||
|
@ -79,7 +79,9 @@ let
|
||||||
sfiles = map (f: src + ("/" + f)) entry.sfiles;
|
sfiles = map (f: src + ("/" + f)) entry.sfiles;
|
||||||
cgofiles = map (f: src + ("/" + f)) entry.cgofiles;
|
cgofiles = map (f: src + ("/" + f)) entry.cgofiles;
|
||||||
inherit cgodeps;
|
inherit cgodeps;
|
||||||
inherit (entry) packageName cgocflags cgoldflags;
|
cgocflags = entry.cgocflags ++ cgocflags;
|
||||||
|
cgoldflags = entry.cgoldflags ++ cgoldflags;
|
||||||
|
inherit (entry) packageName;
|
||||||
cfiles = map (f: src + ("/" + f)) entry.cfiles;
|
cfiles = map (f: src + ("/" + f)) entry.cfiles;
|
||||||
cxxfiles = map (f: src + ("/" + f)) entry.cxxfiles;
|
cxxfiles = map (f: src + ("/" + f)) entry.cxxfiles;
|
||||||
};
|
};
|
||||||
|
@ -91,7 +93,7 @@ let
|
||||||
if entry.isCommand then (program binArgs) else (package libArgs);
|
if entry.isCommand then (program binArgs) else (package libArgs);
|
||||||
|
|
||||||
in
|
in
|
||||||
{ src, path, deps ? [ ], tags ? [ ], cgo ? false, cgodeps ? [ ] }:
|
{ src, path, deps ? [ ], tags ? [ ], cgo ? false, cgodeps ? [ ], cgocflags ? [ ], cgoldflags ? [ ] }:
|
||||||
let
|
let
|
||||||
# Build a map of dependencies (from their import paths to their
|
# Build a map of dependencies (from their import paths to their
|
||||||
# derivation) so that they can be conditionally imported only in
|
# derivation) so that they can be conditionally imported only in
|
||||||
|
@ -110,5 +112,5 @@ let
|
||||||
analysis = fromJSON (readFile analysisOutput);
|
analysis = fromJSON (readFile analysisOutput);
|
||||||
in
|
in
|
||||||
lib.fix (self: foldl' lib.recursiveUpdate { } (
|
lib.fix (self: foldl' lib.recursiveUpdate { } (
|
||||||
map (entry: mkset entry.locator (toPackage self src path depMap entry cgodeps)) analysis
|
map (entry: mkset entry.locator (toPackage self src path depMap entry cgodeps cgocflags cgoldflags)) analysis
|
||||||
))
|
))
|
||||||
|
|
11
third_party/tvl/nix/buildGo/external/main.go
vendored
11
third_party/tvl/nix/buildGo/external/main.go
vendored
|
@ -87,6 +87,13 @@ func findGoDirs(at string) ([]string, error) {
|
||||||
return goDirs, nil
|
return goDirs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func forceEmpty[T any](m []T) []T {
|
||||||
|
if m == nil {
|
||||||
|
return make([]T, 0)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
// analysePackage loads and analyses the imports of a single Go
|
// analysePackage loads and analyses the imports of a single Go
|
||||||
// package, returning the data that is required by the Nix code to
|
// package, returning the data that is required by the Nix code to
|
||||||
// generate a derivation for this package.
|
// generate a derivation for this package.
|
||||||
|
@ -153,8 +160,8 @@ func analysePackage(root, source, importpath string, stdlib map[string]bool, tag
|
||||||
LocalDeps: local,
|
LocalDeps: local,
|
||||||
ForeignDeps: foreign,
|
ForeignDeps: foreign,
|
||||||
IsCommand: p.IsCommand(),
|
IsCommand: p.IsCommand(),
|
||||||
CgoCFLAGS: p.CgoCFLAGS,
|
CgoCFLAGS: forceEmpty(p.CgoCFLAGS),
|
||||||
CgoLDFLAGS: p.CgoLDFLAGS,
|
CgoLDFLAGS: forceEmpty(p.CgoLDFLAGS),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue