aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/test
diff options
context:
space:
mode:
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/test')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cc-main.c7
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cflags-main.c10
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/core-foundation-main.c7
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cxx-main.cc7
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/default.nix66
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/foo.c4
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/ldflags-main.c12
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/multilib.nix37
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/nostdinc-main.c8
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/sanitizers.c8
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/stdio.h1
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/cross/default.nix113
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/default.nix50
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/haskell-documentationTarball/default.nix17
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/haskell-shellFor/default.nix33
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/install-shell-files/default.nix125
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/kernel.nix79
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/ld-library-path/default.nix88
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/macos-sierra-shared/default.nix90
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/mkOption/declare.nix53
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/mkOption/keep.nix11
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/mkOption/keep.ref57
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/mkOption/merge.nix15
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/mkOption/merge.ref20
-rwxr-xr-xinfra/libkookie/nixpkgs/pkgs/test/mkOption/test.sh9
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/nixos-functions/default.nix41
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/patch-shebangs/default.nix26
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/rust-sysroot/default.nix60
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/simple/builder.sh42
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/bar.c3
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/cc-main.c7
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/default.nix68
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/foo.c3
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/include-main.c13
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/lib-main.c14
-rw-r--r--infra/libkookie/nixpkgs/pkgs/test/texlive/default.nix66
36 files changed, 1270 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cc-main.c b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cc-main.c
new file mode 100644
index 000000000000..06f28bc33c69
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cc-main.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ fprintf(stderr, "ok\n");
+ return 0;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cflags-main.c b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cflags-main.c
new file mode 100644
index 000000000000..9491232b5387
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cflags-main.c
@@ -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;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/core-foundation-main.c b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/core-foundation-main.c
new file mode 100644
index 000000000000..fb3bd3126191
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/core-foundation-main.c
@@ -0,0 +1,7 @@
+#include <CoreFoundation/CoreFoundation.h>
+
+int main(int argc, char** argv)
+{
+ CFShow(CFSTR("ok"));
+ return 0;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cxx-main.cc b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cxx-main.cc
new file mode 100644
index 000000000000..83f704617a46
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/cxx-main.cc
@@ -0,0 +1,7 @@
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+ std::cerr << "ok" << std::endl;
+ return 0;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/default.nix b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/default.nix
new file mode 100644
index 000000000000..c0c89d63ffff
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/default.nix
@@ -0,0 +1,66 @@
+{ stdenv }:
+with stdenv.lib;
+let
+ # Sanitizers are not supported on Darwin.
+ # Sanitizer headers aren't available in older libc++ stdenvs due to a bug
+ sanitizersWorking =
+ (stdenv.cc.isClang && versionAtLeast (getVersion stdenv.cc.name) "5.0.0")
+ || (stdenv.cc.isGNU && stdenv.isLinux);
+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
+
+ ${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
+ ''}
+
+ 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 \
+ ${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++
+
+ ${optionalString sanitizersWorking ''
+ printf "checking whether sanitizers are fully functional... ">&2
+ $CC -o sanitizers -fsanitize=address,undefined ${./sanitizers.c}
+ ./sanitizers
+ ''}
+
+ touch $out
+ '';
+
+ meta.platforms = platforms.all;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/foo.c b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/foo.c
new file mode 100644
index 000000000000..8be674be3103
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/foo.c
@@ -0,0 +1,4 @@
+unsigned int foo(void)
+{
+ return VALUE;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/ldflags-main.c b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/ldflags-main.c
new file mode 100644
index 000000000000..89832b3bbad2
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/ldflags-main.c
@@ -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;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/multilib.nix b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/multilib.nix
new file mode 100644
index 000000000000..5ea50b5eb268
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/multilib.nix
@@ -0,0 +1,37 @@
+{ 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 = stdenv.lib.platforms.x86_64;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/nostdinc-main.c b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/nostdinc-main.c
new file mode 100644
index 000000000000..f71d155b1b27
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/nostdinc-main.c
@@ -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;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/sanitizers.c b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/sanitizers.c
new file mode 100644
index 000000000000..93dd78a903ce
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/sanitizers.c
@@ -0,0 +1,8 @@
+#include <sanitizer/asan_interface.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ fprintf(stderr, "ok\n");
+ return 0;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/stdio.h b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/stdio.h
new file mode 100644
index 000000000000..4bddf1d9d486
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cc-wrapper/stdio.h
@@ -0,0 +1 @@
+static void foo(void) {}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/cross/default.nix b/infra/libkookie/nixpkgs/pkgs/test/cross/default.nix
new file mode 100644
index 000000000000..c5a241437732
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/cross/default.nix
@@ -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);
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/default.nix b/infra/libkookie/nixpkgs/pkgs/test/default.nix
new file mode 100644
index 000000000000..8746f065b1bf
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/default.nix
@@ -0,0 +1,50 @@
+{ 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 { };
+
+ haskell-shellFor = callPackage ./haskell-shellFor { };
+ haskell-documentationTarball = callPackage ./haskell-documentationTarball { };
+
+ cc-multilib-gcc = callPackage ./cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; };
+ cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
+
+ 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 {};
+
+ rustCustomSysroot = callPackage ./rust-sysroot {};
+
+ nixos-functions = callPackage ./nixos-functions {};
+
+ patch-shebangs = callPackage ./patch-shebangs {};
+
+ texlive = callPackage ./texlive {};
+
+ writers = callPackage ../build-support/writers/test.nix {};
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/haskell-documentationTarball/default.nix b/infra/libkookie/nixpkgs/pkgs/test/haskell-documentationTarball/default.nix
new file mode 100644
index 000000000000..aec3dc41f268
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/haskell-documentationTarball/default.nix
@@ -0,0 +1,17 @@
+{ pkgs, haskellPackages }:
+
+let
+ drv = haskellPackages.vector;
+ docs = pkgs.haskell.lib.documentationTarball drv;
+
+in pkgs.runCommand "test haskell.lib.documentationTarball" { } ''
+ 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"
+''
diff --git a/infra/libkookie/nixpkgs/pkgs/test/haskell-shellFor/default.nix b/infra/libkookie/nixpkgs/pkgs/test/haskell-shellFor/default.nix
new file mode 100644
index 000000000000..05d09d6f39cf
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/haskell-shellFor/default.nix
@@ -0,0 +1,33 @@
+{ lib, stdenv, haskellPackages, cabal-install }:
+
+(haskellPackages.shellFor {
+ packages = p: [ p.database-id-class p.constraints ];
+ nativeBuildInputs = [ cabal-install ];
+ phases = [ "unpackPhase" "buildPhase" "installPhase" ];
+ unpackPhase = ''
+ sourceRoot=$(pwd)/scratch
+ mkdir -p "$sourceRoot"
+ cd "$sourceRoot"
+ tar -xf ${haskellPackages.database-id-class.src}
+ tar -xf ${haskellPackages.constraints.src}
+ cp ${builtins.toFile "cabal.project" "packages: database-id-class* constraints*"} cabal.project
+ '';
+ buildPhase = ''
+ export HOME=$(mktemp -d)
+ mkdir -p $HOME/.cabal
+ touch $HOME/.cabal/config
+ cabal v2-build --offline --verbose database-id-class constraints --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; };
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/test/install-shell-files/default.nix b/infra/libkookie/nixpkgs/pkgs/test/install-shell-files/default.nix
new file mode 100644
index 000000000000..e3729c7d2504
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/install-shell-files/default.nix
@@ -0,0 +1,125 @@
+{ stdenv, runCommandLocal, recurseIntoAttrs, installShellFiles }:
+
+let
+ runTest = name: env: buildCommand:
+ runCommandLocal "install-shell-files--${name}" ({
+ nativeBuildInputs = [ installShellFiles ];
+ meta.platforms = stdenv.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; }
+ '';
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/kernel.nix b/infra/libkookie/nixpkgs/pkgs/test/kernel.nix
new file mode 100644
index 000000000000..a4da10030332
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/kernel.nix
@@ -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;
+ };
+
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/ld-library-path/default.nix b/infra/libkookie/nixpkgs/pkgs/test/ld-library-path/default.nix
new file mode 100644
index 000000000000..bda3f0be84a6
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/ld-library-path/default.nix
@@ -0,0 +1,88 @@
+{ 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 = stdenv.lib.platforms.linux;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/macos-sierra-shared/default.nix b/infra/libkookie/nixpkgs/pkgs/test/macos-sierra-shared/default.nix
new file mode 100644
index 000000000000..810d5d97829b
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/macos-sierra-shared/default.nix
@@ -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;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/mkOption/declare.nix b/infra/libkookie/nixpkgs/pkgs/test/mkOption/declare.nix
new file mode 100644
index 000000000000..9e89a1c096da
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/mkOption/declare.nix
@@ -0,0 +1,53 @@
+# sets of small configurations:
+# Each configuration
+rec {
+ # has 2 arguments pkgs and this.
+ configA = pkgs: this: {
+ # Can depends on other configuration
+ require = configB;
+
+ # Defines new options
+ optionA = pkgs.lib.mkOption {
+ # With default values
+ default = false;
+ # And merging functions.
+ merge = pkgs.lib.mergeEnableOption;
+ };
+
+ # Add a new definition to other options.
+ optionB = this.optionA;
+ };
+
+ # Can be used for option header.
+ configB = pkgs: this: {
+ # Can depends on more than one configuration.
+ require = [ configC configD ];
+
+ optionB = pkgs.lib.mkOption {
+ default = false;
+ };
+
+ # Is not obliged to define other options.
+ };
+
+ configC = pkgs: this: {
+ require = [ configA ];
+
+ optionC = pkgs.lib.mkOption {
+ default = false;
+ };
+
+ # Use the default value if it is not overwritten.
+ optionA = this.optionC;
+ };
+
+ # Can also be used as option configuration only.
+ # without any arguments (backward compatibility)
+ configD = {
+ # Is not forced to specify the require attribute.
+
+ # Is not force to make new options.
+ optionA = true;
+ optionD = false;
+ };
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/mkOption/keep.nix b/infra/libkookie/nixpkgs/pkgs/test/mkOption/keep.nix
new file mode 100644
index 000000000000..26fb8c28dd59
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/mkOption/keep.nix
@@ -0,0 +1,11 @@
+let
+ pkgs = import ../../.. {};
+ config = import ./declare.nix;
+in
+ with (pkgs.lib);
+
+ finalReferenceOptionSets
+ filterOptionSets
+ pkgs
+ # List of main configurations.
+ [ config.configB config.configC ]
diff --git a/infra/libkookie/nixpkgs/pkgs/test/mkOption/keep.ref b/infra/libkookie/nixpkgs/pkgs/test/mkOption/keep.ref
new file mode 100644
index 000000000000..a3a051eb48c4
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/mkOption/keep.ref
@@ -0,0 +1,57 @@
+<?xml version='1.0' encoding='utf-8'?>
+<expr>
+ <attrs>
+ <attr name="optionA">
+ <list>
+ <attrs>
+ <attr name="_type">
+ <string value="option" />
+ </attr>
+ <attr name="default">
+ <bool value="false" />
+ </attr>
+ <attr name="merge">
+ <unevaluated />
+ </attr>
+ <attr name="name">
+ <string value="optionA" />
+ </attr>
+ </attrs>
+ </list>
+ </attr>
+ <attr name="optionB">
+ <list>
+ <attrs>
+ <attr name="_type">
+ <string value="option" />
+ </attr>
+ <attr name="default">
+ <bool value="false" />
+ </attr>
+ <attr name="name">
+ <string value="optionB" />
+ </attr>
+ </attrs>
+ </list>
+ </attr>
+ <attr name="optionC">
+ <list>
+ <attrs>
+ <attr name="_type">
+ <string value="option" />
+ </attr>
+ <attr name="default">
+ <bool value="false" />
+ </attr>
+ <attr name="name">
+ <string value="optionC" />
+ </attr>
+ </attrs>
+ </list>
+ </attr>
+ <attr name="optionD">
+ <attrs>
+ </attrs>
+ </attr>
+ </attrs>
+</expr>
diff --git a/infra/libkookie/nixpkgs/pkgs/test/mkOption/merge.nix b/infra/libkookie/nixpkgs/pkgs/test/mkOption/merge.nix
new file mode 100644
index 000000000000..bbf68218aa09
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/mkOption/merge.nix
@@ -0,0 +1,15 @@
+let
+ pkgs = import ../../.. {};
+ config = import ./declare.nix;
+
+ # Define the handler of unbound options.
+ noOption = name: values:
+ builtins.trace "Attribute named '${name}' does not match any option declaration." values;
+in
+ with (pkgs.lib);
+
+ finalReferenceOptionSets
+ (mergeOptionSets noOption)
+ pkgs
+ # List of main configurations.
+ [ config.configB config.configC ]
diff --git a/infra/libkookie/nixpkgs/pkgs/test/mkOption/merge.ref b/infra/libkookie/nixpkgs/pkgs/test/mkOption/merge.ref
new file mode 100644
index 000000000000..6956f65dbbcc
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/mkOption/merge.ref
@@ -0,0 +1,20 @@
+trace: Str("Attribute named 'optionD' does not match any option declaration.",[])
+<?xml version='1.0' encoding='utf-8'?>
+<expr>
+ <attrs>
+ <attr name="optionA">
+ <bool value="true" />
+ </attr>
+ <attr name="optionB">
+ <bool value="true" />
+ </attr>
+ <attr name="optionC">
+ <bool value="false" />
+ </attr>
+ <attr name="optionD">
+ <list>
+ <bool value="false" />
+ </list>
+ </attr>
+ </attrs>
+</expr>
diff --git a/infra/libkookie/nixpkgs/pkgs/test/mkOption/test.sh b/infra/libkookie/nixpkgs/pkgs/test/mkOption/test.sh
new file mode 100755
index 000000000000..5478846d563f
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/mkOption/test.sh
@@ -0,0 +1,9 @@
+#! /bin/sh -e
+
+echo 1>&2 "Test: Merge of option bindings."
+nix-instantiate merge.nix --eval-only --strict --xml >& merge.out
+diff merge.ref merge.out
+
+echo 1>&2 "Test: Filter of option declarations."
+nix-instantiate keep.nix --eval-only --strict --xml >& keep.out
+diff keep.ref keep.out
diff --git a/infra/libkookie/nixpkgs/pkgs/test/nixos-functions/default.nix b/infra/libkookie/nixpkgs/pkgs/test/nixos-functions/default.nix
new file mode 100644
index 000000000000..6a4f3164f929
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/nixos-functions/default.nix
@@ -0,0 +1,41 @@
+/*
+
+This file is a test that makes sure that the `pkgs.nixos` and
+`pkgs.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";
+ }).toplevel;
+
+ nixosTest-test = pkgs.nixosTest ({ lib, pkgs, ... }: {
+ name = "nixosTest-test";
+ machine = { pkgs, ... }: {
+ system.nixos = dummyVersioning;
+ environment.systemPackages = [ pkgs.hello ];
+ };
+ testScript = ''
+ machine.succeed("hello")
+ '';
+ });
+
+ }
+)
diff --git a/infra/libkookie/nixpkgs/pkgs/test/patch-shebangs/default.nix b/infra/libkookie/nixpkgs/pkgs/test/patch-shebangs/default.nix
new file mode 100644
index 000000000000..3e68d96004f2
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/patch-shebangs/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, runCommand }:
+
+let
+ 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
+ '';
+ };
+in runCommand "patch-shebangs-test" {
+ passthru = { inherit bad-shebang; };
+ meta.platforms = stdenv.lib.platforms.all;
+} ''
+ printf "checking whether patchShebangs works properly... ">&2
+ if ! grep -q '^#!/bin/sh' ${bad-shebang}/bin/test; then
+ echo "yes" >&2
+ touch $out
+ else
+ echo "no" >&2
+ exit 1
+ fi
+''
diff --git a/infra/libkookie/nixpkgs/pkgs/test/rust-sysroot/default.nix b/infra/libkookie/nixpkgs/pkgs/test/rust-sysroot/default.nix
new file mode 100644
index 000000000000..3a786ad6f00b
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/rust-sysroot/default.nix
@@ -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 = "1cbcplgz28yxshyrp2krp1jphbrcqdw6wxx3rry91p7hiqyibd30";
+
+ 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);
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/simple/builder.sh b/infra/libkookie/nixpkgs/pkgs/test/simple/builder.sh
new file mode 100644
index 000000000000..65f7e4c11ba1
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/simple/builder.sh
@@ -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
diff --git a/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/bar.c b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/bar.c
new file mode 100644
index 000000000000..2d7299c2d462
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/bar.c
@@ -0,0 +1,3 @@
+unsigned int bar(void) {
+ return 42;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/cc-main.c b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/cc-main.c
new file mode 100644
index 000000000000..06f28bc33c69
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/cc-main.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ fprintf(stderr, "ok\n");
+ return 0;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/default.nix b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/default.nix
new file mode 100644
index 000000000000..4db10e75086e
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/default.nix
@@ -0,0 +1,68 @@
+{ 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 \
+ ${stdenv.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 \
+ ${stdenv.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 = stdenv.lib.platforms.all;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/foo.c b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/foo.c
new file mode 100644
index 000000000000..0253a26d5d2c
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/foo.c
@@ -0,0 +1,3 @@
+unsigned int foo(void) {
+ return 42;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/include-main.c b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/include-main.c
new file mode 100644
index 000000000000..35e5ee0d90f7
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/include-main.c
@@ -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;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/lib-main.c b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/lib-main.c
new file mode 100644
index 000000000000..c9488fe43e55
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/stdenv-inputs/lib-main.c
@@ -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;
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/test/texlive/default.nix b/infra/libkookie/nixpkgs/pkgs/test/texlive/default.nix
new file mode 100644
index 000000000000..30d0026c848d
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/test/texlive/default.nix
@@ -0,0 +1,66 @@
+{ runCommandNoCC, fetchurl, file, texlive }:
+
+{
+ chktex = runCommandNoCC "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"
+ '';
+
+ # https://github.com/NixOS/nixpkgs/issues/75605
+ dvipng = runCommandNoCC "texlive-test-dvipng" {
+ 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"/
+ '';
+
+ # https://github.com/NixOS/nixpkgs/issues/75070
+ dvisvgm = runCommandNoCC "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"/
+ '';
+}