From 059ee08f5c73fdff81231cf23fa14fd6fcec8a2d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 Dec 2019 21:51:21 +0100 Subject: [PATCH] Use nix-master --- flake.lock | 13 +++++++++++++ flake.nix | 26 ++++++++++++++++++++------ generate-programs-index.cc | 23 ++++++++++++----------- index-debuginfo.cc | 8 ++++---- 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/flake.lock b/flake.lock index 5730064..e96b9e4 100644 --- a/flake.lock +++ b/flake.lock @@ -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=", diff --git a/flake.nix b/flake.nix index 2437513..cd3fb26 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; diff --git a/generate-programs-index.cc b/generate-programs-index.cc index ab23601..2ffa670 100644 --- a/generate-programs-index.cc +++ b/generate-programs-index.cc @@ -49,13 +49,13 @@ void mainWrapped(int argc, char * * argv) auto binaryCache = openStore(binaryCacheUri).cast(); /* Get the allowed store paths to be included in the database. */ - auto allowedPaths = tokenizeString(readFile(storePathsFile, true)); + auto allowedPaths = binaryCache->parseStorePathSet(tokenizeString(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 packagesByPath; + std::map 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(); diff --git a/index-debuginfo.cc b/index-debuginfo.cc index 33f26f6..4c69834 100644 --- a/index-debuginfo.cc +++ b/index-debuginfo.cc @@ -29,7 +29,7 @@ void mainWrapped(int argc, char * * argv) if (hasSuffix(binaryCacheUri, "/")) binaryCacheUri.pop_back(); auto binaryCache = openStore(binaryCacheUri).cast(); - auto storePaths = tokenizeString(readFile(storePathsFile, true)); + auto storePaths = binaryCache->parseStorePathSet(tokenizeString(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(); + auto info = binaryCache->queryPathInfo(binaryCache->parseStorePath(storePath)).cast(); 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(); }