Skip to content

Commit

Permalink
Merge remote-tracking branch 'obsidian/store-path-or-ca' into ca-drv-…
Browse files Browse the repository at this point in the history
…exotic
  • Loading branch information
Ericson2314 committed Oct 12, 2020
2 parents 8bac07b + 6547357 commit 2c3be0b
Show file tree
Hide file tree
Showing 154 changed files with 1,361 additions and 980 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v10
with:
skip_adding_nixpkgs_channel: true
- uses: cachix/install-nix-action@v11
#- run: nix flake check
- run: nix-build -A checks.$(if [[ `uname` = Linux ]]; then echo x86_64-linux; else echo x86_64-darwin; fi)
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ for more details.

## Installation

On Linux and macOS the easiest way to Install Nix is to run the following shell command
On Linux and macOS the easiest way to install Nix is to run the following shell command
(as a user other than root):

```console
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; }
7 changes: 6 additions & 1 deletion doc/manual/generate-options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ concatStrings (map
then "*empty*"
else if isBool option.value
then (if option.value then "`true`" else "`false`")
else "`" + toString option.value + "`") + "\n\n"
else
# n.b. a StringMap value type is specified as a string, but
# this shows the value type. The empty stringmap is "null" in
# JSON, but that converts to "{ }" here.
(if isAttrs option.value then "`\"\"`"
else "`" + toString option.value + "`")) + "\n\n"
+ (if option.aliases != []
then " **Deprecated alias:** " + (concatStringsSep ", " (map (s: "`${s}`") option.aliases)) + "\n\n"
else "")
Expand Down
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
16 changes: 11 additions & 5 deletions doc/manual/src/hacking.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ To build Nix itself in this shell:

```console
[nix-shell]$ ./bootstrap.sh
[nix-shell]$ ./configure $configureFlags --prefix=$(pwd)/inst
[nix-shell]$ ./configure $configureFlags --prefix=$(pwd)/outputs/out
[nix-shell]$ make -j $NIX_BUILD_CORES
```

To install it in `$(pwd)/inst` and test it:
To install it in `$(pwd)/outputs` and test it:

```console
[nix-shell]$ make install
[nix-shell]$ make installcheck
[nix-shell]$ ./inst/bin/nix --version
nix (Nix) 2.4
[nix-shell]$ make installcheck -j $NIX_BUILD_CORES
[nix-shell]$ ./outputs/out/bin/nix --version
nix (Nix) 3.0
```

To run a functional test:
Expand All @@ -58,6 +58,12 @@ To run a functional test:
make tests/test-name-should-auto-complete.sh.test
```

To run the unit-tests for C++ code:

```
make check
```

If you have a flakes-enabled Nix you can replace:

```console
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
configureFlags =
lib.optionals stdenv.isLinux [
"--with-sandbox-shell=${sh}/bin/busybox"
"LDFLAGS=-fuse-ld=gold"
];

buildDeps =
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
2 changes: 2 additions & 0 deletions scripts/install-nix-from-closure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

umask 0022

dest="/nix"
self="$(dirname "$0")"
nix="@nix@"
Expand Down
2 changes: 2 additions & 0 deletions scripts/install.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ oops() {
exit 1
}

umask 0022

tmpDir="$(mktemp -d -t nix-binary-tarball-unpack.XXXXXXXXXX || \
oops "Can't create temporary directory for downloading the Nix binary tarball")"
cleanup() {
Expand Down
Loading

0 comments on commit 2c3be0b

Please sign in to comment.