aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.nix86
-rw-r--r--mk/programs.mk2
-rw-r--r--src/libstore/globals.cc2
-rw-r--r--src/libutil/lazy.hh48
-rw-r--r--src/libutil/logging.hh2
-rw-r--r--src/libutil/types.hh1
-rw-r--r--src/libutil/util.cc6
-rw-r--r--src/nix/add-to-store.cc2
-rw-r--r--src/nix/eval.cc2
-rw-r--r--src/nix/flake.cc36
-rw-r--r--src/nix/hash.cc4
-rw-r--r--src/nix/ls.cc4
-rw-r--r--src/nix/profile.cc2
-rw-r--r--src/nix/registry.cc2
-rw-r--r--src/nix/search.cc6
-rw-r--r--src/nix/show-config.cc2
-rw-r--r--src/nix/why-depends.cc2
17 files changed, 108 insertions, 101 deletions
diff --git a/flake.nix b/flake.nix
index a707e90e7..bf2066157 100644
--- a/flake.nix
+++ b/flake.nix
@@ -59,6 +59,23 @@
"--with-sandbox-shell=${sh}/bin/busybox"
];
+
+ nativeBuildDeps =
+ [
+ buildPackages.bison
+ buildPackages.flex
+ buildPackages.libxml2
+ buildPackages.libxslt
+ buildPackages.docbook5
+ buildPackages.docbook_xsl_ns
+ buildPackages.autoreconfHook
+ buildPackages.pkgconfig
+
+ # Tests
+ buildPackages.git
+ buildPackages.mercurial
+ ];
+
buildDeps =
[ bison
flex
@@ -78,20 +95,16 @@
then nlohmann_json
else nlohmann_json.override { multipleHeaders = true; })
nlohmann_json
-
- # Tests
- git
- mercurial
- jq
gmock
]
++ lib.optionals stdenv.isLinux [libseccomp utillinuxMinimal]
- ++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
- ++ lib.optional (stdenv.isLinux || stdenv.isDarwin)
- (aws-sdk-cpp.override {
- apis = ["s3" "transfer"];
- customMemoryManagement = false;
- });
+ ++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium;
+
+ awsDeps = lib.optional (stdenv.isLinux || stdenv.isDarwin)
+ (aws-sdk-cpp.override {
+ apis = ["s3" "transfer"];
+ customMemoryManagement = false;
+ });
propagatedDeps =
[ (boehmgc.override { enableLargeConfig = true; })
@@ -118,7 +131,8 @@
outputs = [ "out" "dev" "doc" ];
- buildInputs = buildDeps;
+ nativeBuildInputs = nativeBuildDeps;
+ buildInputs = buildDeps ++ awsDeps;
propagatedBuildInputs = propagatedDeps;
@@ -192,10 +206,12 @@
hydraJobs = {
# Binary package for various platforms.
- build = nixpkgs.lib.genAttrs systems (system: nixpkgsFor.${system}.nix);
+ build = nixpkgs.lib.genAttrs systems (system: self.packages.${system}.nix);
+
+ build-static = nixpkgs.lib.genAttrs systems (system: self.packages.${system}.nix-static);
# Perl bindings for various platforms.
- perlBindings = nixpkgs.lib.genAttrs systems (system: nixpkgsFor.${system}.nix.perl-bindings);
+ perlBindings = nixpkgs.lib.genAttrs systems (system: self.packages.${system}.nix.perl-bindings);
# Binary tarball for various platforms, containing a Nix store
# with the closure of 'nix' package, and the second half of
@@ -301,7 +317,8 @@
enableParallelBuilding = true;
- buildInputs = buildDeps ++ propagatedDeps;
+ nativeBuildInputs = nativeBuildDeps;
+ buildInputs = buildDeps ++ propagatedDeps ++ awsDeps;
dontInstall = false;
@@ -405,11 +422,47 @@
checks = forAllSystems (system: {
binaryTarball = self.hydraJobs.binaryTarball.${system};
+ build-static = self.hydraJobs.build-static.${system};
perlBindings = self.hydraJobs.perlBindings.${system};
});
packages = forAllSystems (system: {
inherit (nixpkgsFor.${system}) nix;
+
+ nix-static = let
+ nixpkgs = nixpkgsFor.${system}.pkgsStatic;
+ in with commonDeps nixpkgs; nixpkgs.stdenv.mkDerivation {
+ name = "nix-${version}";
+
+ src = self;
+
+ VERSION_SUFFIX = versionSuffix;
+
+ outputs = [ "out" "dev" "doc" ];
+
+ nativeBuildInputs = nativeBuildDeps;
+ buildInputs = buildDeps ++ propagatedDeps;
+
+ configureFlags = [ "--sysconfdir=/etc" ];
+
+ enableParallelBuilding = true;
+
+ makeFlags = "profiledir=$(out)/etc/profile.d";
+
+ doCheck = true;
+
+ installFlags = "sysconfdir=$(out)/etc";
+
+ postInstall = ''
+ mkdir -p $doc/nix-support
+ echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
+ '';
+
+ doInstallCheck = true;
+ installCheckFlags = "sysconfdir=$(out)/etc";
+
+ stripAllList = ["bin"];
+ };
});
defaultPackage = forAllSystems (system: self.packages.${system}.nix);
@@ -421,7 +474,8 @@
stdenv.mkDerivation {
name = "nix";
- buildInputs = buildDeps ++ propagatedDeps ++ perlDeps;
+ nativeBuildInputs = nativeBuildDeps;
+ buildInputs = buildDeps ++ propagatedDeps ++ awsDeps ++ perlDeps;
inherit configureFlags;
diff --git a/mk/programs.mk b/mk/programs.mk
index 3fa9685c3..a96ff56af 100644
--- a/mk/programs.mk
+++ b/mk/programs.mk
@@ -32,7 +32,7 @@ define build-program
$$(eval $$(call create-dir, $$(_d)))
$$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/
- $$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
+ $$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) -lz
$(1)_INSTALL_DIR ?= $$(bindir)
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index 683fa5196..7aec6d1c0 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -8,7 +8,7 @@
#include <thread>
#include <dlfcn.h>
#include <sys/utsname.h>
-
+#include <unordered_set>
namespace nix {
diff --git a/src/libutil/lazy.hh b/src/libutil/lazy.hh
deleted file mode 100644
index d073e486c..000000000
--- a/src/libutil/lazy.hh
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <exception>
-#include <functional>
-#include <mutex>
-
-namespace nix {
-
-/* A helper class for lazily-initialized variables.
-
- Lazy<T> var([]() { return value; });
-
- declares a variable of type T that is initialized to 'value' (in a
- thread-safe way) on first use, that is, when var() is first
- called. If the initialiser code throws an exception, then all
- subsequent calls to var() will rethrow that exception. */
-template<typename T>
-class Lazy
-{
-
- typedef std::function<T()> Init;
-
- Init init;
-
- std::once_flag done;
-
- T value;
-
- std::exception_ptr ex;
-
-public:
-
- Lazy(Init init) : init(init)
- { }
-
- const T & operator () ()
- {
- std::call_once(done, [&]() {
- try {
- value = init();
- } catch (...) {
- ex = std::current_exception();
- }
- });
- if (ex) std::rethrow_exception(ex);
- return value;
- }
-};
-
-}
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index 09619aac6..b75b87f80 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -98,7 +98,7 @@ public:
virtual void writeToStdout(std::string_view s);
template<typename... Args>
- inline void stdout(const std::string & fs, const Args & ... args)
+ inline void stdout_(const std::string & fs, const Args & ... args)
{
boost::format f(fs);
formatHelper(f, args...);
diff --git a/src/libutil/types.hh b/src/libutil/types.hh
index 3af485fa0..2170e4c93 100644
--- a/src/libutil/types.hh
+++ b/src/libutil/types.hh
@@ -4,6 +4,7 @@
#include <list>
#include <set>
+#include <string>
#include <map>
#include <vector>
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 97d278581..5500d0f9a 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1,4 +1,3 @@
-#include "lazy.hh"
#include "util.hh"
#include "affinity.hh"
#include "sync.hh"
@@ -511,7 +510,8 @@ std::string getUserName()
}
-static Lazy<Path> getHome2([]() {
+static Path getHome2()
+{
auto homeDir = getEnv("HOME");
if (!homeDir) {
std::vector<char> buf(16384);
@@ -523,7 +523,7 @@ static Lazy<Path> getHome2([]() {
homeDir = pw->pw_dir;
}
return *homeDir;
-});
+};
Path getHome() { return getHome2(); }
diff --git a/src/nix/add-to-store.cc b/src/nix/add-to-store.cc
index ad1f9e91f..b3eec0146 100644
--- a/src/nix/add-to-store.cc
+++ b/src/nix/add-to-store.cc
@@ -58,7 +58,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
store->addToStore(info, source);
}
- logger->stdout("%s", store->printStorePath(info.path));
+ logger->stdout_("%s", store->printStorePath(info.path));
}
};
diff --git a/src/nix/eval.cc b/src/nix/eval.cc
index a8ca446be..9689f2bdb 100644
--- a/src/nix/eval.cc
+++ b/src/nix/eval.cc
@@ -85,7 +85,7 @@ struct CmdEval : MixJSON, InstallableCommand
printValueAsJSON(*state, true, *v, jsonOut, context);
} else {
state->forceValueDeep(*v);
- logger->stdout("%s", *v);
+ logger->stdout_("%s", *v);
}
}
};
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index 027a9871e..53e445695 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -62,17 +62,17 @@ public:
static void printFlakeInfo(const Store & store, const Flake & flake)
{
- logger->stdout("Resolved URL: %s", flake.resolvedRef.to_string());
- logger->stdout("Locked URL: %s", flake.lockedRef.to_string());
+ logger->stdout_("Resolved URL: %s", flake.resolvedRef.to_string());
+ logger->stdout_("Locked URL: %s", flake.lockedRef.to_string());
if (flake.description)
- logger->stdout("Description: %s", *flake.description);
- logger->stdout("Path: %s", store.printStorePath(flake.sourceInfo->storePath));
+ logger->stdout_("Description: %s", *flake.description);
+ logger->stdout_("Path: %s", store.printStorePath(flake.sourceInfo->storePath));
if (auto rev = flake.lockedRef.input.getRev())
- logger->stdout("Revision: %s", rev->to_string(Base16, false));
+ logger->stdout_("Revision: %s", rev->to_string(Base16, false));
if (auto revCount = flake.lockedRef.input.getRevCount())
- logger->stdout("Revisions: %s", *revCount);
+ logger->stdout_("Revisions: %s", *revCount);
if (auto lastModified = flake.lockedRef.input.getLastModified())
- logger->stdout("Last modified: %s",
+ logger->stdout_("Last modified: %s",
std::put_time(std::localtime(&*lastModified), "%F %T"));
}
@@ -140,7 +140,7 @@ struct CmdFlakeInfo : FlakeCommand, MixJSON
if (json) {
auto json = flakeToJson(*store, flake);
- logger->stdout("%s", json.dump());
+ logger->stdout_("%s", json.dump());
} else
printFlakeInfo(*store, flake);
}
@@ -158,9 +158,9 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
auto flake = lockFlake();
if (json)
- logger->stdout("%s", flake.lockFile.toJson());
+ logger->stdout_("%s", flake.lockFile.toJson());
else {
- logger->stdout("%s", flake.flake.lockedRef);
+ logger->stdout_("%s", flake.flake.lockedRef);
std::unordered_set<std::shared_ptr<Node>> visited;
@@ -172,7 +172,7 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
bool last = i + 1 == node.inputs.size();
if (auto lockedNode = std::get_if<0>(&input.second)) {
- logger->stdout("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
+ logger->stdout_("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
prefix + (last ? treeLast : treeConn), input.first,
*lockedNode ? (*lockedNode)->lockedRef : flake.flake.lockedRef);
@@ -180,7 +180,7 @@ struct CmdFlakeListInputs : FlakeCommand, MixJSON
if (firstVisit) recurse(**lockedNode, prefix + (last ? treeNull : treeLine));
} else if (auto follows = std::get_if<1>(&input.second)) {
- logger->stdout("%s" ANSI_BOLD "%s" ANSI_NORMAL " follows input '%s'",
+ logger->stdout_("%s" ANSI_BOLD "%s" ANSI_NORMAL " follows input '%s'",
prefix + (last ? treeLast : treeConn), input.first,
printInputPath(*follows));
}
@@ -793,7 +793,7 @@ struct CmdFlakeShow : FlakeCommand
try {
auto recurse = [&]()
{
- logger->stdout("%s", headerPrefix);
+ logger->stdout_("%s", headerPrefix);
auto attrs = visitor.getAttrs();
for (const auto & [i, attr] : enumerate(attrs)) {
bool last = i + 1 == attrs.size();
@@ -819,7 +819,7 @@ struct CmdFlakeShow : FlakeCommand
}
*/
- logger->stdout("%s: %s '%s'",
+ logger->stdout_("%s: %s '%s'",
headerPrefix,
attrPath.size() == 2 && attrPath[0] == "devShell" ? "development environment" :
attrPath.size() == 3 && attrPath[0] == "checks" ? "derivation" :
@@ -867,7 +867,7 @@ struct CmdFlakeShow : FlakeCommand
if (attrPath.size() == 1)
recurse();
else if (!showLegacy)
- logger->stdout("%s: " ANSI_YELLOW "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix);
+ logger->stdout_("%s: " ANSI_YELLOW "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix);
else {
if (visitor.isDerivation())
showDerivation();
@@ -884,7 +884,7 @@ struct CmdFlakeShow : FlakeCommand
auto aType = visitor.maybeGetAttr("type");
if (!aType || aType->getString() != "app")
throw EvalError("not an app definition");
- logger->stdout("%s: app", headerPrefix);
+ logger->stdout_("%s: app", headerPrefix);
}
else if (
@@ -892,11 +892,11 @@ struct CmdFlakeShow : FlakeCommand
(attrPath.size() == 2 && attrPath[0] == "templates"))
{
auto description = visitor.getAttr("description")->getString();
- logger->stdout("%s: template: " ANSI_BOLD "%s" ANSI_NORMAL, headerPrefix, description);
+ logger->stdout_("%s: template: " ANSI_BOLD "%s" ANSI_NORMAL, headerPrefix, description);
}
else {
- logger->stdout("%s: %s",
+ logger->stdout_("%s: %s",
headerPrefix,
attrPath.size() == 1 && attrPath[0] == "overlay" ? "Nixpkgs overlay" :
attrPath.size() == 2 && attrPath[0] == "nixosConfigurations" ? "NixOS configuration" :
diff --git a/src/nix/hash.cc b/src/nix/hash.cc
index b94751e45..3c117c29b 100644
--- a/src/nix/hash.cc
+++ b/src/nix/hash.cc
@@ -73,7 +73,7 @@ struct CmdHash : Command
Hash h = hashSink->finish().first;
if (truncate && h.hashSize > 20) h = compressHash(h, 20);
- logger->stdout(h.to_string(base, base == SRI));
+ logger->stdout_(h.to_string(base, base == SRI));
}
}
};
@@ -107,7 +107,7 @@ struct CmdToBase : Command
void run() override
{
for (auto s : args)
- logger->stdout(Hash(s, ht).to_string(base, base == SRI));
+ logger->stdout_(Hash(s, ht).to_string(base, base == SRI));
}
};
diff --git a/src/nix/ls.cc b/src/nix/ls.cc
index 76c8bc9a3..b1cf92692 100644
--- a/src/nix/ls.cc
+++ b/src/nix/ls.cc
@@ -37,11 +37,11 @@ struct MixLs : virtual Args, MixJSON
auto line = fmt("%s %20d %s", tp, st.fileSize, relPath);
if (st.type == FSAccessor::Type::tSymlink)
line += " -> " + accessor->readLink(curPath);
- logger->stdout(line);
+ logger->stdout_(line);
if (recursive && st.type == FSAccessor::Type::tDirectory)
doPath(st, curPath, relPath, false);
} else {
- logger->stdout(relPath);
+ logger->stdout_(relPath);
if (recursive) {
auto st = accessor->stat(curPath);
if (st.type == FSAccessor::Type::tDirectory)
diff --git a/src/nix/profile.cc b/src/nix/profile.cc
index 7dcc0b6d4..d42d16f7e 100644
--- a/src/nix/profile.cc
+++ b/src/nix/profile.cc
@@ -387,7 +387,7 @@ struct CmdProfileInfo : virtual EvalCommand, virtual StoreCommand, MixDefaultPro
for (size_t i = 0; i < manifest.elements.size(); ++i) {
auto & element(manifest.elements[i]);
- logger->stdout("%d %s %s %s", i,
+ logger->stdout_("%d %s %s %s", i,
element.source ? element.source->originalRef.to_string() + "#" + element.source->attrPath : "-",
element.source ? element.source->resolvedRef.to_string() + "#" + element.source->attrPath : "-",
concatStringsSep(" ", store->printStorePathSet(element.storePaths)));
diff --git a/src/nix/registry.cc b/src/nix/registry.cc
index ebee4545c..54ee9152b 100644
--- a/src/nix/registry.cc
+++ b/src/nix/registry.cc
@@ -26,7 +26,7 @@ struct CmdRegistryList : StoreCommand
for (auto & registry : registries) {
for (auto & entry : registry->entries) {
// FIXME: format nicely
- logger->stdout("%s %s %s",
+ logger->stdout_("%s %s %s",
registry->type == Registry::Flag ? "flags " :
registry->type == Registry::User ? "user " :
registry->type == Registry::System ? "system" :
diff --git a/src/nix/search.cc b/src/nix/search.cc
index 65a1e1818..f052cc699 100644
--- a/src/nix/search.cc
+++ b/src/nix/search.cc
@@ -147,13 +147,13 @@ struct CmdSearch : InstallableCommand, MixJSON
jsonElem.attr("description", description);
} else {
auto name2 = hilite(name.name, nameMatch, "\e[0;2m");
- if (results > 1) logger->stdout("");
- logger->stdout(
+ if (results > 1) logger->stdout_("");
+ logger->stdout_(
"* %s%s",
wrap("\e[0;1m", hilite(attrPath2, attrPathMatch, "\e[0;1m")),
name.version != "" ? " (" + name.version + ")" : "");
if (description != "")
- logger->stdout(
+ logger->stdout_(
" %s", hilite(description, descriptionMatch, ANSI_NORMAL));
}
}
diff --git a/src/nix/show-config.cc b/src/nix/show-config.cc
index 4fd8886de..a97dc42f9 100644
--- a/src/nix/show-config.cc
+++ b/src/nix/show-config.cc
@@ -25,7 +25,7 @@ struct CmdShowConfig : Command, MixJSON
std::map<std::string, Config::SettingInfo> settings;
globalConfig.getSettings(settings);
for (auto & s : settings)
- logger->stdout("%s = %s", s.first, s.second.value);
+ logger->stdout_("%s = %s", s.first, s.second.value);
}
}
};
diff --git a/src/nix/why-depends.cc b/src/nix/why-depends.cc
index 7e630b745..cbfc9b948 100644
--- a/src/nix/why-depends.cc
+++ b/src/nix/why-depends.cc
@@ -156,7 +156,7 @@ struct CmdWhyDepends : SourceExprCommand
auto pathS = store->printStorePath(node.path);
assert(node.dist != inf);
- logger->stdout("%s%s%s%s" ANSI_NORMAL,
+ logger->stdout_("%s%s%s%s" ANSI_NORMAL,
firstPad,
node.visited ? "\e[38;5;244m" : "",
firstPad != "" ? "→ " : "",