push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1 @@
Just some text

View File

@@ -0,0 +1,147 @@
{
lib,
stdenvNoCC,
testers,
callPackage,
writeText,
# nativeBuildInputs
shellcheck-minimal,
# Samples
samples ? cleanSamples (callPackage ./samples.nix { }),
# Filter out the non-string-like attributes such as <pkg>.override added by
# callPackage.
cleanSamples ? lib.filterAttrs (n: lib.isStringLike),
# Test targets
writeDirectReferencesToFile,
writeClosure,
}:
# -------------------------------------------------------------------------- #
#
# trivial-builders test
#
# -------------------------------------------------------------------------- #
#
# Execute this build script directly (quick):
#
# * Classic
# $ NIX_PATH="nixpkgs=$PWD" nix-shell -p tests.trivial-builders.references.testScriptBin --run references-test
#
# * Flake-based
# $ nix run .#tests.trivial-builders.references.testScriptBin
#
# or in the build sandbox with a ~20s VM overhead:
#
# * Classic
# $ nix-build --no-out-link -A tests.trivial-builders.references
#
# * Flake-based
# $ nix build -L --no-link .#tests.trivial-builders.references
#
# -------------------------------------------------------------------------- #
let
# Map each attribute to an element specification of Bash associative array
# and concatenate them with white spaces, to be used to define a
# one-line Bash associative array.
samplesToString =
attrs:
lib.concatMapStringsSep " " (name: "[${name}]=${lib.escapeShellArg "${attrs.${name}}"}") (
builtins.attrNames attrs
);
closures = lib.mapAttrs (n: v: writeClosure [ v ]) samples;
directReferences = lib.mapAttrs (n: v: writeDirectReferencesToFile v) samples;
collectiveClosure = writeClosure (lib.attrValues samples);
testScriptBin = stdenvNoCC.mkDerivation (finalAttrs: {
name = "references-test";
src = ./references-test.sh;
dontUnpack = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p "$out/bin"
substitute "$src" "$out/bin/${finalAttrs.meta.mainProgram}" \
--replace "@SAMPLES@" ${lib.escapeShellArg (samplesToString samples)} \
--replace "@CLOSURES@" ${lib.escapeShellArg (samplesToString closures)} \
--replace "@DIRECT_REFS@" ${lib.escapeShellArg (samplesToString directReferences)} \
--replace "@COLLECTIVE_CLOSURE@" ${lib.escapeShellArg collectiveClosure}
runHook postInstall
chmod +x "$out/bin/${finalAttrs.meta.mainProgram}"
'';
doInstallCheck = true;
nativeInstallCheckInputs = [
shellcheck-minimal
];
installCheckPhase = ''
runHook preInstallCheck
shellcheck "$out/bin/${finalAttrs.meta.mainProgram}"
runHook postInstallCheck
'';
passthru = {
inherit
collectiveClosure
directReferences
closures
samples
;
};
meta = {
mainProgram = "references-test";
};
});
in
testers.runNixOSTest (
{ config, lib, ... }:
let
# Use the testScriptBin from guest pkgs.
# The attribute path to access the guest version of testScriptBin is
# tests.trivial-builders.references.config.node.pkgs.tests.trivial-builders.references.testScriptBin
# which is why passthru.guestTestScriptBin is provided.
guestTestScriptBin = config.node.pkgs.tests.trivial-builders.references.testScriptBin;
in
{
name = "nixpkgs-trivial-builders-references";
nodes.machine =
{
config,
lib,
pkgs,
...
}:
{
virtualisation.writableStore = true;
# Test runs without network, so we don't substitute and prepare our deps
nix.settings.substituters = lib.mkForce [ ];
system.extraDependencies = [ guestTestScriptBin ];
};
testScript = ''
machine.succeed("""
${lib.getExe guestTestScriptBin} 2>/dev/console
""")
'';
passthru = {
inherit
collectiveClosure
directReferences
closures
samples
testScriptBin
;
inherit guestTestScriptBin;
};
meta = {
maintainers = with lib.maintainers; [
roberth
ShamrockLee
];
};
}
)

View File

@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# -------------------------------------------------------------------------- #
#
# trivial-builders test
#
# -------------------------------------------------------------------------- #
#
# Execute this build script directly (quick):
#
# * Classic
# $ NIX_PATH="nixpkgs=$PWD" nix-shell -p tests.trivial-builders.references.testScriptBin --run references-test
#
# * Flake-based
# $ nix run .#tests.trivial-builders.references.testScriptBin
#
# or in the build sandbox with a ~20s VM overhead:
#
# * Classic
# $ nix-build --no-out-link -A tests.trivial-builders.references
#
# * Flake-based
# $ nix build -L --no-link .#tests.trivial-builders.references
#
# -------------------------------------------------------------------------- #
# strict bash
set -euo pipefail
# debug
# set -x
# PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
cd "$(dirname "${BASH_SOURCE[0]}")" # nixpkgs root
# Inject the path to compare from the Nix expression
# Associative Arrays
declare -A samples=( @SAMPLES@ )
declare -A directRefs=( @DIRECT_REFS@ )
declare -A closures=( @CLOSURES@ )
# Path string
collectiveClosure=@COLLECTIVE_CLOSURE@
echo >&2 Testing direct closures...
for i in "${!samples[@]}"; do
echo >&2 Checking "$i" "${samples[$i]}" "${directRefs[$i]}"
diff -U3 \
<(sort <"${directRefs[$i]}") \
<(nix-store -q --references "${samples[$i]}" | sort)
done
echo >&2 Testing closure...
for i in "${!samples[@]}"; do
echo >&2 Checking "$i" "${samples[$i]}" "${closures[$i]}"
diff -U3 \
<(sort <"${closures[$i]}") \
<(nix-store -q --requisites "${samples[$i]}" | sort)
done
echo >&2 Testing mixed closures...
echo >&2 Checking all samples "(${samples[*]})" "$collectiveClosure"
diff -U3 \
<(sort <"$collectiveClosure") \
<(nix-store -q --requisites "${samples[@]}" | sort)
echo 'OK!'

View File

@@ -0,0 +1,31 @@
{
lib,
runCommand,
writeText,
emptyFile,
emptyDirectory,
figlet,
hello,
zlib,
}:
{
inherit
figlet
hello
zlib
;
zlib-dev = zlib.dev;
norefs = writeText "hi" "hello";
norefsDup = writeText "hi" "hello";
helloRef = writeText "hi" "hello ${hello}";
helloRefDup = writeText "hi" "hello ${hello}";
path = ./apath.txt;
pathLike.outPath = ./apath.txt;
helloFigletRef = writeText "hi" "hello ${hello} ${figlet}";
selfRef = runCommand "self-ref-1" { } "echo $out >$out";
selfRef2 = runCommand "self-ref-2" { } ''echo "${figlet}, $out" >$out'';
inherit
emptyFile
emptyDirectory
;
}