Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d4be6c9d14af
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f46adb783c93
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on May 17, 2021

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    rnhmjoj Michele Guerini Rocco
    Copy the full SHA
    f46adb7 View commit details
Showing with 37 additions and 16 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 tests/ca/config.nix.in
  3. +20 −14 tests/ca/content-addressed.nix
  4. +3 −0 tests/ca/flake.nix
  5. +9 −0 tests/ca/nix-run.sh
  6. +3 −2 tests/local.mk
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ perl/Makefile.config
/tests/shell
/tests/shell.drv
/tests/config.nix
/tests/ca/config.nix

# /tests/lang/
/tests/lang/*.out
1 change: 1 addition & 0 deletions tests/ca/config.nix.in
34 changes: 20 additions & 14 deletions tests/ca/content-addressed.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
with import ../config.nix;
with import ./config.nix;

let mkCADerivation = args: mkDerivation ({
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
} // args);
in

{ seed ? 0 }:
# A simple content-addressed derivation.
@@ -14,7 +21,7 @@ rec {
echo "Hello World" > $out/hello
'';
};
rootCA = mkDerivation {
rootCA = mkCADerivation {
name = "rootCA";
outputs = [ "out" "dev" "foo"];
buildCommand = ''
@@ -27,32 +34,23 @@ rec {
ln -s $out $dev
ln -s $out $foo
'';
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
};
dependentCA = mkDerivation {
dependentCA = mkCADerivation {
name = "dependent";
buildCommand = ''
echo "building a dependent derivation"
mkdir -p $out
cat ${rootCA}/self/dep
echo ${rootCA}/self/dep > $out/dep
'';
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
};
transitivelyDependentCA = mkDerivation {
transitivelyDependentCA = mkCADerivation {
name = "transitively-dependent";
buildCommand = ''
echo "building transitively-dependent"
cat ${dependentCA}/dep
echo ${dependentCA} > $out
'';
__contentAddressed = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
};
dependentNonCA = mkDerivation {
name = "dependent-non-ca";
@@ -72,6 +70,14 @@ rec {
cat ${dependentCA}/dep
echo foo > $out
'';

};
runnable = mkCADerivation rec {
name = "runnable-thing";
buildCommand = ''
mkdir -p $out/bin
echo ${rootCA} # Just to make it depend on it
echo "" > $out/bin/${name}
chmod +x $out/bin/${name}
'';
};
}
3 changes: 3 additions & 0 deletions tests/ca/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
outputs = { self }: import ./content-addressed.nix {};
}
9 changes: 9 additions & 0 deletions tests/ca/nix-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

source common.sh

sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf

FLAKE_PATH=path:$PWD

nix run --no-write-lock-file $FLAKE_PATH#runnable
5 changes: 3 additions & 2 deletions tests/local.mk
Original file line number Diff line number Diff line change
@@ -46,13 +46,14 @@ nix_tests = \
ca/build.sh \
ca/substitute.sh \
ca/signatures.sh \
ca/nix-run.sh \
ca/nix-copy.sh
# parallel.sh

install-tests += $(foreach x, $(nix_tests), tests/$(x))

tests-environment = NIX_REMOTE= $(bash) -e

clean-files += $(d)/common.sh $(d)/config.nix
clean-files += $(d)/common.sh $(d)/config.nix $(d)/ca/config.nix

test-deps += tests/common.sh tests/config.nix tests/plugins/libplugintest.$(SO_EXT)
test-deps += tests/common.sh tests/config.nix tests/ca/config.nix tests/plugins/libplugintest.$(SO_EXT)