uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
7
pkgs/test/cc-wrapper/cc-main.c
Normal file
7
pkgs/test/cc-wrapper/cc-main.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
fprintf(stderr, "ok\n");
|
||||
return 0;
|
||||
}
|
||||
10
pkgs/test/cc-wrapper/cflags-main.c
Normal file
10
pkgs/test/cc-wrapper/cflags-main.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <stdio.h>
|
||||
#include <foo.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (foo() != 42)
|
||||
return 1;
|
||||
fprintf(stderr, "ok\n");
|
||||
return 0;
|
||||
}
|
||||
7
pkgs/test/cc-wrapper/core-foundation-main.c
Normal file
7
pkgs/test/cc-wrapper/core-foundation-main.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CFShow(CFSTR("ok"));
|
||||
return 0;
|
||||
}
|
||||
7
pkgs/test/cc-wrapper/cxx-main.cc
Normal file
7
pkgs/test/cc-wrapper/cxx-main.cc
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <iostream>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::cerr << "ok" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
80
pkgs/test/cc-wrapper/default.nix
Normal file
80
pkgs/test/cc-wrapper/default.nix
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{ lib, stdenv, glibc }:
|
||||
|
||||
let
|
||||
# Sanitizers are not supported on Darwin.
|
||||
# Sanitizer headers aren't available in older libc++ stdenvs due to a bug
|
||||
sanitizersWorking = !stdenv.hostPlatform.isMusl && (
|
||||
(stdenv.cc.isClang && lib.versionAtLeast (lib.getVersion stdenv.cc.name) "5.0.0")
|
||||
|| (stdenv.cc.isGNU && stdenv.isLinux)
|
||||
);
|
||||
staticLibc = lib.optionalString (stdenv.hostPlatform.libc == "glibc") "-L ${glibc.static}/lib";
|
||||
in stdenv.mkDerivation {
|
||||
name = "cc-wrapper-test";
|
||||
|
||||
buildCommand = ''
|
||||
NIX_DEBUG=1 $CC -v
|
||||
NIX_DEBUG=1 $CXX -v
|
||||
|
||||
printf "checking whether compiler builds valid C binaries... " >&2
|
||||
$CC -o cc-check ${./cc-main.c}
|
||||
./cc-check
|
||||
|
||||
printf "checking whether compiler builds valid C++ binaries... " >&2
|
||||
$CXX -o cxx-check ${./cxx-main.cc}
|
||||
./cxx-check
|
||||
|
||||
${lib.optionalString (stdenv.isDarwin && stdenv.cc.isClang) ''
|
||||
printf "checking whether compiler can build with CoreFoundation.framework... " >&2
|
||||
mkdir -p foo/lib
|
||||
$CC -framework CoreFoundation -o core-foundation-check ${./core-foundation-main.c}
|
||||
./core-foundation-check
|
||||
''}
|
||||
|
||||
|
||||
${lib.optionalString (!stdenv.isDarwin) ''
|
||||
printf "checking whether compiler builds valid static C binaries... " >&2
|
||||
$CC ${staticLibc} -static -o cc-static ${./cc-main.c}
|
||||
./cc-static
|
||||
${lib.optionalString (stdenv.cc.isGNU && lib.versionAtLeast (lib.getVersion stdenv.cc.name) "8.0.0") ''
|
||||
printf "checking whether compiler builds valid static pie C binaries... " >&2
|
||||
$CC ${staticLibc} -static-pie -o cc-static-pie ${./cc-main.c}
|
||||
./cc-static-pie
|
||||
''}
|
||||
''}
|
||||
|
||||
printf "checking whether compiler uses NIX_CFLAGS_COMPILE... " >&2
|
||||
mkdir -p foo/include
|
||||
cp ${./foo.c} foo/include/foo.h
|
||||
NIX_CFLAGS_COMPILE="-Ifoo/include -DVALUE=42" $CC -o cflags-check ${./cflags-main.c}
|
||||
./cflags-check
|
||||
|
||||
printf "checking whether compiler uses NIX_LDFLAGS... " >&2
|
||||
mkdir -p foo/lib
|
||||
$CC -shared \
|
||||
${lib.optionalString stdenv.isDarwin "-Wl,-install_name,@rpath/libfoo.dylib"} \
|
||||
-DVALUE=42 \
|
||||
-o foo/lib/libfoo${stdenv.hostPlatform.extensions.sharedLibrary} \
|
||||
${./foo.c}
|
||||
|
||||
NIX_LDFLAGS="-L$NIX_BUILD_TOP/foo/lib -rpath $NIX_BUILD_TOP/foo/lib" $CC -lfoo -o ldflags-check ${./ldflags-main.c}
|
||||
./ldflags-check
|
||||
|
||||
printf "Check whether -nostdinc and -nostdinc++ is handled correctly" >&2
|
||||
mkdir -p std-include
|
||||
cp ${./stdio.h} std-include/stdio.h
|
||||
NIX_DEBUG=1 $CC -I std-include -nostdinc -o nostdinc-main ${./nostdinc-main.c}
|
||||
./nostdinc-main
|
||||
$CXX -I std-include -nostdinc++ -o nostdinc-main++ ${./nostdinc-main.c}
|
||||
./nostdinc-main++
|
||||
|
||||
${lib.optionalString sanitizersWorking ''
|
||||
printf "checking whether sanitizers are fully functional... ">&2
|
||||
$CC -o sanitizers -fsanitize=address,undefined ${./sanitizers.c}
|
||||
./sanitizers
|
||||
''}
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
meta.platforms = lib.platforms.all;
|
||||
}
|
||||
4
pkgs/test/cc-wrapper/foo.c
Normal file
4
pkgs/test/cc-wrapper/foo.c
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
unsigned int foo(void)
|
||||
{
|
||||
return VALUE;
|
||||
}
|
||||
12
pkgs/test/cc-wrapper/ldflags-main.c
Normal file
12
pkgs/test/cc-wrapper/ldflags-main.c
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
extern unsigned int foo(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (foo() != 42) {
|
||||
return 1;
|
||||
}
|
||||
fprintf(stderr, "ok\n");
|
||||
return 0;
|
||||
}
|
||||
37
pkgs/test/cc-wrapper/multilib.nix
Normal file
37
pkgs/test/cc-wrapper/multilib.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{ lib, stdenv }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "cc-multilib-test";
|
||||
|
||||
# XXX: "depend" on cc-wrapper test?
|
||||
|
||||
# TODO: Have tests report pointer size or something; ensure they are what we asked for
|
||||
buildCommand = ''
|
||||
NIX_DEBUG=1 $CC -v
|
||||
NIX_DEBUG=1 $CXX -v
|
||||
|
||||
printf "checking whether compiler builds valid C binaries... " >&2
|
||||
$CC -o cc-check ${./cc-main.c}
|
||||
./cc-check
|
||||
|
||||
printf "checking whether compiler builds valid 32bit C binaries... " >&2
|
||||
$CC -m32 -o c32-check ${./cc-main.c}
|
||||
./c32-check
|
||||
|
||||
printf "checking whether compiler builds valid 64bit C binaries... " >&2
|
||||
$CC -m64 -o c64-check ${./cc-main.c}
|
||||
./c64-check
|
||||
|
||||
printf "checking whether compiler builds valid 32bit C++ binaries... " >&2
|
||||
$CXX -m32 -o cxx32-check ${./cxx-main.cc}
|
||||
./cxx32-check
|
||||
|
||||
printf "checking whether compiler builds valid 64bit C++ binaries... " >&2
|
||||
$CXX -m64 -o cxx64-check ${./cxx-main.cc}
|
||||
./cxx64-check
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
meta.platforms = lib.platforms.x86_64;
|
||||
}
|
||||
8
pkgs/test/cc-wrapper/nostdinc-main.c
Normal file
8
pkgs/test/cc-wrapper/nostdinc-main.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// This one should not come from libc because of -nostdinc
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// provided by our own stdio.h
|
||||
foo();
|
||||
return 0;
|
||||
}
|
||||
8
pkgs/test/cc-wrapper/sanitizers.c
Normal file
8
pkgs/test/cc-wrapper/sanitizers.c
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#include <sanitizer/asan_interface.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
fprintf(stderr, "ok\n");
|
||||
return 0;
|
||||
}
|
||||
1
pkgs/test/cc-wrapper/stdio.h
Normal file
1
pkgs/test/cc-wrapper/stdio.h
Normal file
|
|
@ -0,0 +1 @@
|
|||
static void foo(void) {}
|
||||
24
pkgs/test/config.nix
Normal file
24
pkgs/test/config.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{ lib, ... }:
|
||||
lib.recurseIntoAttrs {
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/issues/175196
|
||||
allowPkgsInPermittedInsecurePackages =
|
||||
let pkgs = import ../.. {
|
||||
config = {
|
||||
permittedInsecurePackages =
|
||||
tempAllow pkgs.authy "2.1.0" [ "electron-9.4.4" ];
|
||||
};
|
||||
};
|
||||
# A simplification of `tempAllow` that doesn't check the version, but
|
||||
# has the same strictness characteristics. Actually checking a version
|
||||
# here would add undue maintenance.
|
||||
#
|
||||
# Original:
|
||||
# tempAllow = p: v: pa:
|
||||
# lib.optionals (lib.assertMsg (p.version == v) "${p.name} is no longer at version ${v}, consider removing the tempAllow") pa;
|
||||
#
|
||||
tempAllow = p: v: pa: builtins.seq v builtins.seq p.version pa;
|
||||
|
||||
in pkgs.hello;
|
||||
|
||||
}
|
||||
113
pkgs/test/cross/default.nix
Normal file
113
pkgs/test/cross/default.nix
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
{ pkgs, lib }:
|
||||
|
||||
let
|
||||
|
||||
testedSystems = lib.filterAttrs (name: value: let
|
||||
platform = lib.systems.elaborate value;
|
||||
in platform.isLinux || platform.isWindows
|
||||
) lib.systems.examples;
|
||||
|
||||
getExecutable = pkgs: pkgFun: exec:
|
||||
"${pkgFun pkgs}${exec}${pkgs.hostPlatform.extensions.executable}";
|
||||
|
||||
compareTest = { emulator, pkgFun, hostPkgs, crossPkgs, exec, args ? [] }: let
|
||||
pkgName = (pkgFun hostPkgs).name;
|
||||
args' = lib.concatStringsSep " " args;
|
||||
in crossPkgs.runCommand "test-${pkgName}-${crossPkgs.hostPlatform.config}" {
|
||||
nativeBuildInputs = [ pkgs.dos2unix ];
|
||||
} ''
|
||||
# Just in case we are using wine, get rid of that annoying extra
|
||||
# stuff.
|
||||
export WINEDEBUG=-all
|
||||
|
||||
HOME=$(pwd)
|
||||
mkdir -p $out
|
||||
|
||||
# We need to remove whitespace, unfortunately
|
||||
# Windows programs use \r but Unix programs use \n
|
||||
|
||||
echo Running native-built program natively
|
||||
|
||||
# find expected value natively
|
||||
${getExecutable hostPkgs pkgFun exec} ${args'} \
|
||||
| dos2unix > $out/expected
|
||||
|
||||
echo Running cross-built program in emulator
|
||||
|
||||
# run emulator to get actual value
|
||||
${emulator} ${getExecutable crossPkgs pkgFun exec} ${args'} \
|
||||
| dos2unix > $out/actual
|
||||
|
||||
echo Comparing results...
|
||||
|
||||
if [ "$(cat $out/actual)" != "$(cat $out/expected)" ]; then
|
||||
echo "${pkgName} did not output expected value:"
|
||||
cat $out/expected
|
||||
echo "instead it output:"
|
||||
cat $out/actual
|
||||
exit 1
|
||||
else
|
||||
echo "${pkgName} test passed"
|
||||
echo "both produced output:"
|
||||
cat $out/actual
|
||||
fi
|
||||
'';
|
||||
|
||||
mapMultiPlatformTest = crossSystemFun: test: lib.mapAttrs (name: system: test rec {
|
||||
crossPkgs = import pkgs.path {
|
||||
localSystem = { inherit (pkgs.hostPlatform) config; };
|
||||
crossSystem = crossSystemFun system;
|
||||
};
|
||||
|
||||
emulator = crossPkgs.hostPlatform.emulator pkgs;
|
||||
|
||||
# Apply some transformation on windows to get dlls in the right
|
||||
# place. Unfortunately mingw doesn’t seem to be able to do linking
|
||||
# properly.
|
||||
platformFun = pkg: if crossPkgs.hostPlatform.isWindows then
|
||||
pkgs.buildEnv {
|
||||
name = "${pkg.name}-winlinks";
|
||||
paths = [pkg] ++ pkg.buildInputs;
|
||||
} else pkg;
|
||||
}) testedSystems;
|
||||
|
||||
tests = {
|
||||
|
||||
file = {platformFun, crossPkgs, emulator}: compareTest {
|
||||
inherit emulator crossPkgs;
|
||||
hostPkgs = pkgs;
|
||||
exec = "/bin/file";
|
||||
args = [
|
||||
"${pkgs.file}/share/man/man1/file.1.gz"
|
||||
"${pkgs.dejavu_fonts}/share/fonts/truetype/DejaVuMathTeXGyre.ttf"
|
||||
];
|
||||
pkgFun = pkgs: platformFun pkgs.file;
|
||||
};
|
||||
|
||||
hello = {platformFun, crossPkgs, emulator}: compareTest {
|
||||
inherit emulator crossPkgs;
|
||||
hostPkgs = pkgs;
|
||||
exec = "/bin/hello";
|
||||
pkgFun = pkgs: pkgs.hello;
|
||||
};
|
||||
|
||||
pkg-config = {platformFun, crossPkgs, emulator}: crossPkgs.runCommand
|
||||
"test-pkg-config-${crossPkgs.hostPlatform.config}"
|
||||
{
|
||||
depsBuildBuild = [ crossPkgs.pkgsBuildBuild.pkg-config ];
|
||||
nativeBuildInputs = [ crossPkgs.pkgsBuildHost.pkg-config crossPkgs.buildPackages.zlib ];
|
||||
depsBuildTarget = [ crossPkgs.pkgsBuildTarget.pkg-config ];
|
||||
buildInputs = [ crossPkgs.zlib ];
|
||||
NIX_DEBUG = 7;
|
||||
} ''
|
||||
mkdir $out
|
||||
${crossPkgs.pkgsBuildBuild.pkg-config.targetPrefix}pkg-config --cflags zlib > "$out/for-build"
|
||||
${crossPkgs.pkgsBuildHost.pkg-config.targetPrefix}pkg-config --cflags zlib > "$out/for-host"
|
||||
! diff "$out/for-build" "$out/for-host"
|
||||
'';
|
||||
};
|
||||
|
||||
in {
|
||||
gcc = (lib.mapAttrs (_: mapMultiPlatformTest (system: system // {useLLVM = false;})) tests);
|
||||
llvm = (lib.mapAttrs (_: mapMultiPlatformTest (system: system // {useLLVM = true;})) tests);
|
||||
}
|
||||
3
pkgs/test/cuda/cuda-library-samples/extension.nix
Normal file
3
pkgs/test/cuda/cuda-library-samples/extension.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
final: prev: {
|
||||
cuda-library-samples = final.callPackage ./generic.nix { };
|
||||
}
|
||||
69
pkgs/test/cuda/cuda-library-samples/generic.nix
Normal file
69
pkgs/test/cuda/cuda-library-samples/generic.nix
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
{ lib, stdenv, fetchFromGitHub
|
||||
, cmake, addOpenGLRunpath
|
||||
, cudatoolkit
|
||||
, cutensor
|
||||
}:
|
||||
|
||||
let
|
||||
rev = "5aab680905d853bce0dbad4c488e4f7e9f7b2302";
|
||||
src = fetchFromGitHub {
|
||||
owner = "NVIDIA";
|
||||
repo = "CUDALibrarySamples";
|
||||
inherit rev;
|
||||
sha256 = "0gwgbkq05ygrfgg5hk07lmap7n7ampxv0ha1axrv8qb748ph81xs";
|
||||
};
|
||||
commonAttrs = {
|
||||
version = lib.strings.substring 0 7 rev + "-" + lib.versions.majorMinor cudatoolkit.version;
|
||||
nativeBuildInputs = [ cmake addOpenGLRunpath ];
|
||||
buildInputs = [ cudatoolkit ];
|
||||
postFixup = ''
|
||||
for exe in $out/bin/*; do
|
||||
addOpenGLRunpath $exe
|
||||
done
|
||||
'';
|
||||
meta = {
|
||||
description = "examples of using libraries using CUDA";
|
||||
longDescription = ''
|
||||
CUDA Library Samples contains examples demonstrating the use of
|
||||
features in the math and image processing libraries cuBLAS, cuTENSOR,
|
||||
cuSPARSE, cuSOLVER, cuFFT, cuRAND, NPP and nvJPEG.
|
||||
'';
|
||||
license = lib.licenses.bsd3;
|
||||
maintainers = with lib.maintainers; [ obsidian-systems-maintenance ];
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
{
|
||||
cublas = stdenv.mkDerivation (commonAttrs // {
|
||||
pname = "cuda-library-samples-cublas";
|
||||
|
||||
src = "${src}/cuBLASLt";
|
||||
});
|
||||
|
||||
cusolver = stdenv.mkDerivation (commonAttrs // {
|
||||
pname = "cuda-library-samples-cusolver";
|
||||
|
||||
src = "${src}/cuSOLVER";
|
||||
|
||||
sourceRoot = "cuSOLVER/gesv";
|
||||
});
|
||||
|
||||
cutensor = stdenv.mkDerivation (commonAttrs // {
|
||||
pname = "cuda-library-samples-cutensor";
|
||||
|
||||
src = "${src}/cuTENSOR";
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${builtins.placeholder "out"}/bin"
|
||||
];
|
||||
|
||||
# CUTENSOR_ROOT is double escaped
|
||||
postPatch = ''
|
||||
substituteInPlace CMakeLists.txt \
|
||||
--replace "\''${CUTENSOR_ROOT}/include" "${cutensor.dev}/include"
|
||||
'';
|
||||
|
||||
CUTENSOR_ROOT = cutensor;
|
||||
});
|
||||
}
|
||||
20
pkgs/test/cuda/cuda-samples/extension.nix
Normal file
20
pkgs/test/cuda/cuda-samples/extension.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
final: prev: let
|
||||
|
||||
sha256 = {
|
||||
"10.0" = "1zvh4xsdyc59m87brpcmssxsjlp9dkynh4asnkcmc3g94f53l0jw";
|
||||
"10.1" = "1s8ka0hznrni36ajhzf2gqpdrl8kd8fi047qijxks5l2abc093qd";
|
||||
"10.2" = "01p1innzgh9siacpld6nsqimj8jkg93rk4gj8q4crn62pa5vhd94";
|
||||
"11.0" = "1n3vjc8c7zdig2xgl5fppavrphqzhdiv9m9nk6smh4f99fwi0705";
|
||||
"11.1" = "1kjixk50i8y1bkiwbdn5lkv342crvkmbvy1xl5j3lsa1ica21kwh";
|
||||
"11.2" = "1p1qjvfbm28l933mmnln02rqrf0cy9kbpsyb488d1haiqzvrazl1";
|
||||
"11.3" = "0kbibb6pgz8j5iq6284axcnmycaha9bw8qlmdp6yfwmnahq1v0yz";
|
||||
"11.4" = "082dkk5y34wyvjgj2p5j1d00rk8xaxb9z0mhvz16bd469r1bw2qk";
|
||||
"11.5" = "sha256-AKRZbke0K59lakhTi8dX2cR2aBuWPZkiQxyKaZTvHrI=";
|
||||
"11.6" = "sha256-AsLNmAplfuQbXg9zt09tXAuFJ524EtTYsQuUlV1tPkE=";
|
||||
}.${prev.cudaVersion};
|
||||
|
||||
in {
|
||||
cuda-samples = final.callPackage ./generic.nix {
|
||||
inherit sha256;
|
||||
};
|
||||
}
|
||||
60
pkgs/test/cuda/cuda-samples/generic.nix
Normal file
60
pkgs/test/cuda/cuda-samples/generic.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, addOpenGLRunpath
|
||||
, cudatoolkit
|
||||
, pkg-config
|
||||
, sha256
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "cuda-samples";
|
||||
version = lib.versions.majorMinor cudatoolkit.version;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "NVIDIA";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ pkg-config addOpenGLRunpath ];
|
||||
|
||||
buildInputs = [ cudatoolkit ];
|
||||
|
||||
# See https://github.com/NVIDIA/cuda-samples/issues/75.
|
||||
patches = lib.optionals (version == "11.3") [
|
||||
(fetchpatch {
|
||||
url = "https://github.com/NVIDIA/cuda-samples/commit/5c3ec60faeb7a3c4ad9372c99114d7bb922fda8d.patch";
|
||||
sha256 = "sha256-0XxdmNK9MPpHwv8+qECJTvXGlFxc+fIbta4ynYprfpU=";
|
||||
})
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
preConfigure = ''
|
||||
export CUDA_PATH=${cudatoolkit}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm755 -t $out/bin bin/${stdenv.hostPlatform.parsed.cpu.name}/${stdenv.hostPlatform.parsed.kernel.name}/release/*
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
for exe in $out/bin/*; do
|
||||
addOpenGLRunpath $exe
|
||||
done
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Samples for CUDA Developers which demonstrates features in CUDA Toolkit";
|
||||
# CUDA itself is proprietary, but these sample apps are not.
|
||||
license = lib.licenses.bsd3;
|
||||
maintainers = with lib.maintainers; [ obsidian-systems-maintenance ];
|
||||
};
|
||||
}
|
||||
28
pkgs/test/cuda/default.nix
Normal file
28
pkgs/test/cuda/default.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{ callPackage }:
|
||||
|
||||
rec {
|
||||
cuda-samplesPackages = callPackage ./cuda-samples { };
|
||||
inherit (cuda-samplesPackages)
|
||||
cuda-samples_cudatoolkit_10
|
||||
cuda-samples_cudatoolkit_10_0
|
||||
cuda-samples_cudatoolkit_10_1
|
||||
cuda-samples_cudatoolkit_10_2
|
||||
cuda-samples_cudatoolkit_11
|
||||
cuda-samples_cudatoolkit_11_0
|
||||
cuda-samples_cudatoolkit_11_1
|
||||
cuda-samples_cudatoolkit_11_2
|
||||
cuda-samples_cudatoolkit_11_3
|
||||
cuda-samples_cudatoolkit_11_4;
|
||||
|
||||
cuda-library-samplesPackages = callPackage ./cuda-library-samples { };
|
||||
inherit (cuda-library-samplesPackages)
|
||||
cuda-library-samples_cudatoolkit_10
|
||||
cuda-library-samples_cudatoolkit_10_1
|
||||
cuda-library-samples_cudatoolkit_10_2
|
||||
cuda-library-samples_cudatoolkit_11
|
||||
cuda-library-samples_cudatoolkit_11_0
|
||||
cuda-library-samples_cudatoolkit_11_1
|
||||
cuda-library-samples_cudatoolkit_11_2
|
||||
cuda-library-samples_cudatoolkit_11_3
|
||||
cuda-library-samples_cudatoolkit_11_4;
|
||||
}
|
||||
88
pkgs/test/default.nix
Normal file
88
pkgs/test/default.nix
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
{ pkgs, callPackage }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
{
|
||||
cc-wrapper = callPackage ./cc-wrapper { };
|
||||
cc-wrapper-gcc = callPackage ./cc-wrapper { stdenv = gccStdenv; };
|
||||
cc-wrapper-gcc7 = callPackage ./cc-wrapper { stdenv = gcc7Stdenv; };
|
||||
cc-wrapper-gcc8 = callPackage ./cc-wrapper { stdenv = gcc8Stdenv; };
|
||||
cc-wrapper-gcc9 = callPackage ./cc-wrapper { stdenv = gcc9Stdenv; };
|
||||
cc-wrapper-clang = callPackage ./cc-wrapper { stdenv = llvmPackages.stdenv; };
|
||||
cc-wrapper-libcxx = callPackage ./cc-wrapper { stdenv = llvmPackages.libcxxStdenv; };
|
||||
cc-wrapper-clang-5 = callPackage ./cc-wrapper { stdenv = llvmPackages_5.stdenv; };
|
||||
cc-wrapper-libcxx-5 = callPackage ./cc-wrapper { stdenv = llvmPackages_5.libcxxStdenv; };
|
||||
cc-wrapper-clang-6 = callPackage ./cc-wrapper { stdenv = llvmPackages_6.stdenv; };
|
||||
cc-wrapper-libcxx-6 = callPackage ./cc-wrapper { stdenv = llvmPackages_6.libcxxStdenv; };
|
||||
cc-wrapper-clang-7 = callPackage ./cc-wrapper { stdenv = llvmPackages_7.stdenv; };
|
||||
cc-wrapper-libcxx-7 = callPackage ./cc-wrapper { stdenv = llvmPackages_7.libcxxStdenv; };
|
||||
cc-wrapper-clang-8 = callPackage ./cc-wrapper { stdenv = llvmPackages_8.stdenv; };
|
||||
cc-wrapper-libcxx-8 = callPackage ./cc-wrapper { stdenv = llvmPackages_8.libcxxStdenv; };
|
||||
cc-wrapper-clang-9 = callPackage ./cc-wrapper { stdenv = llvmPackages_9.stdenv; };
|
||||
cc-wrapper-libcxx-9 = callPackage ./cc-wrapper { stdenv = llvmPackages_9.libcxxStdenv; };
|
||||
stdenv-inputs = callPackage ./stdenv-inputs { };
|
||||
|
||||
config = callPackage ./config.nix { };
|
||||
|
||||
haskell = callPackage ./haskell { };
|
||||
|
||||
cc-multilib-gcc = callPackage ./cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; };
|
||||
cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
|
||||
|
||||
fetchpatch = callPackages ../build-support/fetchpatch/tests.nix { };
|
||||
fetchzip = callPackages ../build-support/fetchzip/tests.nix { };
|
||||
fetchgit = callPackages ../build-support/fetchgit/tests.nix { };
|
||||
fetchFirefoxAddon = callPackages ../build-support/fetchfirefoxaddon/tests.nix { };
|
||||
|
||||
install-shell-files = callPackage ./install-shell-files {};
|
||||
|
||||
kernel-config = callPackage ./kernel.nix {};
|
||||
|
||||
ld-library-path = callPackage ./ld-library-path {};
|
||||
|
||||
macOSSierraShared = callPackage ./macos-sierra-shared {};
|
||||
|
||||
cross = callPackage ./cross {};
|
||||
|
||||
php = recurseIntoAttrs (callPackages ./php {});
|
||||
|
||||
rustCustomSysroot = callPackage ./rust-sysroot {};
|
||||
buildRustCrate = callPackage ../build-support/rust/build-rust-crate/test { };
|
||||
importCargoLock = callPackage ../build-support/rust/test/import-cargo-lock { };
|
||||
|
||||
vim = callPackage ./vim {};
|
||||
|
||||
nixos-functions = callPackage ./nixos-functions {};
|
||||
|
||||
patch-shebangs = callPackage ./patch-shebangs {};
|
||||
|
||||
texlive = callPackage ./texlive {};
|
||||
|
||||
cuda = callPackage ./cuda { };
|
||||
|
||||
trivial-builders = recurseIntoAttrs {
|
||||
writeStringReferencesToFile = callPackage ../build-support/trivial-builders/test/writeStringReferencesToFile.nix {};
|
||||
writeTextFile = callPackage ../build-support/trivial-builders/test/write-text-file.nix {};
|
||||
references = callPackage ../build-support/trivial-builders/test/references.nix {};
|
||||
overriding = callPackage ../build-support/trivial-builders/test-overriding.nix {};
|
||||
concat = callPackage ../build-support/trivial-builders/test/concat-test.nix {};
|
||||
};
|
||||
|
||||
writers = callPackage ../build-support/writers/test.nix {};
|
||||
|
||||
testers = callPackage ../build-support/testers/test/default.nix {};
|
||||
|
||||
dhall = callPackage ./dhall { };
|
||||
|
||||
makeWrapper = callPackage ./make-wrapper { };
|
||||
makeBinaryWrapper = callPackage ./make-binary-wrapper {
|
||||
makeBinaryWrapper = pkgs.makeBinaryWrapper.override {
|
||||
# Enable sanitizers in the tests only, to avoid the performance cost in regular usage.
|
||||
# The sanitizers cause errors on aarch64-darwin, see https://github.com/NixOS/nixpkgs/pull/150079#issuecomment-994132734
|
||||
sanitizers = pkgs.lib.optionals (! (pkgs.stdenv.isDarwin && pkgs.stdenv.isAarch64))
|
||||
[ "undefined" "address" ];
|
||||
};
|
||||
};
|
||||
|
||||
pkgs-lib = recurseIntoAttrs (import ../pkgs-lib/tests { inherit pkgs; });
|
||||
}
|
||||
14
pkgs/test/dhall/buildDhallUrl/default.nix
Normal file
14
pkgs/test/dhall/buildDhallUrl/default.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{ dhallPackages, lib }:
|
||||
|
||||
# This file tests that dhallPackages.buildDhallUrl is able to successfully
|
||||
# build a Nix Dhall package for a given remote Dhall import.
|
||||
#
|
||||
# TODO: It would be nice to extend this test to make sure that the resulting
|
||||
# Nix Dhall package is has the expected contents.
|
||||
|
||||
dhallPackages.buildDhallUrl {
|
||||
url = "https://raw.githubusercontent.com/cdepillabout/example-dhall-nix/e6a675c72ecd4dd23d254a02aea8181fe875747f/mydhallfile.dhall";
|
||||
hash = "sha256-434x+QjHRzuprBdw0h6wmwB1Zj6yZqQb533me8XdO4c=";
|
||||
dhallHash = "sha256-434x+QjHRzuprBdw0h6wmwB1Zj6yZqQb533me8XdO4c=";
|
||||
source = true;
|
||||
}
|
||||
6
pkgs/test/dhall/default.nix
Normal file
6
pkgs/test/dhall/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{ lib, callPackage }:
|
||||
|
||||
lib.recurseIntoAttrs {
|
||||
buildDhallUrl = callPackage ./buildDhallUrl { };
|
||||
generateDhallDirectoryPackage = callPackage ./generateDhallDirectoryPackage { };
|
||||
}
|
||||
17
pkgs/test/dhall/generateDhallDirectoryPackage/default.nix
Normal file
17
pkgs/test/dhall/generateDhallDirectoryPackage/default.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ dhallPackages, fetchFromGitHub }:
|
||||
|
||||
# This file tests that dhallPackages.generateDhallDirectoryPackage works.
|
||||
#
|
||||
# TODO: It would be nice to extend this test to make sure that the resulting
|
||||
# Nix file has the expected contents, but it might be tough to do that easily
|
||||
# without IFD.
|
||||
|
||||
dhallPackages.generateDhallDirectoryPackage {
|
||||
src = fetchFromGitHub {
|
||||
owner = "cdepillabout";
|
||||
repo = "example-dhall-nix";
|
||||
rev = "e6a675c72ecd4dd23d254a02aea8181fe875747f";
|
||||
sha256 = "sha256-c/EZq76s/+hmLkaeJWKqgh2KrHuJRYI6kWry0E0YQ6s=";
|
||||
};
|
||||
file = "mydhallfile.dhall";
|
||||
}
|
||||
8
pkgs/test/haskell/default.nix
Normal file
8
pkgs/test/haskell/default.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{ lib, callPackage }:
|
||||
|
||||
lib.recurseIntoAttrs {
|
||||
shellFor = callPackage ./shellFor { };
|
||||
documentationTarball = callPackage ./documentationTarball { };
|
||||
setBuildTarget = callPackage ./setBuildTarget { };
|
||||
writers = callPackage ./writers { };
|
||||
}
|
||||
21
pkgs/test/haskell/documentationTarball/default.nix
Normal file
21
pkgs/test/haskell/documentationTarball/default.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{ pkgs, haskellPackages }:
|
||||
|
||||
let
|
||||
drv = haskellPackages.vector;
|
||||
docs = pkgs.haskell.lib.compose.documentationTarball drv;
|
||||
|
||||
in pkgs.runCommand "test haskell.lib.compose.documentationTarball" {
|
||||
meta = {
|
||||
inherit (docs.meta) platforms;
|
||||
};
|
||||
} ''
|
||||
tar xvzf "${docs}/${drv.name}-docs.tar.gz"
|
||||
|
||||
# Check for Haddock html
|
||||
find "${drv.name}-docs" | grep -q "Data-Vector.html"
|
||||
|
||||
# Check for source html
|
||||
find "${drv.name}-docs" | grep -q "src/Data.Vector.html"
|
||||
|
||||
touch "$out"
|
||||
''
|
||||
4
pkgs/test/haskell/setBuildTarget/Bar.hs
Normal file
4
pkgs/test/haskell/setBuildTarget/Bar.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
module Main where
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Hello, Bar!"
|
||||
4
pkgs/test/haskell/setBuildTarget/Foo.hs
Normal file
4
pkgs/test/haskell/setBuildTarget/Foo.hs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
module Main where
|
||||
|
||||
main :: IO ()
|
||||
main = putStrLn "Hello, Foo!"
|
||||
2
pkgs/test/haskell/setBuildTarget/Setup.hs
Normal file
2
pkgs/test/haskell/setBuildTarget/Setup.hs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
43
pkgs/test/haskell/setBuildTarget/default.nix
Normal file
43
pkgs/test/haskell/setBuildTarget/default.nix
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{ pkgs, haskellPackages }:
|
||||
|
||||
let
|
||||
# This can be regenerated by running `cabal2nix .` in the current directory.
|
||||
pkgDef =
|
||||
{ mkDerivation, base, lib }:
|
||||
mkDerivation {
|
||||
pname = "haskell-setBuildTarget";
|
||||
version = "0.1.0.0";
|
||||
src = ./.;
|
||||
isLibrary = false;
|
||||
isExecutable = true;
|
||||
executableHaskellDepends = [ base ];
|
||||
license = lib.licenses.bsd3;
|
||||
};
|
||||
|
||||
drv = haskellPackages.callPackage pkgDef {};
|
||||
|
||||
test = target: excluded:
|
||||
let only = pkgs.haskell.lib.compose.setBuildTarget target drv;
|
||||
in ''
|
||||
if [[ ! -f "${only}/bin/${target}" ]]; then
|
||||
echo "${target} was not built"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f "${only}/bin/${excluded}" ]]; then
|
||||
echo "${excluded} was built, when it should not have been"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
|
||||
in
|
||||
pkgs.runCommand "test haskell.lib.compose.setBuildTarget" {
|
||||
meta = {
|
||||
inherit (drv.meta) platforms;
|
||||
};
|
||||
} ''
|
||||
${test "foo" "bar"}
|
||||
${test "bar" "foo"}
|
||||
touch "$out"
|
||||
''
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
cabal-version: >=1.10
|
||||
name: haskell-setBuildTarget
|
||||
version: 0.1.0.0
|
||||
author: Isaac Shapira
|
||||
maintainer: fresheyeball@protonmail.com
|
||||
build-type: Simple
|
||||
|
||||
executable foo
|
||||
main-is: Foo.hs
|
||||
build-depends: base
|
||||
default-language: Haskell2010
|
||||
|
||||
executable bar
|
||||
main-is: Bar.hs
|
||||
build-depends: base
|
||||
default-language: Haskell2010
|
||||
47
pkgs/test/haskell/shellFor/default.nix
Normal file
47
pkgs/test/haskell/shellFor/default.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{ lib, writeText, haskellPackages, cabal-install }:
|
||||
|
||||
(haskellPackages.shellFor {
|
||||
packages = p: [ p.constraints p.linear ];
|
||||
extraDependencies = p: { libraryHaskellDepends = [ p.releaser ]; };
|
||||
nativeBuildInputs = [ cabal-install ];
|
||||
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
|
||||
unpackPhase = ''
|
||||
sourceRoot=$(pwd)/scratch
|
||||
mkdir -p "$sourceRoot"
|
||||
cd "$sourceRoot"
|
||||
tar -xf ${haskellPackages.constraints.src}
|
||||
tar -xf ${haskellPackages.linear.src}
|
||||
cp ${writeText "cabal.project" "packages: constraints* linear*"} cabal.project
|
||||
'';
|
||||
buildPhase = ''
|
||||
export HOME=$(mktemp -d)
|
||||
mkdir -p $HOME/.cabal
|
||||
touch $HOME/.cabal/config
|
||||
|
||||
# Check extraDependencies.libraryHaskellDepends arg
|
||||
ghci <<EOF
|
||||
:m + Releaser.Primitives
|
||||
:m + System.IO
|
||||
writeFile "done" "done"
|
||||
EOF
|
||||
[[ done == $(cat done) ]]
|
||||
|
||||
# Check packages arg
|
||||
cabal v2-build --offline --verbose constraints linear --ghc-options="-O0 -j$NIX_BUILD_CORES"
|
||||
'';
|
||||
installPhase = ''
|
||||
touch $out
|
||||
'';
|
||||
}).overrideAttrs (oldAttrs: {
|
||||
meta =
|
||||
let
|
||||
oldMeta = oldAttrs.meta or {};
|
||||
oldMaintainers = oldMeta.maintainers or [];
|
||||
additionalMaintainers = with lib.maintainers; [ cdepillabout ];
|
||||
allMaintainers = oldMaintainers ++ additionalMaintainers;
|
||||
in
|
||||
oldMeta // {
|
||||
maintainers = allMaintainers;
|
||||
inherit (cabal-install.meta) platforms;
|
||||
};
|
||||
})
|
||||
26
pkgs/test/haskell/writers/default.nix
Normal file
26
pkgs/test/haskell/writers/default.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Wrap only the haskell-related tests from tests.writers
|
||||
# in their own derivation for Hydra CI in the haskell-updates
|
||||
# jobset. Can presumably removed as soon as tests.writers is
|
||||
# always green on darwin as well:
|
||||
# https://github.com/NixOS/nixpkgs/issues/126182
|
||||
{ runCommand, tests }:
|
||||
|
||||
let
|
||||
inherit (tests.writers)
|
||||
writeTest
|
||||
bin
|
||||
simple
|
||||
path
|
||||
;
|
||||
in
|
||||
|
||||
runCommand "test-haskell-writers" {
|
||||
meta = {
|
||||
inherit (tests.writers.meta) platforms;
|
||||
};
|
||||
} ''
|
||||
${writeTest "success" "test-haskell-bin-writer" "${bin.haskell}/bin/${bin.haskell.name}"}
|
||||
${writeTest "success" "test-haskell-simple-writer" simple.haskell}
|
||||
${writeTest "success" "test-haskell-path-writer" path.haskell}
|
||||
touch $out
|
||||
''
|
||||
125
pkgs/test/install-shell-files/default.nix
Normal file
125
pkgs/test/install-shell-files/default.nix
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
{ lib, runCommandLocal, recurseIntoAttrs, installShellFiles }:
|
||||
|
||||
let
|
||||
runTest = name: env: buildCommand:
|
||||
runCommandLocal "install-shell-files--${name}" ({
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
meta.platforms = lib.platforms.all;
|
||||
} // env) buildCommand;
|
||||
in
|
||||
|
||||
recurseIntoAttrs {
|
||||
# installManPage
|
||||
|
||||
install-manpage = runTest "install-manpage" {} ''
|
||||
mkdir -p doc
|
||||
echo foo > doc/foo.1
|
||||
echo bar > doc/bar.2.gz
|
||||
echo baz > doc/baz.3
|
||||
|
||||
installManPage doc/*
|
||||
|
||||
cmp doc/foo.1 $out/share/man/man1/foo.1
|
||||
cmp doc/bar.2.gz $out/share/man/man2/bar.2.gz
|
||||
cmp doc/baz.3 $out/share/man/man3/baz.3
|
||||
'';
|
||||
install-manpage-outputs = runTest "install-manpage-outputs" {
|
||||
outputs = [ "out" "man" "devman" ];
|
||||
} ''
|
||||
mkdir -p doc
|
||||
echo foo > doc/foo.1
|
||||
echo bar > doc/bar.3
|
||||
|
||||
installManPage doc/*
|
||||
|
||||
# assert they didn't go into $out
|
||||
[[ ! -f $out/share/man/man1/foo.1 && ! -f $out/share/man/man3/bar.3 ]]
|
||||
|
||||
# foo.1 alone went into man
|
||||
cmp doc/foo.1 ''${!outputMan:?}/share/man/man1/foo.1
|
||||
[[ ! -f ''${!outputMan:?}/share/man/man3/bar.3 ]]
|
||||
|
||||
# bar.3 alone went into devman
|
||||
cmp doc/bar.3 ''${!outputDevman:?}/share/man/man3/bar.3
|
||||
[[ ! -f ''${!outputDevman:?}/share/man/man1/foo.1 ]]
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
# installShellCompletion
|
||||
|
||||
install-completion = runTest "install-completion" {} ''
|
||||
echo foo > foo
|
||||
echo bar > bar
|
||||
echo baz > baz
|
||||
echo qux > qux.zsh
|
||||
echo quux > quux
|
||||
|
||||
installShellCompletion --bash foo bar --zsh baz qux.zsh --fish quux
|
||||
|
||||
cmp foo $out/share/bash-completion/completions/foo
|
||||
cmp bar $out/share/bash-completion/completions/bar
|
||||
cmp baz $out/share/zsh/site-functions/_baz
|
||||
cmp qux.zsh $out/share/zsh/site-functions/_qux
|
||||
cmp quux $out/share/fish/vendor_completions.d/quux
|
||||
'';
|
||||
install-completion-output = runTest "install-completion-output" {
|
||||
outputs = [ "out" "bin" ];
|
||||
} ''
|
||||
echo foo > foo
|
||||
|
||||
installShellCompletion --bash foo
|
||||
|
||||
# assert it didn't go into $out
|
||||
[[ ! -f $out/share/bash-completion/completions/foo ]]
|
||||
|
||||
cmp foo ''${!outputBin:?}/share/bash-completion/completions/foo
|
||||
|
||||
touch $out
|
||||
'';
|
||||
install-completion-name = runTest "install-completion-name" {} ''
|
||||
echo foo > foo
|
||||
echo bar > bar
|
||||
echo baz > baz
|
||||
|
||||
installShellCompletion --bash --name foobar.bash foo --zsh --name _foobar bar --fish baz
|
||||
|
||||
cmp foo $out/share/bash-completion/completions/foobar.bash
|
||||
cmp bar $out/share/zsh/site-functions/_foobar
|
||||
cmp baz $out/share/fish/vendor_completions.d/baz
|
||||
'';
|
||||
install-completion-inference = runTest "install-completion-inference" {} ''
|
||||
echo foo > foo.bash
|
||||
echo bar > bar.zsh
|
||||
echo baz > baz.fish
|
||||
|
||||
installShellCompletion foo.bash bar.zsh baz.fish
|
||||
|
||||
cmp foo.bash $out/share/bash-completion/completions/foo.bash
|
||||
cmp bar.zsh $out/share/zsh/site-functions/_bar
|
||||
cmp baz.fish $out/share/fish/vendor_completions.d/baz.fish
|
||||
'';
|
||||
install-completion-cmd = runTest "install-completion-cmd" {} ''
|
||||
echo foo > foo.bash
|
||||
echo bar > bar.zsh
|
||||
echo baz > baz.fish
|
||||
echo qux > qux.fish
|
||||
|
||||
installShellCompletion --cmd foobar --bash foo.bash --zsh bar.zsh --fish baz.fish --name qux qux.fish
|
||||
|
||||
cmp foo.bash $out/share/bash-completion/completions/foobar.bash
|
||||
cmp bar.zsh $out/share/zsh/site-functions/_foobar
|
||||
cmp baz.fish $out/share/fish/vendor_completions.d/foobar.fish
|
||||
cmp qux.fish $out/share/fish/vendor_completions.d/qux
|
||||
'';
|
||||
install-completion-fifo = runTest "install-completion-fifo" {} ''
|
||||
installShellCompletion \
|
||||
--bash --name foo.bash <(echo foo) \
|
||||
--zsh --name _foo <(echo bar) \
|
||||
--fish --name foo.fish <(echo baz)
|
||||
|
||||
[[ $(<$out/share/bash-completion/completions/foo.bash) == foo ]] || { echo "foo.bash comparison failed"; exit 1; }
|
||||
[[ $(<$out/share/zsh/site-functions/_foo) == bar ]] || { echo "_foo comparison failed"; exit 1; }
|
||||
[[ $(<$out/share/fish/vendor_completions.d/foo.fish) == baz ]] || { echo "foo.fish comparison failed"; exit 1; }
|
||||
'';
|
||||
}
|
||||
79
pkgs/test/kernel.nix
Normal file
79
pkgs/test/kernel.nix
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# to run these tests:
|
||||
# nix-instantiate --eval --strict . -A tests.kernel-config
|
||||
#
|
||||
# make sure to use NON EXISTING kernel settings else they may conflict with
|
||||
# common-config.nix
|
||||
{ lib, pkgs }:
|
||||
|
||||
with lib;
|
||||
with kernel;
|
||||
|
||||
let
|
||||
lts_kernel = pkgs.linuxPackages.kernel;
|
||||
|
||||
# to see the result once the module transformed the lose structured config
|
||||
getConfig = structuredConfig:
|
||||
(lts_kernel.override {
|
||||
structuredExtraConfig = structuredConfig;
|
||||
}).configfile.structuredConfig;
|
||||
|
||||
mandatoryVsOptionalConfig = mkMerge [
|
||||
{ NIXOS_FAKE_USB_DEBUG = yes;}
|
||||
{ NIXOS_FAKE_USB_DEBUG = option yes; }
|
||||
];
|
||||
|
||||
freeformConfig = mkMerge [
|
||||
{ NIXOS_FAKE_MMC_BLOCK_MINORS = freeform "32"; } # same as default, won't trigger any error
|
||||
{ NIXOS_FAKE_MMC_BLOCK_MINORS = freeform "64"; } # will trigger an error but the message is not great:
|
||||
];
|
||||
|
||||
yesWinsOverNoConfig = mkMerge [
|
||||
# default for "NIXOS_TEST_BOOLEAN" is no
|
||||
{ "NIXOS_TEST_BOOLEAN" = yes; } # yes wins over no by default
|
||||
{ "NIXOS_TEST_BOOLEAN" = no; }
|
||||
];
|
||||
|
||||
optionalNoWins = mkMerge [
|
||||
{ NIXOS_FAKE_USB_DEBUG = option yes;}
|
||||
{ NIXOS_FAKE_USB_DEBUG = yes;}
|
||||
];
|
||||
|
||||
allOptionalRemainOptional = mkMerge [
|
||||
{ NIXOS_FAKE_USB_DEBUG = option yes;}
|
||||
{ NIXOS_FAKE_USB_DEBUG = option yes;}
|
||||
];
|
||||
|
||||
in
|
||||
runTests {
|
||||
testEasy = {
|
||||
expr = (getConfig { NIXOS_FAKE_USB_DEBUG = yes;}).NIXOS_FAKE_USB_DEBUG;
|
||||
expected = { tristate = "y"; optional = false; freeform = null; };
|
||||
};
|
||||
|
||||
# mandatory flag should win over optional
|
||||
testMandatoryCheck = {
|
||||
expr = (getConfig mandatoryVsOptionalConfig).NIXOS_FAKE_USB_DEBUG.optional;
|
||||
expected = false;
|
||||
};
|
||||
|
||||
testYesWinsOverNo = {
|
||||
expr = (getConfig yesWinsOverNoConfig)."NIXOS_TEST_BOOLEAN".tristate;
|
||||
expected = "y";
|
||||
};
|
||||
|
||||
testAllOptionalRemainOptional = {
|
||||
expr = (getConfig allOptionalRemainOptional)."NIXOS_FAKE_USB_DEBUG".optional;
|
||||
expected = true;
|
||||
};
|
||||
|
||||
# check that freeform options are unique
|
||||
# Should trigger
|
||||
# > The option `settings.NIXOS_FAKE_MMC_BLOCK_MINORS.freeform' has conflicting definitions, in `<unknown-file>' and `<unknown-file>'
|
||||
testTreeform = let
|
||||
res = builtins.tryEval ( (getConfig freeformConfig).NIXOS_FAKE_MMC_BLOCK_MINORS.freeform);
|
||||
in {
|
||||
expr = res.success;
|
||||
expected = false;
|
||||
};
|
||||
|
||||
}
|
||||
88
pkgs/test/ld-library-path/default.nix
Normal file
88
pkgs/test/ld-library-path/default.nix
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
{ lib, stdenv }:
|
||||
|
||||
# This tests that libraries listed in LD_LIBRARY_PATH take precedence over those listed in RPATH.
|
||||
|
||||
let
|
||||
# A simple test library: libgreeting.so which exports a single function getGreeting() returning the good old hello greeting.
|
||||
libgreeting = stdenv.mkDerivation {
|
||||
name = "libgreeting";
|
||||
|
||||
code = ''
|
||||
const char* getGreeting() { return "Hello, world!"; }
|
||||
'';
|
||||
|
||||
unpackPhase = ''
|
||||
echo "$code" > libgreeting.c
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib
|
||||
$CC -c -fpic libgreeting.c
|
||||
$CC -shared libgreeting.o -o $out/lib/libgreeting.so
|
||||
'';
|
||||
};
|
||||
|
||||
# A variant of libgreeting.so that returns a different message.
|
||||
libgoodbye = libgreeting.overrideAttrs (_: {
|
||||
name = "libgoodbye";
|
||||
code = ''
|
||||
const char* getGreeting() { return "Goodbye, world!"; }
|
||||
'';
|
||||
});
|
||||
|
||||
# A simple consumer of libgreeting.so that just prints the greeting to stdout.
|
||||
testProgram = stdenv.mkDerivation {
|
||||
name = "greeting-test";
|
||||
|
||||
buildInputs = [ libgreeting ];
|
||||
|
||||
code = ''
|
||||
#include <stdio.h>
|
||||
|
||||
extern const char* getGreeting(void);
|
||||
|
||||
int main() {
|
||||
puts(getGreeting());
|
||||
}
|
||||
'';
|
||||
|
||||
unpackPhase = ''
|
||||
echo "$code" > greeting-test.c
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
$CC -c greeting-test.c
|
||||
$CC greeting-test.o -lgreeting -o $out/bin/greeting-test
|
||||
|
||||
# Now test the installed binaries right after compiling them. In particular,
|
||||
# don't do this in installCheckPhase because fixupPhase has been run by then!
|
||||
(
|
||||
export PATH=$out/bin
|
||||
set -x
|
||||
|
||||
# Verify that our unmodified binary works as expected.
|
||||
[ "$(greeting-test)" = "Hello, world!" ]
|
||||
|
||||
# And finally, test that a library in LD_LIBRARY_PATH takes precedence over the linked-in library.
|
||||
[ "$(LD_LIBRARY_PATH=${libgoodbye}/lib greeting-test)" = "Goodbye, world!" ]
|
||||
)
|
||||
'';
|
||||
|
||||
};
|
||||
in stdenv.mkDerivation {
|
||||
name = "test-LD_LIBRARY_PATH";
|
||||
nativeBuildInputs = [ testProgram ];
|
||||
|
||||
buildCommand = ''
|
||||
# And for good measure, repeat the tests again from a separate derivation,
|
||||
# as fixupPhase done by the stdenv can (and has!) affect the result.
|
||||
|
||||
[ "$(greeting-test)" = "Hello, world!" ]
|
||||
[ "$(LD_LIBRARY_PATH=${libgoodbye}/lib greeting-test)" = "Goodbye, world!" ]
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
meta.platforms = lib.platforms.linux;
|
||||
}
|
||||
90
pkgs/test/macos-sierra-shared/default.nix
Normal file
90
pkgs/test/macos-sierra-shared/default.nix
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
{ lib, clangStdenv, clang-sierraHack-stdenv, stdenvNoCC }:
|
||||
|
||||
let
|
||||
makeBigExe = stdenv: prefix: rec {
|
||||
|
||||
count = 320;
|
||||
|
||||
sillyLibs = lib.genList (i: stdenv.mkDerivation rec {
|
||||
name = "${prefix}-fluff-${toString i}";
|
||||
unpackPhase = ''
|
||||
src=$PWD
|
||||
cat << 'EOF' > ${name}.c
|
||||
unsigned int asdf_${toString i}(void) {
|
||||
return ${toString i};
|
||||
}
|
||||
EOF
|
||||
'';
|
||||
buildPhase = ''
|
||||
$CC -std=c99 -shared ${name}.c -o lib${name}.dylib -Wl,-install_name,$out/lib/lib${name}.dylib
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p "$out/lib"
|
||||
mv lib${name}.dylib "$out/lib"
|
||||
'';
|
||||
meta.platforms = lib.platforms.darwin;
|
||||
}) count;
|
||||
|
||||
finalExe = stdenv.mkDerivation {
|
||||
name = "${prefix}-final-asdf";
|
||||
unpackPhase = ''
|
||||
src=$PWD
|
||||
cat << 'EOF' > main.cxx
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
${toString (lib.genList (i: "extern \"C\" unsigned int asdf_${toString i}(void); ") count)}
|
||||
|
||||
unsigned int (*funs[])(void) = {
|
||||
${toString (lib.genList (i: "asdf_${toString i},") count)}
|
||||
};
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
bool ret;
|
||||
unsigned int i = 0;
|
||||
for (auto f : funs) {
|
||||
if (f() != i++) {
|
||||
std::cerr << "Failed to get expected response from function #" << i << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
EOF
|
||||
'';
|
||||
buildPhase = ''
|
||||
$CXX -std=c++11 main.cxx ${toString (map (x: "-l${x.name}") sillyLibs)} -o ${prefix}-asdf
|
||||
'';
|
||||
buildInputs = sillyLibs;
|
||||
installPhase = ''
|
||||
mkdir -p "$out/bin"
|
||||
mv ${prefix}-asdf "$out/bin"
|
||||
'';
|
||||
meta.platforms = lib.platforms.darwin;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
good = makeBigExe clang-sierraHack-stdenv "good";
|
||||
|
||||
bad = makeBigExe clangStdenv "bad";
|
||||
|
||||
in stdenvNoCC.mkDerivation {
|
||||
name = "macos-sierra-shared-test";
|
||||
buildInputs = [ good.finalExe bad.finalExe ];
|
||||
# TODO(@Ericson2314): Be impure or require exact MacOS version of builder?
|
||||
buildCommand = ''
|
||||
if bad-asdf &> /dev/null
|
||||
then echo "WARNING: bad-asdf did not fail, not running on sierra?" >&2
|
||||
else echo "bad-asdf should fail on sierra, OK" >&2
|
||||
fi
|
||||
|
||||
# Must succeed on all supported MacOS versions
|
||||
good-asdf
|
||||
echo "good-asdf should succeed on sierra, OK"
|
||||
|
||||
touch $out
|
||||
'';
|
||||
meta.platforms = lib.platforms.darwin;
|
||||
}
|
||||
21
pkgs/test/make-binary-wrapper/add-flags.c
Normal file
21
pkgs/test/make-binary-wrapper/add-flags.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char **argv_tmp = calloc(5 + argc, sizeof(*argv_tmp));
|
||||
assert(argv_tmp != NULL);
|
||||
argv_tmp[0] = argv[0];
|
||||
argv_tmp[1] = "-x";
|
||||
argv_tmp[2] = "-y";
|
||||
argv_tmp[3] = "-z";
|
||||
argv_tmp[4] = "-abc";
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
argv_tmp[4 + i] = argv[i];
|
||||
}
|
||||
argv_tmp[4 + argc] = NULL;
|
||||
argv = argv_tmp;
|
||||
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
2
pkgs/test/make-binary-wrapper/add-flags.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/add-flags.cmdline
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--add-flags "-x -y -z" \
|
||||
--add-flags -abc
|
||||
6
pkgs/test/make-binary-wrapper/add-flags.env
Normal file
6
pkgs/test/make-binary-wrapper/add-flags.env
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
-x
|
||||
-y
|
||||
-z
|
||||
-abc
|
||||
7
pkgs/test/make-binary-wrapper/argv0.c
Normal file
7
pkgs/test/make-binary-wrapper/argv0.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
argv[0] = "alternative-name";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
1
pkgs/test/make-binary-wrapper/argv0.cmdline
Normal file
1
pkgs/test/make-binary-wrapper/argv0.cmdline
Normal file
|
|
@ -0,0 +1 @@
|
|||
--argv0 alternative-name
|
||||
2
pkgs/test/make-binary-wrapper/argv0.env
Normal file
2
pkgs/test/make-binary-wrapper/argv0.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CWD=SUBST_CWD
|
||||
alternative-name
|
||||
7
pkgs/test/make-binary-wrapper/basic.c
Normal file
7
pkgs/test/make-binary-wrapper/basic.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
0
pkgs/test/make-binary-wrapper/basic.cmdline
Normal file
0
pkgs/test/make-binary-wrapper/basic.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/basic.env
Normal file
2
pkgs/test/make-binary-wrapper/basic.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
11
pkgs/test/make-binary-wrapper/chdir.c
Normal file
11
pkgs/test/make-binary-wrapper/chdir.c
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
assert_success(chdir("./tmp/foo"));
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
1
pkgs/test/make-binary-wrapper/chdir.cmdline
Normal file
1
pkgs/test/make-binary-wrapper/chdir.cmdline
Normal file
|
|
@ -0,0 +1 @@
|
|||
--chdir ./tmp/foo
|
||||
2
pkgs/test/make-binary-wrapper/chdir.env
Normal file
2
pkgs/test/make-binary-wrapper/chdir.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CWD=SUBST_CWD/tmp/foo
|
||||
SUBST_ARGV0
|
||||
53
pkgs/test/make-binary-wrapper/combination.c
Normal file
53
pkgs/test/make-binary-wrapper/combination.c
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
void set_env_prefix(char *env, char *sep, char *prefix) {
|
||||
char *existing = getenv(env);
|
||||
if (existing) {
|
||||
char *val;
|
||||
assert_success(asprintf(&val, "%s%s%s", prefix, sep, existing));
|
||||
assert_success(setenv(env, val, 1));
|
||||
free(val);
|
||||
} else {
|
||||
assert_success(setenv(env, prefix, 1));
|
||||
}
|
||||
}
|
||||
|
||||
void set_env_suffix(char *env, char *sep, char *suffix) {
|
||||
char *existing = getenv(env);
|
||||
if (existing) {
|
||||
char *val;
|
||||
assert_success(asprintf(&val, "%s%s%s", existing, sep, suffix));
|
||||
assert_success(setenv(env, val, 1));
|
||||
free(val);
|
||||
} else {
|
||||
assert_success(setenv(env, suffix, 1));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
assert_success(setenv("MESSAGE", "HELLO", 0));
|
||||
set_env_prefix("PATH", ":", "/usr/bin/");
|
||||
set_env_suffix("PATH", ":", "/usr/local/bin/");
|
||||
putenv("MESSAGE2=WORLD");
|
||||
|
||||
char **argv_tmp = calloc(4 + argc, sizeof(*argv_tmp));
|
||||
assert(argv_tmp != NULL);
|
||||
argv_tmp[0] = argv[0];
|
||||
argv_tmp[1] = "-x";
|
||||
argv_tmp[2] = "-y";
|
||||
argv_tmp[3] = "-z";
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
argv_tmp[3 + i] = argv[i];
|
||||
}
|
||||
argv_tmp[3 + argc] = NULL;
|
||||
argv = argv_tmp;
|
||||
|
||||
argv[0] = "my-wrapper";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
6
pkgs/test/make-binary-wrapper/combination.cmdline
Normal file
6
pkgs/test/make-binary-wrapper/combination.cmdline
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
--argv0 my-wrapper \
|
||||
--set-default MESSAGE HELLO \
|
||||
--prefix PATH : /usr/bin/ \
|
||||
--suffix PATH : /usr/local/bin/ \
|
||||
--add-flags "-x -y -z" \
|
||||
--set MESSAGE2 WORLD
|
||||
8
pkgs/test/make-binary-wrapper/combination.env
Normal file
8
pkgs/test/make-binary-wrapper/combination.env
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
MESSAGE=HELLO
|
||||
PATH=/usr/bin/:/usr/local/bin/
|
||||
MESSAGE2=WORLD
|
||||
CWD=SUBST_CWD
|
||||
my-wrapper
|
||||
-x
|
||||
-y
|
||||
-z
|
||||
23
pkgs/test/make-binary-wrapper/cross.nix
Normal file
23
pkgs/test/make-binary-wrapper/cross.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{ stdenv
|
||||
, runCommand
|
||||
, makeBinaryWrapper
|
||||
, binutils
|
||||
, expectedArch ? stdenv.hostPlatform.parsed.cpu.name
|
||||
}:
|
||||
|
||||
runCommand "make-binary-wrapper-test-cross" {
|
||||
nativeBuildInputs = [
|
||||
makeBinaryWrapper
|
||||
binutils
|
||||
];
|
||||
inherit expectedArch;
|
||||
} ''
|
||||
touch prog
|
||||
chmod +x prog
|
||||
makeWrapper prog $out
|
||||
read -r _ arch < <($READELF --file-header $out | grep Machine:)
|
||||
if [[ ''${arch,,} != *"''${expectedArch,,}"* ]]; then
|
||||
echo "expected $expectedArch, got $arch"
|
||||
exit 1
|
||||
fi
|
||||
''
|
||||
61
pkgs/test/make-binary-wrapper/default.nix
Normal file
61
pkgs/test/make-binary-wrapper/default.nix
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, pkgsCross
|
||||
, makeBinaryWrapper
|
||||
, writeText
|
||||
, runCommand
|
||||
, runCommandCC
|
||||
}:
|
||||
|
||||
let
|
||||
env = { nativeBuildInputs = [ makeBinaryWrapper ]; };
|
||||
envCheck = runCommandCC "envcheck" env ''
|
||||
cc -Wall -Werror -Wpedantic -o $out ${./envcheck.c}
|
||||
'';
|
||||
makeGoldenTest = testname: runCommand "make-binary-wrapper-test-${testname}" env ''
|
||||
mkdir -p tmp/foo # for the chdir test
|
||||
|
||||
params=$(<"${./.}/${testname}.cmdline")
|
||||
eval "makeCWrapper /send/me/flags $params" > wrapper.c
|
||||
|
||||
diff wrapper.c "${./.}/${testname}.c"
|
||||
|
||||
if [ -f "${./.}/${testname}.env" ]; then
|
||||
eval "makeWrapper ${envCheck} wrapped $params"
|
||||
env -i ./wrapped > env.txt
|
||||
sed "s#SUBST_ARGV0#${envCheck}#;s#SUBST_CWD#$PWD#" \
|
||||
"${./.}/${testname}.env" > golden-env.txt
|
||||
if ! diff env.txt golden-env.txt; then
|
||||
echo "env/argv should be:"
|
||||
cat golden-env.txt
|
||||
echo "env/argv output is:"
|
||||
cat env.txt
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# without a golden env, we expect the wrapper compilation to fail
|
||||
! eval "makeWrapper ${envCheck} wrapped $params" &> error.txt
|
||||
fi
|
||||
|
||||
cp wrapper.c $out
|
||||
'';
|
||||
tests = lib.genAttrs [
|
||||
"add-flags"
|
||||
"argv0"
|
||||
"basic"
|
||||
"chdir"
|
||||
"combination"
|
||||
"env"
|
||||
"inherit-argv0"
|
||||
"invalid-env"
|
||||
"overlength-strings"
|
||||
"prefix"
|
||||
"suffix"
|
||||
] makeGoldenTest // lib.optionalAttrs (! stdenv.isDarwin) {
|
||||
cross = pkgsCross.aarch64-multiplatform.callPackage ./cross.nix { };
|
||||
};
|
||||
in
|
||||
|
||||
writeText "make-binary-wrapper-tests" ''
|
||||
${lib.concatStringsSep "\n" (builtins.attrValues tests)}
|
||||
'' // tests
|
||||
14
pkgs/test/make-binary-wrapper/env.c
Normal file
14
pkgs/test/make-binary-wrapper/env.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
putenv("PART1=HELLO");
|
||||
assert_success(setenv("PART2", "WORLD", 0));
|
||||
assert_success(unsetenv("SOME_OTHER_VARIABLE"));
|
||||
putenv("PART3=\"!!\n\"");
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
4
pkgs/test/make-binary-wrapper/env.cmdline
Normal file
4
pkgs/test/make-binary-wrapper/env.cmdline
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
--set PART1 HELLO \
|
||||
--set-default PART2 WORLD \
|
||||
--unset SOME_OTHER_VARIABLE \
|
||||
--set PART3 $'"!!\n"'
|
||||
6
pkgs/test/make-binary-wrapper/env.env
Normal file
6
pkgs/test/make-binary-wrapper/env.env
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
PART1=HELLO
|
||||
PART2=WORLD
|
||||
PART3="!!
|
||||
"
|
||||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
22
pkgs/test/make-binary-wrapper/envcheck.c
Normal file
22
pkgs/test/make-binary-wrapper/envcheck.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char **argv, char **envp) {
|
||||
for (char **env = envp; *env != 0; ++env) {
|
||||
puts(*env);
|
||||
}
|
||||
|
||||
char cwd[PATH_MAX];
|
||||
if (getcwd(cwd, sizeof(cwd))) {
|
||||
printf("CWD=%s\n", cwd);
|
||||
} else {
|
||||
perror("getcwd() error");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i=0; i < argc; ++i) {
|
||||
puts(argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
6
pkgs/test/make-binary-wrapper/inherit-argv0.c
Normal file
6
pkgs/test/make-binary-wrapper/inherit-argv0.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
1
pkgs/test/make-binary-wrapper/inherit-argv0.cmdline
Normal file
1
pkgs/test/make-binary-wrapper/inherit-argv0.cmdline
Normal file
|
|
@ -0,0 +1 @@
|
|||
--inherit-argv0
|
||||
2
pkgs/test/make-binary-wrapper/inherit-argv0.env
Normal file
2
pkgs/test/make-binary-wrapper/inherit-argv0.env
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
CWD=SUBST_CWD
|
||||
./wrapped
|
||||
14
pkgs/test/make-binary-wrapper/invalid-env.c
Normal file
14
pkgs/test/make-binary-wrapper/invalid-env.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
putenv("==TEST1");
|
||||
#error Illegal environment variable name `=` (cannot contain `=`)
|
||||
assert_success(setenv("", "TEST2", 0));
|
||||
#error Environment variable name can't be empty.
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
2
pkgs/test/make-binary-wrapper/invalid-env.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/invalid-env.cmdline
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--set "=" "TEST1" \
|
||||
--set-default "" "TEST2"
|
||||
25
pkgs/test/make-binary-wrapper/overlength-strings.c
Normal file
25
pkgs/test/make-binary-wrapper/overlength-strings.c
Normal file
File diff suppressed because one or more lines are too long
1
pkgs/test/make-binary-wrapper/overlength-strings.cmdline
Normal file
1
pkgs/test/make-binary-wrapper/overlength-strings.cmdline
Normal file
File diff suppressed because one or more lines are too long
3
pkgs/test/make-binary-wrapper/overlength-strings.env
Normal file
3
pkgs/test/make-binary-wrapper/overlength-strings.env
Normal file
File diff suppressed because one or more lines are too long
26
pkgs/test/make-binary-wrapper/prefix.c
Normal file
26
pkgs/test/make-binary-wrapper/prefix.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
void set_env_prefix(char *env, char *sep, char *prefix) {
|
||||
char *existing = getenv(env);
|
||||
if (existing) {
|
||||
char *val;
|
||||
assert_success(asprintf(&val, "%s%s%s", prefix, sep, existing));
|
||||
assert_success(setenv(env, val, 1));
|
||||
free(val);
|
||||
} else {
|
||||
assert_success(setenv(env, prefix, 1));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
set_env_prefix("PATH", ":", "/usr/bin/");
|
||||
set_env_prefix("PATH", ":", "/usr/local/bin/");
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
2
pkgs/test/make-binary-wrapper/prefix.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/prefix.cmdline
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--prefix PATH : /usr/bin/ \
|
||||
--prefix PATH : /usr/local/bin/
|
||||
3
pkgs/test/make-binary-wrapper/prefix.env
Normal file
3
pkgs/test/make-binary-wrapper/prefix.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
PATH=/usr/local/bin/:/usr/bin/
|
||||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
26
pkgs/test/make-binary-wrapper/suffix.c
Normal file
26
pkgs/test/make-binary-wrapper/suffix.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#define _GNU_SOURCE /* See feature_test_macros(7) */
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define assert_success(e) do { if ((e) < 0) { perror(#e); abort(); } } while (0)
|
||||
|
||||
void set_env_suffix(char *env, char *sep, char *suffix) {
|
||||
char *existing = getenv(env);
|
||||
if (existing) {
|
||||
char *val;
|
||||
assert_success(asprintf(&val, "%s%s%s", existing, sep, suffix));
|
||||
assert_success(setenv(env, val, 1));
|
||||
free(val);
|
||||
} else {
|
||||
assert_success(setenv(env, suffix, 1));
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
set_env_suffix("PATH", ":", "/usr/bin/");
|
||||
set_env_suffix("PATH", ":", "/usr/local/bin/");
|
||||
argv[0] = "/send/me/flags";
|
||||
return execv("/send/me/flags", argv);
|
||||
}
|
||||
2
pkgs/test/make-binary-wrapper/suffix.cmdline
Normal file
2
pkgs/test/make-binary-wrapper/suffix.cmdline
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
--suffix PATH : /usr/bin/ \
|
||||
--suffix PATH : /usr/local/bin/
|
||||
3
pkgs/test/make-binary-wrapper/suffix.env
Normal file
3
pkgs/test/make-binary-wrapper/suffix.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
PATH=/usr/bin/:/usr/local/bin/
|
||||
CWD=SUBST_CWD
|
||||
SUBST_ARGV0
|
||||
139
pkgs/test/make-wrapper/default.nix
Normal file
139
pkgs/test/make-wrapper/default.nix
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
{ lib
|
||||
, writeText
|
||||
, writeCBin
|
||||
, writeShellScript
|
||||
, makeWrapper
|
||||
, runCommand
|
||||
, which
|
||||
, ...
|
||||
}:
|
||||
|
||||
let
|
||||
# Testfiles
|
||||
foofile = writeText "foofile" "foo";
|
||||
barfile = writeText "barfile" "bar";
|
||||
|
||||
# Wrapped binaries
|
||||
wrappedArgv0 = writeCBin "wrapped-argv0" ''
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void main(int argc, char** argv) {
|
||||
printf("argv0=%s", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
'';
|
||||
wrappedBinaryVar = writeShellScript "wrapped-var" ''
|
||||
echo "VAR=$VAR"
|
||||
'';
|
||||
wrappedBinaryArgs = writeShellScript "wrapped-args" ''
|
||||
echo "$@"
|
||||
'';
|
||||
|
||||
mkWrapperBinary = { name, args, wrapped ? wrappedBinaryVar }: runCommand name
|
||||
{
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
} ''
|
||||
mkdir -p $out/bin
|
||||
makeWrapper "${wrapped}" "$out/bin/${name}" ${lib.escapeShellArgs args}
|
||||
'';
|
||||
|
||||
mkTest = cmd: toExpect: ''
|
||||
output="$(${cmd})"
|
||||
if [[ "$output" != '${toExpect}' ]]; then
|
||||
echo "test failed: the output of ${cmd} was '$output', expected '${toExpect}'"
|
||||
echo "the wrapper contents:"
|
||||
for i in ${cmd}; do
|
||||
if [[ $i =~ ^test- ]]; then
|
||||
cat $(which $i)
|
||||
fi
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
in
|
||||
runCommand "make-wrapper-test"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
which
|
||||
(mkWrapperBinary { name = "test-argv0"; args = [ "--argv0" "foo" ]; wrapped = "${wrappedArgv0}/bin/wrapped-argv0"; })
|
||||
(mkWrapperBinary { name = "test-set"; args = [ "--set" "VAR" "abc" ]; })
|
||||
(mkWrapperBinary { name = "test-set-default"; args = [ "--set-default" "VAR" "abc" ]; })
|
||||
(mkWrapperBinary { name = "test-unset"; args = [ "--unset" "VAR" ]; })
|
||||
(mkWrapperBinary { name = "test-run"; args = [ "--run" "echo bar" ]; })
|
||||
(mkWrapperBinary { name = "test-run-and-set"; args = [ "--run" "export VAR=foo" "--set" "VAR" "bar" ]; })
|
||||
(mkWrapperBinary { name = "test-args"; args = [ "--add-flags" "abc" ]; wrapped = wrappedBinaryArgs; })
|
||||
(mkWrapperBinary { name = "test-prefix"; args = [ "--prefix" "VAR" ":" "abc" ]; })
|
||||
(mkWrapperBinary { name = "test-prefix-noglob"; args = [ "--prefix" "VAR" ":" "./*" ]; })
|
||||
(mkWrapperBinary { name = "test-suffix"; args = [ "--suffix" "VAR" ":" "abc" ]; })
|
||||
(mkWrapperBinary { name = "test-prefix-and-suffix"; args = [ "--prefix" "VAR" ":" "foo" "--suffix" "VAR" ":" "bar" ]; })
|
||||
(mkWrapperBinary { name = "test-prefix-multi"; args = [ "--prefix" "VAR" ":" "abc:foo:foo" ]; })
|
||||
(mkWrapperBinary { name = "test-suffix-each"; args = [ "--suffix-each" "VAR" ":" "foo bar:def" ]; })
|
||||
(mkWrapperBinary { name = "test-prefix-each"; args = [ "--prefix-each" "VAR" ":" "foo bar:def" ]; })
|
||||
(mkWrapperBinary { name = "test-suffix-contents"; args = [ "--suffix-contents" "VAR" ":" "${foofile} ${barfile}" ]; })
|
||||
(mkWrapperBinary { name = "test-prefix-contents"; args = [ "--prefix-contents" "VAR" ":" "${foofile} ${barfile}" ]; })
|
||||
];
|
||||
}
|
||||
(
|
||||
# --argv0 works
|
||||
mkTest "test-argv0" "argv0=foo"
|
||||
|
||||
# --set works
|
||||
+ mkTest "test-set" "VAR=abc"
|
||||
# --set overwrites the variable
|
||||
+ mkTest "VAR=foo test-set" "VAR=abc"
|
||||
# --set-default works
|
||||
+ mkTest "test-set-default" "VAR=abc"
|
||||
# --set-default doesn"t overwrite the variable
|
||||
+ mkTest "VAR=foo test-set-default" "VAR=foo"
|
||||
# --unset works
|
||||
+ mkTest "VAR=foo test-unset" "VAR="
|
||||
|
||||
# --add-flags works
|
||||
+ mkTest "test-args" "abc"
|
||||
# given flags are appended
|
||||
+ mkTest "test-args foo" "abc foo"
|
||||
|
||||
# --run works
|
||||
+ mkTest "test-run" "bar\nVAR="
|
||||
# --run & --set works
|
||||
+ mkTest "test-run-and-set" "VAR=bar"
|
||||
|
||||
# --prefix works
|
||||
+ mkTest "VAR=foo test-prefix" "VAR=abc:foo"
|
||||
# sets variable if not set yet
|
||||
+ mkTest "test-prefix" "VAR=abc"
|
||||
# prepends value only once
|
||||
+ mkTest "VAR=abc test-prefix" "VAR=abc"
|
||||
# Moves value to the front if it already existed
|
||||
+ mkTest "VAR=foo:abc test-prefix" "VAR=abc:foo"
|
||||
+ mkTest "VAR=abc:foo:bar test-prefix-multi" "VAR=abc:foo:bar"
|
||||
# Doesn't overwrite parts of the string
|
||||
+ mkTest "VAR=test:abcde:test test-prefix" "VAR=abc:test:abcde:test"
|
||||
# Only append the value once when given multiple times in a parameter
|
||||
# to makeWrapper
|
||||
+ mkTest "test-prefix" "VAR=abc"
|
||||
# --prefix doesn't expand globs
|
||||
+ mkTest "VAR=f?oo test-prefix-noglob" "VAR=./*:f?oo"
|
||||
|
||||
|
||||
# --suffix works
|
||||
+ mkTest "VAR=foo test-suffix" "VAR=foo:abc"
|
||||
# sets variable if not set yet
|
||||
+ mkTest "test-suffix" "VAR=abc"
|
||||
# adds the same value only once
|
||||
+ mkTest "VAR=abc test-suffix" "VAR=abc"
|
||||
+ mkTest "VAR=abc:foo test-suffix" "VAR=abc:foo"
|
||||
# --prefix in combination with --suffix
|
||||
+ mkTest "VAR=abc test-prefix-and-suffix" "VAR=foo:abc:bar"
|
||||
|
||||
# --suffix-each works
|
||||
+ mkTest "VAR=abc test-suffix-each" "VAR=abc:foo:bar:def"
|
||||
# --prefix-each works
|
||||
+ mkTest "VAR=abc test-prefix-each" "VAR=bar:def:foo:abc"
|
||||
# --suffix-contents works
|
||||
+ mkTest "VAR=abc test-suffix-contents" "VAR=abc:foo:bar"
|
||||
# --prefix-contents works
|
||||
+ mkTest "VAR=abc test-prefix-contents" "VAR=bar:foo:abc"
|
||||
+ "touch $out"
|
||||
)
|
||||
31
pkgs/test/nixos-functions/default.nix
Normal file
31
pkgs/test/nixos-functions/default.nix
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
|
||||
This file is a test that makes sure that the `pkgs.nixos` and
|
||||
`pkgs.testers.nixosTest` functions work. It's far from a perfect test suite,
|
||||
but better than not checking them at all on hydra.
|
||||
|
||||
To run this test:
|
||||
|
||||
nixpkgs$ nix-build -A tests.nixos-functions
|
||||
|
||||
*/
|
||||
{ pkgs, lib, stdenv, ... }:
|
||||
|
||||
let
|
||||
dummyVersioning = {
|
||||
revision = "test";
|
||||
versionSuffix = "test";
|
||||
label = "test";
|
||||
};
|
||||
in lib.optionalAttrs stdenv.hostPlatform.isLinux (
|
||||
pkgs.recurseIntoAttrs {
|
||||
|
||||
nixos-test = (pkgs.nixos {
|
||||
system.nixos = dummyVersioning;
|
||||
boot.loader.grub.enable = false;
|
||||
fileSystems."/".device = "/dev/null";
|
||||
system.stateVersion = lib.trivial.release;
|
||||
}).toplevel;
|
||||
|
||||
}
|
||||
)
|
||||
70
pkgs/test/patch-shebangs/default.nix
Normal file
70
pkgs/test/patch-shebangs/default.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
{ lib, stdenv, runCommand }:
|
||||
|
||||
let
|
||||
tests = {
|
||||
bad-shebang = stdenv.mkDerivation {
|
||||
name = "bad-shebang";
|
||||
dontUnpack = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
echo "#!/bin/sh" > $out/bin/test
|
||||
echo "echo -n hello" >> $out/bin/test
|
||||
chmod +x $out/bin/test
|
||||
'';
|
||||
passthru = {
|
||||
assertion = "grep -v '^#!/bin/sh' $out/bin/test > /dev/null";
|
||||
};
|
||||
};
|
||||
|
||||
ignores-nix-store = stdenv.mkDerivation {
|
||||
name = "ignores-nix-store";
|
||||
dontUnpack = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
echo "#!$NIX_STORE/path/to/sh" > $out/bin/test
|
||||
echo "echo -n hello" >> $out/bin/test
|
||||
chmod +x $out/bin/test
|
||||
'';
|
||||
passthru = {
|
||||
assertion = "grep \"^#!$NIX_STORE/path/to/sh\" $out/bin/test > /dev/null";
|
||||
};
|
||||
};
|
||||
};
|
||||
in runCommand "patch-shebangs-test" {
|
||||
passthru = { inherit (tests) bad-shebang ignores-nix-store; };
|
||||
meta.platforms = lib.platforms.all;
|
||||
} ''
|
||||
validate() {
|
||||
local name=$1
|
||||
local testout=$2
|
||||
local assertion=$3
|
||||
|
||||
echo -n "... $name: " >&2
|
||||
|
||||
local rc=0
|
||||
(out=$testout eval "$assertion") || rc=1
|
||||
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
echo "yes" >&2
|
||||
else
|
||||
echo "no" >&2
|
||||
fi
|
||||
|
||||
return "$rc"
|
||||
}
|
||||
|
||||
echo "checking whether patchShebangs works properly... ">&2
|
||||
|
||||
fail=
|
||||
${lib.concatStringsSep "\n" (lib.mapAttrsToList (_: test: ''
|
||||
validate "${test.name}" "${test}" ${lib.escapeShellArg test.assertion} || fail=1
|
||||
'') tests)}
|
||||
|
||||
if [ "$fail" ]; then
|
||||
echo "failed"
|
||||
exit 1
|
||||
else
|
||||
echo "succeeded"
|
||||
touch $out
|
||||
fi
|
||||
''
|
||||
116
pkgs/test/php/default.nix
Normal file
116
pkgs/test/php/default.nix
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
{ lib
|
||||
, php
|
||||
, runCommand
|
||||
}:
|
||||
|
||||
let
|
||||
runTest = name: body: runCommand name { } ''
|
||||
testFailed=
|
||||
checking() {
|
||||
echo -n "Checking $1... " > /dev/stderr
|
||||
}
|
||||
ok() {
|
||||
echo ok > /dev/stderr
|
||||
}
|
||||
nok() {
|
||||
echo fail > /dev/stderr
|
||||
testFailed=1
|
||||
}
|
||||
|
||||
${body}
|
||||
|
||||
if test -n "$testFailed"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
check = cond: if cond then "ok" else "nok";
|
||||
in
|
||||
{
|
||||
withExtensions-enables-previously-disabled-extensions = runTest "php-test-withExtensions-enables-previously-disabled-extensions" ''
|
||||
php="${php}"
|
||||
|
||||
checking "that imagick is not present by default"
|
||||
$php/bin/php -r 'exit(extension_loaded("imagick") ? 1 : 0);' && ok || nok
|
||||
|
||||
phpWithImagick="${php.withExtensions ({ all, ... }: [ all.imagick ])}"
|
||||
checking "that imagick extension is present when enabled"
|
||||
$phpWithImagick/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok
|
||||
'';
|
||||
|
||||
overrideAttrs-preserves-enabled-extensions =
|
||||
let
|
||||
customPhp =
|
||||
(php.withExtensions ({ all, ... }: [ all.imagick ])).overrideAttrs (attrs: {
|
||||
postInstall = attrs.postInstall or "" + ''
|
||||
touch "$out/oApee-was-here"
|
||||
'';
|
||||
});
|
||||
in
|
||||
runTest "php-test-overrideAttrs-preserves-enabled-extensions" ''
|
||||
php="${customPhp}"
|
||||
phpUnwrapped="${customPhp.unwrapped}"
|
||||
|
||||
checking "if overrides took hold"
|
||||
test -f "$phpUnwrapped/oApee-was-here" && ok || nok
|
||||
|
||||
checking "if imagick extension is still present"
|
||||
$php/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok
|
||||
|
||||
checking "if imagick extension is linked against the overridden PHP"
|
||||
echo $php
|
||||
$php/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok
|
||||
'';
|
||||
|
||||
unwrapped-overrideAttrs-stacks =
|
||||
let
|
||||
customPhp =
|
||||
lib.pipe php.unwrapped [
|
||||
(pkg: pkg.overrideAttrs (attrs: {
|
||||
postInstall = attrs.postInstall or "" + ''
|
||||
touch "$out/oAs-first"
|
||||
'';
|
||||
}))
|
||||
|
||||
(pkg: pkg.overrideAttrs (attrs: {
|
||||
postInstall = attrs.postInstall or "" + ''
|
||||
touch "$out/oAs-second"
|
||||
'';
|
||||
}))
|
||||
];
|
||||
in
|
||||
runTest "php-test-unwrapped-overrideAttrs-stacks" ''
|
||||
checking "if first override remained"
|
||||
${check (builtins.match ".*oAs-first.*" customPhp.postInstall != null)}
|
||||
|
||||
checking "if second override is there"
|
||||
${check (builtins.match ".*oAs-second.*" customPhp.postInstall != null)}
|
||||
'';
|
||||
|
||||
wrapped-overrideAttrs-stacks =
|
||||
let
|
||||
customPhp =
|
||||
lib.pipe php [
|
||||
(pkg: pkg.overrideAttrs (attrs: {
|
||||
postInstall = attrs.postInstall or "" + ''
|
||||
touch "$out/oAs-first"
|
||||
'';
|
||||
}))
|
||||
|
||||
(pkg: pkg.overrideAttrs (attrs: {
|
||||
postInstall = attrs.postInstall or "" + ''
|
||||
touch "$out/oAs-second"
|
||||
'';
|
||||
}))
|
||||
];
|
||||
in
|
||||
runTest "php-test-wrapped-overrideAttrs-stacks" ''
|
||||
checking "if first override remained"
|
||||
${check (builtins.match ".*oAs-first.*" customPhp.unwrapped.postInstall != null)}
|
||||
|
||||
checking "if second override is there"
|
||||
${check (builtins.match ".*oAs-second.*" customPhp.unwrapped.postInstall != null)}
|
||||
'';
|
||||
}
|
||||
60
pkgs/test/rust-sysroot/default.nix
Normal file
60
pkgs/test/rust-sysroot/default.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{ lib, rust, rustPlatform, fetchFromGitHub }:
|
||||
|
||||
let
|
||||
mkBlogOsTest = target: rustPlatform.buildRustPackage rec {
|
||||
name = "blog_os-sysroot-test";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "phil-opp";
|
||||
repo = "blog_os";
|
||||
rev = "4e38e7ddf8dd021c3cd7e4609dfa01afb827797b";
|
||||
sha256 = "0k9ipm9ddm1bad7bs7368wzzp6xwrhyfzfpckdax54l4ffqwljcg";
|
||||
};
|
||||
|
||||
cargoSha256 = "1x8iwgy1irgfkv2yjkxm6479nwbrk82b0c80jm7y4kw0s32r01lg";
|
||||
|
||||
inherit target;
|
||||
|
||||
RUSTFLAGS = "-C link-arg=-nostartfiles";
|
||||
|
||||
# Tests don't work for `no_std`. See https://os.phil-opp.com/testing/
|
||||
doCheck = false;
|
||||
|
||||
meta = with lib; {
|
||||
description = "Test for using custom sysroots with buildRustPackage";
|
||||
maintainers = with maintainers; [ aaronjanse ];
|
||||
platforms = lib.platforms.x86_64;
|
||||
};
|
||||
};
|
||||
|
||||
# The book uses rust-lld for linking, but rust-lld is not currently packaged for NixOS.
|
||||
# The justification in the book for using rust-lld suggests that gcc can still be used for testing:
|
||||
# > Instead of using the platform's default linker (which might not support Linux targets),
|
||||
# > we use the cross platform LLD linker that is shipped with Rust for linking our kernel.
|
||||
# https://github.com/phil-opp/blog_os/blame/7212ffaa8383122b1eb07fe1854814f99d2e1af4/blog/content/second-edition/posts/02-minimal-rust-kernel/index.md#L157
|
||||
targetContents = {
|
||||
"llvm-target" = "x86_64-unknown-none";
|
||||
"data-layout" = "e-m:e-i64:64-f80:128-n8:16:32:64-S128";
|
||||
"arch" = "x86_64";
|
||||
"target-endian" = "little";
|
||||
"target-pointer-width" = "64";
|
||||
"target-c-int-width" = "32";
|
||||
"os" = "none";
|
||||
"executables" = true;
|
||||
"linker-flavor" = "gcc";
|
||||
"panic-strategy" = "abort";
|
||||
"disable-redzone" = true;
|
||||
"features" = "-mmx,-sse,+soft-float";
|
||||
};
|
||||
|
||||
in {
|
||||
blogOS-targetByFile = mkBlogOsTest (builtins.toFile "x86_64-blog_os.json" (builtins.toJSON targetContents));
|
||||
blogOS-targetByNix = let
|
||||
plat = lib.systems.elaborate { config = "x86_64-none"; } // {
|
||||
rustc = {
|
||||
config = "x86_64-blog_os";
|
||||
platform = targetContents;
|
||||
};
|
||||
};
|
||||
in mkBlogOsTest (rust.toRustTargetSpec plat);
|
||||
}
|
||||
42
pkgs/test/simple/builder.sh
Normal file
42
pkgs/test/simple/builder.sh
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
set -x
|
||||
|
||||
export NIX_DEBUG=1
|
||||
|
||||
source $stdenv/setup
|
||||
|
||||
export NIX_ENFORCE_PURITY=1
|
||||
|
||||
mkdir $out
|
||||
mkdir $out/bin
|
||||
|
||||
cat > hello.c <<EOF
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello World!\n");
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
#gcc -I/nix/store/foo -I /nix/store/foo -I/usr/lib -I /usr/lib hello.c -o $out/bin/hello
|
||||
gcc -I`pwd` -L /nix/store/abcd/lib -isystem /usr/lib hello.c -o $out/bin/hello
|
||||
|
||||
$out/bin/hello
|
||||
|
||||
cat > hello2.cc <<EOF
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
std::cout << "Hello World!\n";
|
||||
std::cout << VALUE << std::endl;
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
g++ hello2.cc -o $out/bin/hello2 -DVALUE="1 + 2 * 3"
|
||||
|
||||
$out/bin/hello2
|
||||
|
||||
ld -v
|
||||
3
pkgs/test/stdenv-inputs/bar.c
Normal file
3
pkgs/test/stdenv-inputs/bar.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
unsigned int bar(void) {
|
||||
return 42;
|
||||
}
|
||||
7
pkgs/test/stdenv-inputs/cc-main.c
Normal file
7
pkgs/test/stdenv-inputs/cc-main.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
fprintf(stderr, "ok\n");
|
||||
return 0;
|
||||
}
|
||||
68
pkgs/test/stdenv-inputs/default.nix
Normal file
68
pkgs/test/stdenv-inputs/default.nix
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{ lib, stdenv }:
|
||||
|
||||
let
|
||||
foo = stdenv.mkDerivation {
|
||||
name = "foo-test";
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/include $out/lib
|
||||
$CC -o $out/bin/foo ${./cc-main.c}
|
||||
chmod +x $out/bin/foo
|
||||
cp ${./foo.c} $out/include/foo.h
|
||||
$CC -shared \
|
||||
${lib.optionalString stdenv.isDarwin "-Wl,-install_name,$out/lib/libfoo.dylib"} \
|
||||
-o $out/lib/libfoo${stdenv.hostPlatform.extensions.sharedLibrary} \
|
||||
${./foo.c}
|
||||
'';
|
||||
};
|
||||
|
||||
bar = stdenv.mkDerivation {
|
||||
name = "bar-test";
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $dev/include $dev/lib
|
||||
$CC -o $out/bin/bar ${./cc-main.c}
|
||||
chmod +x $out/bin/bar
|
||||
cp ${./bar.c} $dev/include/bar.h
|
||||
$CC -shared \
|
||||
${lib.optionalString stdenv.isDarwin "-Wl,-install_name,$dev/lib/libbar.dylib"} \
|
||||
-o $dev/lib/libbar${stdenv.hostPlatform.extensions.sharedLibrary} \
|
||||
${./bar.c}
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "stdenv-inputs-test";
|
||||
phases = [ "buildPhase" ];
|
||||
|
||||
buildInputs = [ foo bar ];
|
||||
|
||||
buildPhase = ''
|
||||
env
|
||||
|
||||
printf "checking whether binaries are available... " >&2
|
||||
foo && bar
|
||||
|
||||
printf "checking whether compiler can find headers... " >&2
|
||||
$CC -o include-check ${./include-main.c}
|
||||
./include-check
|
||||
|
||||
printf "checking whether compiler can find headers... " >&2
|
||||
$CC -o include-check ${./include-main.c}
|
||||
./include-check
|
||||
|
||||
printf "checking whether compiler can find libraries... " >&2
|
||||
$CC -lfoo -lbar -o lib-check ${./lib-main.c}
|
||||
./lib-check
|
||||
|
||||
touch $out
|
||||
'';
|
||||
|
||||
meta.platforms = lib.platforms.all;
|
||||
}
|
||||
3
pkgs/test/stdenv-inputs/foo.c
Normal file
3
pkgs/test/stdenv-inputs/foo.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
unsigned int foo(void) {
|
||||
return 42;
|
||||
}
|
||||
13
pkgs/test/stdenv-inputs/include-main.c
Normal file
13
pkgs/test/stdenv-inputs/include-main.c
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#include <stdio.h>
|
||||
#include <foo.h>
|
||||
#include <bar.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (foo() != 42)
|
||||
return 1;
|
||||
if (bar() != 42)
|
||||
return 1;
|
||||
fprintf(stderr, "ok\n");
|
||||
return 0;
|
||||
}
|
||||
14
pkgs/test/stdenv-inputs/lib-main.c
Normal file
14
pkgs/test/stdenv-inputs/lib-main.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <stdio.h>
|
||||
|
||||
extern unsigned int foo(void);
|
||||
extern unsigned int bar(void);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (foo() != 42)
|
||||
return 1;
|
||||
if (bar() != 42)
|
||||
return 1;
|
||||
fprintf(stderr, "ok\n");
|
||||
return 0;
|
||||
}
|
||||
167
pkgs/test/texlive/default.nix
Normal file
167
pkgs/test/texlive/default.nix
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
{ lib, runCommand, fetchurl, file, texlive, writeShellScript }:
|
||||
|
||||
{
|
||||
chktex = runCommand "texlive-test-chktex" {
|
||||
nativeBuildInputs = [
|
||||
(with texlive; combine { inherit scheme-infraonly chktex; })
|
||||
];
|
||||
input = builtins.toFile "chktex-sample.tex" ''
|
||||
\documentclass{article}
|
||||
\begin{document}
|
||||
\LaTeX is great
|
||||
\end{document}
|
||||
'';
|
||||
} ''
|
||||
chktex -v -nall -w1 "$input" 2>&1 | tee "$out"
|
||||
grep "One warning printed" "$out"
|
||||
'';
|
||||
|
||||
dvipng = lib.recurseIntoAttrs {
|
||||
# https://github.com/NixOS/nixpkgs/issues/75605
|
||||
basic = runCommand "texlive-test-dvipng-basic" {
|
||||
nativeBuildInputs = [ file texlive.combined.scheme-medium ];
|
||||
input = fetchurl {
|
||||
name = "test_dvipng.tex";
|
||||
url = "http://git.savannah.nongnu.org/cgit/dvipng.git/plain/test_dvipng.tex?id=b872753590a18605260078f56cbd6f28d39dc035";
|
||||
sha256 = "1pjpf1jvwj2pv5crzdgcrzvbmn7kfmgxa39pcvskl4pa0c9hl88n";
|
||||
};
|
||||
} ''
|
||||
cp "$input" ./document.tex
|
||||
|
||||
latex document.tex
|
||||
dvipng -T tight -strict -picky document.dvi
|
||||
for f in document*.png; do
|
||||
file "$f" | tee output
|
||||
grep PNG output
|
||||
done
|
||||
|
||||
mkdir "$out"
|
||||
mv document*.png "$out"/
|
||||
'';
|
||||
|
||||
# test dvipng's limited capability to render postscript specials via GS
|
||||
ghostscript = runCommand "texlive-test-ghostscript" {
|
||||
nativeBuildInputs = [ file (with texlive; combine { inherit scheme-small dvipng; }) ];
|
||||
input = builtins.toFile "postscript-sample.tex" ''
|
||||
\documentclass{minimal}
|
||||
\begin{document}
|
||||
Ni
|
||||
\special{ps:
|
||||
newpath
|
||||
0 0 moveto
|
||||
7 7 rlineto
|
||||
0 7 moveto
|
||||
7 -7 rlineto
|
||||
stroke
|
||||
showpage
|
||||
}
|
||||
\end{document}
|
||||
'';
|
||||
gs_trap = writeShellScript "gs_trap.sh" ''
|
||||
exit 1
|
||||
'';
|
||||
} ''
|
||||
cp "$gs_trap" ./gs
|
||||
export PATH=$PWD:$PATH
|
||||
# check that the trap works
|
||||
gs && exit 1
|
||||
|
||||
cp "$input" ./document.tex
|
||||
|
||||
latex document.tex
|
||||
dvipng -T 1in,1in -strict -picky document.dvi
|
||||
for f in document*.png; do
|
||||
file "$f" | tee output
|
||||
grep PNG output
|
||||
done
|
||||
|
||||
mkdir "$out"
|
||||
mv document*.png "$out"/
|
||||
'';
|
||||
};
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/issues/75070
|
||||
dvisvgm = runCommand "texlive-test-dvisvgm" {
|
||||
nativeBuildInputs = [ file texlive.combined.scheme-medium ];
|
||||
input = builtins.toFile "dvisvgm-sample.tex" ''
|
||||
\documentclass{article}
|
||||
\begin{document}
|
||||
mwe
|
||||
\end{document}
|
||||
'';
|
||||
} ''
|
||||
cp "$input" ./document.tex
|
||||
|
||||
latex document.tex
|
||||
dvisvgm document.dvi -n -o document_dvi.svg
|
||||
cat document_dvi.svg
|
||||
file document_dvi.svg | grep SVG
|
||||
|
||||
pdflatex document.tex
|
||||
dvisvgm -P document.pdf -n -o document_pdf.svg
|
||||
cat document_pdf.svg
|
||||
file document_pdf.svg | grep SVG
|
||||
|
||||
mkdir "$out"
|
||||
mv document*.svg "$out"/
|
||||
'';
|
||||
|
||||
texdoc = runCommand "texlive-test-texdoc" {
|
||||
nativeBuildInputs = [
|
||||
(with texlive; combine {
|
||||
inherit scheme-infraonly luatex texdoc;
|
||||
pkgFilter = pkg: lib.elem pkg.tlType [ "run" "bin" "doc" ];
|
||||
})
|
||||
];
|
||||
} ''
|
||||
texdoc --version
|
||||
|
||||
texdoc --debug --list texdoc | tee "$out"
|
||||
grep texdoc.pdf "$out"
|
||||
'';
|
||||
|
||||
# test that language files are generated as expected
|
||||
hyphen-base = runCommand "texlive-test-hyphen-base" {
|
||||
hyphenBase = lib.head texlive.hyphen-base.pkgs;
|
||||
schemeFull = texlive.combined.scheme-full;
|
||||
schemeInfraOnly = texlive.combined.scheme-infraonly;
|
||||
} ''
|
||||
mkdir -p "$out"/{scheme-infraonly,scheme-full}
|
||||
|
||||
# create language files with no hyphenation patterns
|
||||
cat "$hyphenBase"/tex/generic/config/language.us >language.dat
|
||||
cat "$hyphenBase"/tex/generic/config/language.us.def >language.def
|
||||
cat "$hyphenBase"/tex/generic/config/language.us.lua >language.dat.lua
|
||||
|
||||
cat >>language.dat.lua <<EOF
|
||||
}
|
||||
EOF
|
||||
|
||||
cat >>language.def <<EOF
|
||||
%%% No changes may be made beyond this point.
|
||||
|
||||
\uselanguage {USenglish} %%% This MUST be the last line of the file.
|
||||
EOF
|
||||
|
||||
for fname in language.{dat,def,dat.lua} ; do
|
||||
diff --ignore-matching-lines='^\(%\|--\) Generated by ' -u \
|
||||
{"$hyphenBase","$schemeFull"/share/texmf}/tex/generic/config/"$fname" \
|
||||
| tee "$out/scheme-full/$fname.patch"
|
||||
diff --ignore-matching-lines='^\(%\|--\) Generated by ' -u \
|
||||
{,"$schemeInfraOnly"/share/texmf/tex/generic/config/}"$fname" \
|
||||
| tee "$out/scheme-infraonly/$fname.patch"
|
||||
done
|
||||
'';
|
||||
|
||||
# test that fmtutil.cnf is fully regenerated on scheme-full
|
||||
fmtutilCnf = runCommand "texlive-test-fmtutil.cnf" {
|
||||
kpathsea = lib.head texlive.kpathsea.pkgs;
|
||||
schemeFull = texlive.combined.scheme-full;
|
||||
} ''
|
||||
mkdir -p "$out"
|
||||
|
||||
diff --ignore-matching-lines='^# Generated by ' -u \
|
||||
{"$kpathsea","$schemeFull"/share/texmf}/web2c/fmtutil.cnf \
|
||||
| tee "$out/fmtutil.cnf.patch"
|
||||
'';
|
||||
}
|
||||
63
pkgs/test/vim/default.nix
Normal file
63
pkgs/test/vim/default.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{ vimUtils, vim_configurable, writeText, vimPlugins
|
||||
, lib, fetchFromGitHub
|
||||
, pkgs
|
||||
}:
|
||||
let
|
||||
inherit (vimUtils) buildVimPluginFrom2Nix;
|
||||
|
||||
packages.myVimPackage.start = with vimPlugins; [ vim-nix ];
|
||||
|
||||
in
|
||||
pkgs.recurseIntoAttrs (rec {
|
||||
vim_empty_config = vimUtils.vimrcFile { beforePlugins = ""; customRC = ""; };
|
||||
|
||||
### vim tests
|
||||
##################
|
||||
vim_with_vim2nix = vim_configurable.customize {
|
||||
name = "vim"; vimrcConfig.vam.pluginDictionaries = [ "vim2nix" ];
|
||||
};
|
||||
|
||||
# test cases:
|
||||
test_vim_with_vim_nix_using_vam = vim_configurable.customize {
|
||||
name = "vim-with-vim-addon-nix-using-vam";
|
||||
vimrcConfig.vam.pluginDictionaries = [{name = "vim-nix"; }];
|
||||
};
|
||||
|
||||
test_vim_with_vim_nix_using_pathogen = vim_configurable.customize {
|
||||
name = "vim-with-vim-addon-nix-using-pathogen";
|
||||
vimrcConfig.pathogen.pluginNames = [ "vim-nix" ];
|
||||
};
|
||||
|
||||
test_vim_with_vim_nix_using_plug = vim_configurable.customize {
|
||||
name = "vim-with-vim-addon-nix-using-plug";
|
||||
vimrcConfig.plug.plugins = with vimPlugins; [ vim-nix ];
|
||||
};
|
||||
|
||||
test_vim_with_vim_nix = vim_configurable.customize {
|
||||
name = "vim-with-vim-addon-nix";
|
||||
vimrcConfig.packages.myVimPackage.start = with vimPlugins; [ vim-nix ];
|
||||
};
|
||||
|
||||
# regression test for https://github.com/NixOS/nixpkgs/issues/53112
|
||||
# The user may have specified their own plugins which may not be formatted
|
||||
# exactly as the generated ones. In particular, they may not have the `pname`
|
||||
# attribute.
|
||||
test_vim_with_custom_plugin = vim_configurable.customize {
|
||||
name = "vim_with_custom_plugin";
|
||||
vimrcConfig.vam.knownPlugins =
|
||||
vimPlugins // ({
|
||||
vim-trailing-whitespace = buildVimPluginFrom2Nix {
|
||||
name = "vim-trailing-whitespace";
|
||||
src = fetchFromGitHub {
|
||||
owner = "bronson";
|
||||
repo = "vim-trailing-whitespace";
|
||||
rev = "4c596548216b7c19971f8fc94e38ef1a2b55fee6";
|
||||
sha256 = "0f1cpnp1nxb4i5hgymjn2yn3k1jwkqmlgw1g02sq270lavp2dzs9";
|
||||
};
|
||||
# make sure string dependencies are handled
|
||||
dependencies = [ "vim-nix" ];
|
||||
};
|
||||
});
|
||||
vimrcConfig.vam.pluginDictionaries = [ { names = [ "vim-trailing-whitespace" ]; } ];
|
||||
};
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue