Use nix-master

This commit is contained in:
Eelco Dolstra 2019-12-30 21:51:21 +01:00
parent aec148383a
commit 059ee08f5c
4 changed files with 49 additions and 21 deletions

View file

@ -1,5 +1,18 @@
{
"inputs": {
"nix": {
"inputs": {
"nixpkgs": {
"inputs": {},
"narHash": "sha256-HKuPcp/pBpKNBOnDlrSzObee5eB0LdzhI0RpRjTVxik=",
"originalUrl": "nixpkgs/release-19.09",
"url": "github:edolstra/nixpkgs/03f3def66a104a221aac8b751eeb7075374848fd"
}
},
"narHash": "sha256-wiOmdFFMhuBGEcAURvj7c1LAcVbO82QjcFr+5WjuNzM=",
"originalUrl": "nix",
"url": "github:NixOS/nix/c7866733d7ce2836fbb43de90dd64d17b0d20753"
},
"nixpkgs": {
"inputs": {},
"narHash": "sha256-HKuPcp/pBpKNBOnDlrSzObee5eB0LdzhI0RpRjTVxik=",

View file

@ -5,7 +5,7 @@
inputs.nixpkgs.url = "nixpkgs/release-19.09";
outputs = { self, nixpkgs }:
outputs = { self, nixpkgs, nix }:
{
@ -14,8 +14,22 @@
nixos-channel-scripts = with final; stdenv.mkDerivation {
name = "nixos-channel-scripts";
buildInputs = with perlPackages;
[ pkgconfig nix sqlite makeWrapper perl FileSlurp LWP LWPProtocolHttps ListMoreUtils DBDSQLite NetAmazonS3 boehmgc nlohmann_json boost ];
buildInputs = with final.perlPackages;
[ pkgconfig
final.nix
sqlite
makeWrapper
perl
FileSlurp
LWP
LWPProtocolHttps
ListMoreUtils
DBDSQLite
NetAmazonS3
boehmgc
nlohmann_json
boost
];
buildCommand = ''
mkdir -p $out/bin
@ -27,13 +41,13 @@
$(pkg-config --libs nix-main) \
$(pkg-config --libs nix-expr) \
$(pkg-config --libs nix-store) \
-lsqlite3 -lgc
-lsqlite3 -lgc -lnixrust
g++ -Os -g ${./index-debuginfo.cc} -Wall -std=c++14 -o $out/bin/index-debuginfo -I . \
$(pkg-config --cflags nix-main) \
$(pkg-config --libs nix-main) \
$(pkg-config --libs nix-store) \
-lsqlite3
-lsqlite3 -lnixrust
cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch
wrapProgram $out/bin/mirror-nixos-branch --set PERL5LIB $PERL5LIB --prefix PATH : ${wget}/bin:${git}/bin:${nix}/bin:${gnutar}/bin:${xz}/bin:${rsync}/bin:${openssh}/bin:$out/bin
@ -46,7 +60,7 @@
defaultPackage.x86_64-linux = (import nixpkgs {
system = "x86_64-linux";
overlays = [ self.overlay ];
overlays = [ nix.overlay self.overlay ];
}).nixos-channel-scripts;
};

View file

@ -49,13 +49,13 @@ void mainWrapped(int argc, char * * argv)
auto binaryCache = openStore(binaryCacheUri).cast<BinaryCacheStore>();
/* Get the allowed store paths to be included in the database. */
auto allowedPaths = tokenizeString<PathSet>(readFile(storePathsFile, true));
auto allowedPaths = binaryCache->parseStorePathSet(tokenizeString<PathSet>(readFile(storePathsFile, true)));
PathSet allowedPathsClosure;
StorePathSet allowedPathsClosure;
binaryCache->computeFSClosure(allowedPaths, allowedPathsClosure);
printMsg(lvlInfo, format("%d top-level paths, %d paths in closure")
% allowedPaths.size() % allowedPathsClosure.size());
printMsg(lvlInfo, "%d top-level paths, %d paths in closure",
allowedPaths.size(), allowedPathsClosure.size());
FileCache fileCache(cacheDbPath);
@ -104,24 +104,25 @@ void mainWrapped(int argc, char * * argv)
/* For each store path, figure out the package with the shortest
attribute name. E.g. "nix" is preferred over "nixStable". */
std::map<Path, DrvInfo *> packagesByPath;
std::map<StorePath, DrvInfo *> packagesByPath;
for (auto & package : packages)
try {
auto outputs = package.queryOutputs(true);
for (auto & output : outputs) {
if (!allowedPathsClosure.count(output.second)) continue;
auto i = packagesByPath.find(output.second);
auto storePath = binaryCache->parseStorePath(output.second);
if (!allowedPathsClosure.count(storePath)) continue;
auto i = packagesByPath.find(storePath);
if (i != packagesByPath.end() &&
(i->second->attrPath.size() < package.attrPath.size() ||
(i->second->attrPath.size() == package.attrPath.size() && i->second->attrPath < package.attrPath)))
(i->second->attrPath.size() == package.attrPath.size() && i->second->attrPath < package.attrPath)))
continue;
packagesByPath[output.second] = &package;
packagesByPath.emplace(std::move(storePath), &package);
}
} catch (AssertionError & e) {
} catch (Error & e) {
e.addPrefix(format("in package %s: ") % package.attrPath);
e.addPrefix(fmt("in package %s: ", package.attrPath));
throw;
}
@ -203,7 +204,7 @@ void mainWrapped(int argc, char * * argv)
ThreadPool threadPool(16);
for (auto & i : packagesByPath)
threadPool.enqueue(std::bind(doPath, i.first, i.second));
threadPool.enqueue(std::bind(doPath, binaryCache->printStorePath(i.first), i.second));
threadPool.process();

View file

@ -29,7 +29,7 @@ void mainWrapped(int argc, char * * argv)
if (hasSuffix(binaryCacheUri, "/")) binaryCacheUri.pop_back();
auto binaryCache = openStore(binaryCacheUri).cast<S3BinaryCacheStore>();
auto storePaths = tokenizeString<PathSet>(readFile(storePathsFile, true));
auto storePaths = binaryCache->parseStorePathSet(tokenizeString<PathSet>(readFile(storePathsFile, true)));
std::regex debugFileRegex("^lib/debug/\\.build-id/[0-9a-f]{2}/[0-9a-f]{38}\\.debug$");
@ -68,7 +68,7 @@ void mainWrapped(int argc, char * * argv)
std::string(file.first, prefix.size(), 2) +
std::string(file.first, prefix.size() + 3, 38);
auto info = binaryCache->queryPathInfo(storePath).cast<const NarInfo>();
auto info = binaryCache->queryPathInfo(binaryCache->parseStorePath(storePath)).cast<const NarInfo>();
assert(hasPrefix(info->url, "nar/"));
@ -84,8 +84,8 @@ void mainWrapped(int argc, char * * argv)
};
for (auto & storePath : storePaths)
if (hasSuffix(storePath, "-debug"))
threadPool.enqueue(std::bind(doPath, storePath));
if (hasSuffix(storePath.name(), "-debug"))
threadPool.enqueue(std::bind(doPath, binaryCache->printStorePath(storePath)));
threadPool.process();
}