Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into path-info
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Oct 12, 2020
2 parents f8d562c + 20d2140 commit a0f369a
Show file tree
Hide file tree
Showing 127 changed files with 650 additions and 549 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ perl/Makefile.config
/aclocal.m4
/autom4te.cache
/precompiled-headers.h.gch
/precompiled-headers.h.pch
/config.*
/configure
/stamp-h1
Expand Down
3 changes: 1 addition & 2 deletions doc/manual/generate-manpage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ in

command:

"Title: nix\n\n"
+ showCommand { command = "nix"; section = "#"; def = command; }
showCommand { command = "nix"; section = "#"; def = command; }
17 changes: 13 additions & 4 deletions doc/manual/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ dist-files += $(man-pages)
nix-eval = $(bindir)/nix eval --experimental-features nix-command -I nix/corepkgs=corepkgs --store dummy:// --impure --raw --expr

$(d)/%.1: $(d)/src/command-ref/%.md
$(trace-gen) lowdown -sT man $^ -o $@
@printf "Title: %s\n\n" "$$(basename $@ .1)" > $^.tmp
@cat $^ >> $^.tmp
$(trace-gen) lowdown -sT man $^.tmp -o $@
@rm $^.tmp

$(d)/%.8: $(d)/src/command-ref/%.md
$(trace-gen) lowdown -sT man $^ -o $@
@printf "Title: %s\n\n" "$$(basename $@ .8)" > $^.tmp
@cat $^ >> $^.tmp
$(trace-gen) lowdown -sT man $^.tmp -o $@
@rm $^.tmp

$(d)/nix.conf.5: $(d)/src/command-ref/conf-file.md
$(trace-gen) lowdown -sT man $^ -o $@
@printf "Title: %s\n\n" "$$(basename $@ .5)" > $^.tmp
@cat $^ >> $^.tmp
$(trace-gen) lowdown -sT man $^.tmp -o $@
@rm $^.tmp

$(d)/src/command-ref/nix.md: $(d)/nix.json $(d)/generate-manpage.nix $(bindir)/nix
$(trace-gen) $(nix-eval) 'import doc/manual/generate-manpage.nix (builtins.fromJSON (builtins.readFile $<))' > $@.tmp
Expand All @@ -40,7 +49,7 @@ $(d)/nix.json: $(bindir)/nix
@mv $@.tmp $@

$(d)/conf-file.json: $(bindir)/nix
$(trace-gen) env -i NIX_CONF_DIR=/dummy HOME=/dummy $(bindir)/nix show-config --json --experimental-features nix-command > $@.tmp
$(trace-gen) env -i NIX_CONF_DIR=/dummy HOME=/dummy NIX_SSL_CERT_FILE=/dummy/no-ca-bundle.crt $(bindir)/nix show-config --json --experimental-features nix-command > $@.tmp
@mv $@.tmp $@

$(d)/src/expressions/builtins.md: $(d)/builtins.json $(d)/generate-builtins.nix $(d)/src/expressions/builtins-prefix.md $(bindir)/nix
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/conf-file-prefix.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix.conf

# Name

`nix.conf` - Nix configuration file
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-build.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-build

# Name

`nix-build` - build a Nix expression
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-channel.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-channel

# Name

`nix-channel` - manage Nix channels
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-collect-garbage.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-collect-garbage

# Name

`nix-collect-garbage` - delete unreachable store paths
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-copy-closure.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-copy-closure

# Name

`nix-copy-closure` - copy a closure to or from a remote machine via SSH
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-daemon.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-daemon

# Name

`nix-daemon` - Nix multi-user support daemon
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-env.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-env

# Name

`nix-env` - manipulate or query Nix user environments
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-hash.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-hash

# Name

`nix-hash` - compute the cryptographic hash of a path
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-instantiate.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-instantiate

# Name

`nix-instantiate` - instantiate store derivations from Nix expressions
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-prefetch-url.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-prefetch-url

# Name

`nix-prefetch-url` - copy a file from a URL into the store and print its hash
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-shell.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-shell

# Name

`nix-shell` - start an interactive shell based on a Nix expression
Expand Down
2 changes: 0 additions & 2 deletions doc/manual/src/command-ref/nix-store.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Title: nix-store

# Name

`nix-store` - manipulate or query the Nix store
Expand Down
2 changes: 1 addition & 1 deletion local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ GLOBAL_CXXFLAGS += -Wno-deprecated-declarations
$(foreach i, config.h $(wildcard src/lib*/*.hh), \
$(eval $(call install-file-in, $(i), $(includedir)/nix, 0644)))

$(GCH) $(PCH): src/libutil/util.hh config.h
$(GCH): src/libutil/util.hh config.h

GCH_CXXFLAGS = -I src/libutil
5 changes: 3 additions & 2 deletions misc/bash/completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ function _complete_nix {
_get_comp_words_by_ref -n ':=&' words cword cur
local have_type
while IFS= read -r line; do
local completion=${line%% *}
if [[ -z $have_type ]]; then
have_type=1
if [[ $line = filenames ]]; then
if [[ $completion = filenames ]]; then
compopt -o filenames
fi
else
COMPREPLY+=("$line")
COMPREPLY+=("$completion")
fi
done < <(NIX_GET_COMPLETIONS=$cword "${words[@]}")
__ltrim_colon_completions "$cur"
Expand Down
21 changes: 21 additions & 0 deletions misc/zsh/completion.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function _nix() {
local ifs_bk="$IFS"
local input=("${(Q)words[@]}")
IFS=$'\n'
local res=($(NIX_GET_COMPLETIONS=$((CURRENT - 1)) "$input[@]"))
IFS="$ifs_bk"
local tpe="${${res[1]}%%> *}"
local -a suggestions
declare -a suggestions
for suggestion in ${res:1}; do
# FIXME: This doesn't work properly if the suggestion word contains a `:`
# itself
suggestions+="${suggestion/ /:}"
done
if [[ "$tpe" == filenames ]]; then
compadd -f
fi
_describe 'nix' suggestions
}

compdef _nix nix
27 changes: 3 additions & 24 deletions mk/precompiled-headers.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,12 @@ $(GCH): precompiled-headers.h
@mkdir -p "$(dir $@)"
$(trace-gen) $(CXX) -x c++-header -o $@ $< $(GLOBAL_CXXFLAGS) $(GCH_CXXFLAGS)

PCH = $(buildprefix)precompiled-headers.h.pch

$(PCH): precompiled-headers.h
@rm -f $@
@mkdir -p "$(dir $@)"
$(trace-gen) $(CXX) -x c++-header -o $@ $< $(GLOBAL_CXXFLAGS) $(GCH_CXXFLAGS)

clean-files += $(GCH) $(PCH)
clean-files += $(GCH)

ifeq ($(PRECOMPILE_HEADERS), 1)

ifeq ($(findstring g++,$(CXX)), g++)

GLOBAL_CXXFLAGS_PCH += -include $(buildprefix)precompiled-headers.h -Winvalid-pch

GLOBAL_ORDER_AFTER += $(GCH)

else ifeq ($(findstring clang++,$(CXX)), clang++)

GLOBAL_CXXFLAGS_PCH += -include-pch $(PCH) -Winvalid-pch

GLOBAL_ORDER_AFTER += $(PCH)

else

$(error Don't know how to precompile headers on $(CXX))
GLOBAL_CXXFLAGS_PCH += -include $(buildprefix)precompiled-headers.h -Winvalid-pch

endif
GLOBAL_ORDER_AFTER += $(GCH)

endif
1 change: 1 addition & 0 deletions nix-rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(improper_ctypes_definitions)]
#[cfg(not(test))]
mod c;
mod error;
Expand Down
35 changes: 17 additions & 18 deletions nix-rust/src/store/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ impl StorePath {
}
Self::new_from_base_name(
path.file_name()
.ok_or(Error::BadStorePath(path.into()))?
.ok_or_else(|| Error::BadStorePath(path.into()))?
.to_str()
.ok_or(Error::BadStorePath(path.into()))?,
.ok_or_else(|| Error::BadStorePath(path.into()))?,
)
}

Expand All @@ -34,7 +34,7 @@ impl StorePath {

pub fn new_from_base_name(base_name: &str) -> Result<Self, Error> {
if base_name.len() < STORE_PATH_HASH_CHARS + 1
|| base_name.as_bytes()[STORE_PATH_HASH_CHARS] != '-' as u8
|| base_name.as_bytes()[STORE_PATH_HASH_CHARS] != b'-'
{
return Err(Error::BadStorePath(base_name.into()));
}
Expand Down Expand Up @@ -65,7 +65,7 @@ impl StorePathHash {
Ok(Self(bytes))
}

pub fn hash<'a>(&'a self) -> &'a [u8; STORE_PATH_HASH_BYTES] {
pub fn hash(&self) -> &[u8; STORE_PATH_HASH_BYTES] {
&self.0
}
}
Expand Down Expand Up @@ -98,33 +98,32 @@ pub struct StorePathName(String);

impl StorePathName {
pub fn new(s: &str) -> Result<Self, Error> {
if s.len() == 0 {
if s.is_empty() {
return Err(Error::StorePathNameEmpty);
}

if s.len() > 211 {
return Err(Error::StorePathNameTooLong);
}

if s.starts_with('.')
|| !s.chars().all(|c| {
c.is_ascii_alphabetic()
|| c.is_ascii_digit()
|| c == '+'
|| c == '-'
|| c == '.'
|| c == '_'
|| c == '?'
|| c == '='
})
{
let is_good_path_name = s.chars().all(|c| {
c.is_ascii_alphabetic()
|| c.is_ascii_digit()
|| c == '+'
|| c == '-'
|| c == '.'
|| c == '_'
|| c == '?'
|| c == '='
});
if s.starts_with('.') || !is_good_path_name {
return Err(Error::BadStorePathName);
}

Ok(Self(s.to_string()))
}

pub fn name<'a>(&'a self) -> &'a str {
pub fn name(&self) -> &str {
&self.0
}
}
Expand Down
2 changes: 1 addition & 1 deletion nix-rust/src/util/base32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn decoded_len(input_len: usize) -> usize {
input_len * 5 / 8
}

static BASE32_CHARS: &'static [u8; 32] = &b"0123456789abcdfghijklmnpqrsvwxyz";
static BASE32_CHARS: &[u8; 32] = &b"0123456789abcdfghijklmnpqrsvwxyz";

lazy_static! {
static ref BASE32_CHARS_REVERSE: Box<[u8; 256]> = {
Expand Down
4 changes: 2 additions & 2 deletions src/build-remote/build-remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static bool allSupportedLocally(Store & store, const std::set<std::string>& requ
return true;
}

static int _main(int argc, char * * argv)
static int main_build_remote(int argc, char * * argv)
{
{
logger = makeJSONLogger(*logger);
Expand Down Expand Up @@ -297,4 +297,4 @@ static int _main(int argc, char * * argv)
}
}

static RegisterLegacyCommand s1("build-remote", _main);
static RegisterLegacyCommand r_build_remote("build-remote", main_build_remote);
2 changes: 1 addition & 1 deletion src/libexpr/eval-cache.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace nix::eval_cache {

MakeError(CachedEvalError, EvalError);

class AttrDb;
struct AttrDb;
class AttrCursor;

class EvalCache : public std::enable_shared_from_this<EvalCache>
Expand Down
2 changes: 1 addition & 1 deletion src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@ Strings EvalSettings::getDefaultNixPath()

EvalSettings evalSettings;

static GlobalConfig::Register r1(&evalSettings);
static GlobalConfig::Register rEvalSettings(&evalSettings);


}
2 changes: 1 addition & 1 deletion src/libexpr/flake/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using namespace flake;

namespace flake {

typedef std::pair<Tree, FlakeRef> FetchedFlake;
typedef std::pair<fetchers::Tree, FlakeRef> FetchedFlake;
typedef std::vector<std::pair<FlakeRef, FetchedFlake>> FlakeCache;

static std::optional<FetchedFlake> lookupInFlakeCache(
Expand Down
4 changes: 2 additions & 2 deletions src/libexpr/flake/lockfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ FlakeRef getFlakeRef(
{
auto i = json.find(attr);
if (i != json.end()) {
auto attrs = jsonToAttrs(*i);
auto attrs = fetchers::jsonToAttrs(*i);
// FIXME: remove when we drop support for version 5.
if (info) {
auto j = json.find(info);
if (j != json.end()) {
for (auto k : jsonToAttrs(*j))
for (auto k : fetchers::jsonToAttrs(*j))
attrs.insert_or_assign(k.first, k.second);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/libexpr/flake/lockfile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class StorePath;

namespace nix::flake {

using namespace fetchers;

typedef std::vector<FlakeId> InputPath;

struct LockedNode;
Expand Down
2 changes: 2 additions & 0 deletions src/libexpr/primops.hh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include "eval.hh"

#include <tuple>
Expand Down
Loading

0 comments on commit a0f369a

Please sign in to comment.