Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into github-api-token
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Hale committed Sep 25, 2020
2 parents a303c0b + 7d81582 commit faa5607
Show file tree
Hide file tree
Showing 82 changed files with 971 additions and 745 deletions.
9 changes: 0 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ perl/Makefile.config
/svn-revision
/libtool

/corepkgs/config.nix

# /corepkgs/channels/
/corepkgs/channels/unpack.sh

# /corepkgs/nar/
/corepkgs/nar/nar.sh
/corepkgs/nar/unnar.sh

# /doc/manual/
/doc/manual/*.1
/doc/manual/*.5
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ OPTIMIZE = 1
ifeq ($(OPTIMIZE), 1)
GLOBAL_CXXFLAGS += -O3
else
GLOBAL_CXXFLAGS += -O0
GLOBAL_CXXFLAGS += -O0 -U_FORTIFY_SOURCE
endif

include mk/lib.mk
Expand Down
13 changes: 0 additions & 13 deletions corepkgs/config.nix.in

This file was deleted.

6 changes: 1 addition & 5 deletions corepkgs/local.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
corepkgs_FILES = \
unpack-channel.nix \
derivation.nix \
fetchurl.nix

$(foreach file,config.nix $(corepkgs_FILES),$(eval $(call install-data-in,$(d)/$(file),$(datadir)/nix/corepkgs)))

template-files += $(d)/config.nix
$(foreach file,$(corepkgs_FILES),$(eval $(call install-data-in,$(d)/$(file),$(datadir)/nix/corepkgs)))
3 changes: 3 additions & 0 deletions doc/manual/src/command-ref/nix-prefetch-url.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ Nix store is also printed.
result to the Nix store. The resulting hash can be used with
functions such as Nixpkgs’s `fetchzip` or `fetchFromGitHub`.

- `--executable`
Set the executable bit on the downloaded file.

- `--name` *name*
Override the name of the file in the Nix store. By default, this is
`hash-basename`, where *basename* is the last component of *url*.
Expand Down
11 changes: 5 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "The purely functional package manager";

inputs.nixpkgs.url = "nixpkgs/nixos-20.03-small";
inputs.lowdown-src = { url = "github:edolstra/lowdown/no-structs-in-anonymous-unions"; flake = false; };
inputs.lowdown-src = { url = "github:kristapsdz/lowdown"; flake = false; };

outputs = { self, nixpkgs, lowdown-src }:

Expand Down Expand Up @@ -58,6 +58,7 @@
configureFlags =
lib.optionals stdenv.isLinux [
"--with-sandbox-shell=${sh}/bin/busybox"
"LDFLAGS=-fuse-ld=gold"
];

buildDeps =
Expand Down Expand Up @@ -136,7 +137,7 @@

enableParallelBuilding = true;

makeFlags = "profiledir=$(out)/etc/profile.d";
makeFlags = "profiledir=$(out)/etc/profile.d PRECOMPILE_HEADERS=1";

doCheck = true;

Expand Down Expand Up @@ -334,9 +335,6 @@
# syntax-check generated dot files, it still requires some
# fonts. So provide those.
FONTCONFIG_FILE = texFunctions.fontsConf;

# To test building without precompiled headers.
makeFlagsArray = [ "PRECOMPILE_HEADERS=0" ];
};

# System tests.
Expand Down
2 changes: 2 additions & 0 deletions misc/launchd/org.nixos.nix-daemon.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>NIX_SSL_CERT_FILE</key>
<string>/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt</string>
<key>OBJC_DISABLE_INITIALIZE_FORK_SAFETY</key>
<string>YES</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion mk/precompiled-headers.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PRECOMPILE_HEADERS ?= 1
PRECOMPILE_HEADERS ?= 0

print-var-help += \
echo " PRECOMPILE_HEADERS ($(PRECOMPILE_HEADERS)): Whether to use precompiled headers to speed up the build";
Expand Down
13 changes: 0 additions & 13 deletions perl/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ PKG_CHECK_MODULES([NIX], [nix-store])

NEED_PROG([NIX], [nix])

# Get nix configure values
export NIX_REMOTE=daemon
nixbindir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixBinDir)
nixlibexecdir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixLibexecDir)
nixlocalstatedir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixLocalstateDir)
nixsysconfdir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixSysconfDir)
nixstoredir=$("$NIX" --experimental-features nix-command eval --raw -f '<nix/config.nix>' nixStoreDir)
AC_SUBST(nixbindir)
AC_SUBST(nixlibexecdir)
AC_SUBST(nixlocalstatedir)
AC_SUBST(nixsysconfdir)
AC_SUBST(nixstoredir)

# Expand all variables in config.status.
test "$prefix" = NONE && prefix=$ac_default_prefix
test "$exec_prefix" = NONE && exec_prefix='${prefix}'
Expand Down
10 changes: 2 additions & 8 deletions perl/lib/Nix/Config.pm.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ use MIME::Base64;

$version = "@PACKAGE_VERSION@";

$binDir = $ENV{"NIX_BIN_DIR"} || "@nixbindir@";
$libexecDir = $ENV{"NIX_LIBEXEC_DIR"} || "@nixlibexecdir@";
$stateDir = $ENV{"NIX_STATE_DIR"} || "@nixlocalstatedir@/nix";
$logDir = $ENV{"NIX_LOG_DIR"} || "@nixlocalstatedir@/log/nix";
$confDir = $ENV{"NIX_CONF_DIR"} || "@nixsysconfdir@/nix";
$storeDir = $ENV{"NIX_STORE_DIR"} || "@nixstoredir@";

$useBindings = 1;
$binDir = Nix::Store::getBinDir;
$storeDir = Nix::Store::getStoreDir;

%config = ();

Expand Down
60 changes: 3 additions & 57 deletions perl/lib/Nix/Store.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package Nix::Store;

use strict;
use warnings;
use Nix::Config;

require Exporter;

Expand All @@ -22,6 +21,7 @@ our @EXPORT = qw(
addToStore makeFixedOutputPath
derivationFromPath
addTempRoot
getBinDir getStoreDir
);

our $VERSION = '0.15';
Expand All @@ -34,62 +34,8 @@ sub backtick {
return $res;
}

if ($Nix::Config::useBindings) {
require XSLoader;
XSLoader::load('Nix::Store', $VERSION);
} else {

# Provide slow fallbacks of some functions on platforms that don't
# support the Perl bindings.

use File::Temp;
use Fcntl qw/F_SETFD/;

*hashFile = sub {
my ($algo, $base32, $path) = @_;
my $res = backtick("$Nix::Config::binDir/nix-hash", "--flat", $path, "--type", $algo, $base32 ? "--base32" : ());
chomp $res;
return $res;
};

*hashPath = sub {
my ($algo, $base32, $path) = @_;
my $res = backtick("$Nix::Config::binDir/nix-hash", $path, "--type", $algo, $base32 ? "--base32" : ());
chomp $res;
return $res;
};

*hashString = sub {
my ($algo, $base32, $s) = @_;
my $fh = File::Temp->new();
print $fh $s;
my $res = backtick("$Nix::Config::binDir/nix-hash", $fh->filename, "--type", $algo, $base32 ? "--base32" : ());
chomp $res;
return $res;
};

*addToStore = sub {
my ($srcPath, $recursive, $algo) = @_;
die "not implemented" if $recursive || $algo ne "sha256";
my $res = backtick("$Nix::Config::binDir/nix-store", "--add", $srcPath);
chomp $res;
return $res;
};

*isValidPath = sub {
my ($path) = @_;
my $res = backtick("$Nix::Config::binDir/nix-store", "--check-validity", "--print-invalid", $path);
chomp $res;
return $res ne $path;
};

*queryPathHash = sub {
my ($path) = @_;
my $res = backtick("$Nix::Config::binDir/nix-store", "--query", "--hash", $path);
chomp $res;
return $res;
};
}
require XSLoader;
XSLoader::load('Nix::Store', $VERSION);

1;
__END__
10 changes: 10 additions & 0 deletions perl/lib/Nix/Store.xs
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,13 @@ void addTempRoot(char * storePath)
} catch (Error & e) {
croak("%s", e.what());
}


SV * getBinDir()
PPCODE:
XPUSHs(sv_2mortal(newSVpv(settings.nixBinDir.c_str(), 0)));


SV * getStoreDir()
PPCODE:
XPUSHs(sv_2mortal(newSVpv(settings.nixStore.c_str(), 0)));
1 change: 1 addition & 0 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ EvalState::EvalState(const Strings & _searchPath, ref<Store> store)
, sEpsilon(symbols.create(""))
, repair(NoRepair)
, store(store)
, regexCache(makeRegexCache())
, baseEnv(allocEnv(128))
, staticBaseEnv(false, 0)
{
Expand Down
8 changes: 6 additions & 2 deletions src/libexpr/eval.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "symbol-table.hh"
#include "config.hh"

#include <regex>
#include <map>
#include <optional>
#include <unordered_map>
Expand Down Expand Up @@ -65,6 +64,11 @@ typedef std::list<SearchPathElem> SearchPath;
void initGC();


struct RegexCache;

std::shared_ptr<RegexCache> makeRegexCache();


class EvalState
{
public:
Expand Down Expand Up @@ -120,7 +124,7 @@ private:
std::unordered_map<Path, Path> resolvedPaths;

/* Cache used by prim_match(). */
std::unordered_map<std::string, std::regex> regexCache;
std::shared_ptr<RegexCache> regexCache;

public:

Expand Down
15 changes: 7 additions & 8 deletions src/libexpr/flake/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ static std::tuple<fetchers::Tree, FlakeRef, FlakeRef> fetchOrSubstituteTree(
resolvedRef = originalRef.resolve(state.store);
auto fetchedResolved = lookupInFlakeCache(flakeCache, originalRef);
if (!fetchedResolved) fetchedResolved.emplace(resolvedRef.fetchTree(state.store));
flakeCache.push_back({resolvedRef, fetchedResolved.value()});
fetched.emplace(fetchedResolved.value());
flakeCache.push_back({resolvedRef, *fetchedResolved});
fetched.emplace(*fetchedResolved);
}
else {
throw Error("'%s' is an indirect flake reference, but registry lookups are not allowed", originalRef);
}
}
flakeCache.push_back({originalRef, fetched.value()});
flakeCache.push_back({originalRef, *fetched});
}

auto [tree, lockedRef] = fetched.value();
auto [tree, lockedRef] = *fetched;

debug("got tree '%s' from '%s'",
state.store->printStorePath(tree.storePath), lockedRef);
Expand Down Expand Up @@ -215,10 +215,9 @@ static Flake getFlake(

if (auto outputs = vInfo.attrs->get(sOutputs)) {
expectType(state, tLambda, *outputs->value, *outputs->pos);
flake.vOutputs = allocRootValue(outputs->value);

if ((*flake.vOutputs)->lambda.fun->matchAttrs) {
for (auto & formal : (*flake.vOutputs)->lambda.fun->formals->formals) {
if (outputs->value->lambda.fun->matchAttrs) {
for (auto & formal : outputs->value->lambda.fun->formals->formals) {
if (formal.name != state.sSelf)
flake.inputs.emplace(formal.name, FlakeInput {
.ref = parseFlakeRef(formal.name)
Expand Down Expand Up @@ -367,7 +366,7 @@ LockedFlake lockFlake(

/* If we have an --update-input flag for an input
of this input, then we must fetch the flake to
to update it. */
update it. */
auto lb = lockFlags.inputUpdates.lower_bound(inputPath);

auto hasChildUpdate =
Expand Down
1 change: 0 additions & 1 deletion src/libexpr/flake/flake.hh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct Flake
std::optional<std::string> description;
std::shared_ptr<const fetchers::Tree> sourceInfo;
FlakeInputs inputs;
RootValue vOutputs;
~Flake();
};

Expand Down
1 change: 1 addition & 0 deletions src/libexpr/flake/flakeref.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "flakeref.hh"
#include "store-api.hh"
#include "url.hh"
#include "url-parts.hh"
#include "fetchers.hh"
#include "registry.hh"

Expand Down
1 change: 1 addition & 0 deletions src/libexpr/flake/lockfile.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "lockfile.hh"
#include "store-api.hh"
#include "url-parts.hh"

#include <nlohmann/json.hpp>

Expand Down
8 changes: 8 additions & 0 deletions src/libexpr/json-to-value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ class JSONSax : nlohmann::json_sax<json> {
{
return handle_value<void(Value&, const char*)>(mkString, val.c_str());
}
#if NLOHMANN_JSON_VERSION_MAJOR >= 3 && NLOHMANN_JSON_VERSION_MINOR >= 8
bool binary(binary_t&)
{
// This function ought to be unreachable
assert(false);
return true;
}
#endif

bool start_object(std::size_t len)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ $(eval $(call install-file-in, $(d)/nix-expr.pc, $(prefix)/lib/pkgconfig, 0644))
$(foreach i, $(wildcard src/libexpr/flake/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix/flake, 0644)))

$(d)/primops.cc: $(d)/imported-drv-to-derivation.nix.gen.hh
$(d)/primops.cc: $(d)/imported-drv-to-derivation.nix.gen.hh $(d)/primops/derivation.nix.gen.hh

$(d)/flake/flake.cc: $(d)/flake/call-flake.nix.gen.hh
Loading

0 comments on commit faa5607

Please sign in to comment.