Skip to content

Commit

Permalink
Showing 15 changed files with 125 additions and 66 deletions.
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -179,6 +179,10 @@ AC_CHECK_HEADERS([bzlib.h], [true],
[AC_MSG_ERROR([Nix requires libbz2, which is part of bzip2. See https://web.archive.org/web/20180624184756/http://www.bzip.org/.])])
# Checks for libarchive
PKG_CHECK_MODULES([LIBARCHIVE], [libarchive >= 3.1.2], [CXXFLAGS="$LIBARCHIVE_CFLAGS $CXXFLAGS"])
# Workaround until https://github.com/libarchive/libarchive/issues/1446 is fixed
if test "$shared" != yes; then
LIBARCHIVE_LIBS+=' -lz'
fi

# Look for SQLite, a required dependency.
PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.6.19], [CXXFLAGS="$SQLITE3_CFLAGS $CXXFLAGS"])
119 changes: 86 additions & 33 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -16,7 +16,8 @@

officialRelease = false;

systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ];
linuxSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
systems = linuxSystems ++ [ "x86_64-darwin" ];

forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);

@@ -61,34 +62,41 @@
"LDFLAGS=-fuse-ld=gold"
];

buildDeps =
[ bison
flex
mdbook
lowdown
autoconf-archive
autoreconfHook

curl
nativeBuildDeps =
[
buildPackages.bison
buildPackages.flex
(lib.getBin buildPackages.lowdown)
buildPackages.mdbook
buildPackages.autoconf-archive
buildPackages.autoreconfHook
buildPackages.pkgconfig

# Tests
buildPackages.git
buildPackages.mercurial
buildPackages.jq
];

buildDeps =
[ curl
bzip2 xz brotli zlib editline
openssl pkgconfig sqlite
openssl sqlite
libarchive
boost
nlohmann_json

# Tests
git
mercurial
jq
lowdown
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; })
@@ -115,7 +123,8 @@

outputs = [ "out" "dev" "doc" ];

buildInputs = buildDeps;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ awsDeps;

propagatedBuildInputs = propagatedDeps;

@@ -159,14 +168,17 @@

src = self;

nativeBuildInputs =
[ buildPackages.autoconf-archive
buildPackages.autoreconfHook
buildPackages.pkgconfig
];

buildInputs =
[ autoconf-archive
autoreconfHook
nix
[ nix
curl
bzip2
xz
pkgconfig
pkgs.perl
boost
nlohmann_json
@@ -197,15 +209,15 @@

src = lowdown-src;

outputs = [ "out" "dev" ];
outputs = [ "out" "bin" "dev" ];

buildInputs = [ which ];
nativeBuildInputs = [ which ];

configurePhase =
''
./configure \
PREFIX=${placeholder "dev"} \
BINDIR=${placeholder "out"}/bin
BINDIR=${placeholder "bin"}/bin
'';
};

@@ -214,10 +226,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);

buildStatic = nixpkgs.lib.genAttrs linuxSystems (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
@@ -323,7 +337,8 @@

enableParallelBuilding = true;

buildInputs = buildDeps ++ propagatedDeps;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps ++ awsDeps;

dontInstall = false;

@@ -425,10 +440,47 @@
checks = forAllSystems (system: {
binaryTarball = self.hydraJobs.binaryTarball.${system};
perlBindings = self.hydraJobs.perlBindings.${system};
} // nixpkgs.lib.optionalAttrs (builtins.elem system linuxSystems) {
buildStatic = self.hydraJobs.buildStatic.${system};
});

packages = forAllSystems (system: {
inherit (nixpkgsFor.${system}) nix;
} // nixpkgs.lib.optionalAttrs (builtins.elem system linuxSystems) {
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);
@@ -442,7 +494,8 @@

outputs = [ "out" "dev" "doc" ];

buildInputs = buildDeps ++ propagatedDeps ++ perlDeps;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps ++ awsDeps ++ perlDeps;

inherit configureFlags;

2 changes: 1 addition & 1 deletion src/libutil/logging.hh
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ public:
virtual void writeToStdout(std::string_view s);

template<typename... Args>
inline void stdout(const std::string & fs, const Args & ... args)
inline void cout(const std::string & fs, const Args & ... args)
{
boost::format f(fs);
formatHelper(f, args...);
1 change: 1 addition & 0 deletions src/libutil/tests/tests.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "util.hh"
#include "types.hh"

#include <limits.h>
#include <gtest/gtest.h>

namespace nix {
1 change: 1 addition & 0 deletions src/libutil/types.hh
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@

#include <list>
#include <set>
#include <string>
#include <map>
#include <vector>

2 changes: 1 addition & 1 deletion src/nix/add-to-store.cc
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
store->addToStore(info, source);
}

logger->stdout("%s", store->printStorePath(info.path));
logger->cout("%s", store->printStorePath(info.path));
}
};

2 changes: 1 addition & 1 deletion src/nix/eval.cc
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ struct CmdEval : MixJSON, InstallableCommand
printValueAsJSON(*state, true, *v, jsonOut, context);
} else {
state->forceValueDeep(*v);
logger->stdout("%s", *v);
logger->cout("%s", *v);
}
}
};
36 changes: 18 additions & 18 deletions src/nix/flake.cc
Original file line number Diff line number Diff line change
@@ -62,17 +62,17 @@ class FlakeCommand : virtual Args, public MixFlakeOptions

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->cout("Resolved URL: %s", flake.resolvedRef.to_string());
logger->cout("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->cout("Description: %s", *flake.description);
logger->cout("Path: %s", store.printStorePath(flake.sourceInfo->storePath));
if (auto rev = flake.lockedRef.input.getRev())
logger->stdout("Revision: %s", rev->to_string(Base16, false));
logger->cout("Revision: %s", rev->to_string(Base16, false));
if (auto revCount = flake.lockedRef.input.getRevCount())
logger->stdout("Revisions: %s", *revCount);
logger->cout("Revisions: %s", *revCount);
if (auto lastModified = flake.lockedRef.input.getLastModified())
logger->stdout("Last modified: %s",
logger->cout("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->cout("%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->cout("%s", flake.lockFile.toJson());
else {
logger->stdout("%s", flake.flake.lockedRef);
logger->cout("%s", flake.flake.lockedRef);

std::unordered_set<std::shared_ptr<Node>> visited;

@@ -172,15 +172,15 @@ 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->cout("%s" ANSI_BOLD "%s" ANSI_NORMAL ": %s",
prefix + (last ? treeLast : treeConn), input.first,
*lockedNode ? (*lockedNode)->lockedRef : flake.flake.lockedRef);

bool firstVisit = visited.insert(*lockedNode).second;

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->cout("%s" ANSI_BOLD "%s" ANSI_NORMAL " follows input '%s'",
prefix + (last ? treeLast : treeConn), input.first,
printInputPath(*follows));
}
@@ -811,7 +811,7 @@ struct CmdFlakeShow : FlakeCommand
try {
auto recurse = [&]()
{
logger->stdout("%s", headerPrefix);
logger->cout("%s", headerPrefix);
auto attrs = visitor.getAttrs();
for (const auto & [i, attr] : enumerate(attrs)) {
bool last = i + 1 == attrs.size();
@@ -837,7 +837,7 @@ struct CmdFlakeShow : FlakeCommand
}
*/

logger->stdout("%s: %s '%s'",
logger->cout("%s: %s '%s'",
headerPrefix,
attrPath.size() == 2 && attrPath[0] == "devShell" ? "development environment" :
attrPath.size() == 3 && attrPath[0] == "checks" ? "derivation" :
@@ -885,7 +885,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->cout("%s: " ANSI_YELLOW "omitted" ANSI_NORMAL " (use '--legacy' to show)", headerPrefix);
else {
if (visitor.isDerivation())
showDerivation();
@@ -902,19 +902,19 @@ 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->cout("%s: app", headerPrefix);
}

else if (
(attrPath.size() == 1 && attrPath[0] == "defaultTemplate") ||
(attrPath.size() == 2 && attrPath[0] == "templates"))
{
auto description = visitor.getAttr("description")->getString();
logger->stdout("%s: template: " ANSI_BOLD "%s" ANSI_NORMAL, headerPrefix, description);
logger->cout("%s: template: " ANSI_BOLD "%s" ANSI_NORMAL, headerPrefix, description);
}

else {
logger->stdout("%s: %s",
logger->cout("%s: %s",
headerPrefix,
attrPath.size() == 1 && attrPath[0] == "overlay" ? "Nixpkgs overlay" :
attrPath.size() == 2 && attrPath[0] == "nixosConfigurations" ? "NixOS configuration" :
4 changes: 2 additions & 2 deletions src/nix/hash.cc
Original file line number Diff line number Diff line change
@@ -74,7 +74,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->cout(h.to_string(base, base == SRI));
}
}
};
@@ -108,7 +108,7 @@ struct CmdToBase : Command
void run() override
{
for (auto s : args)
logger->stdout(Hash::parseAny(s, ht).to_string(base, base == SRI));
logger->cout(Hash::parseAny(s, ht).to_string(base, base == SRI));
}
};

Loading

0 comments on commit e6247a5

Please sign in to comment.