79a1e9d729
Define package `testScriptBin` that contains the substituted test script. * Add an `installCheckPhase` to check the result script with ShellCheck. * Passthru as `references.testScriptBin` to run the (substituted) test script directly (without VM). * Drop the logic in build script that detects if it is run in the Nix sandbox. * Inline sample application; drop invoke-*.nix. Format expressions. * Format with `nixpkgs-fmt`. * Use multi-line style of set patterns. Call the samples with `callPackage`. * Rename `sample` -> `samples`. * Take individual packages / build helpers directly from the set pattern. * Define `cleanSamples` to filter out overriders such as `<pkg>.override`. added by `callPackage`. Passthru samples and invocation results for easier debugging. * Passthru samples, references, directReferences * Provide tests.trivial-builders.writeStringReferencesToFile with such samples argument.
17 lines
641 B
Nix
17 lines
641 B
Nix
{ callPackage, lib, pkgs, runCommand, samples, writeText, writeStringReferencesToFile }:
|
|
let
|
|
samplePaths = lib.unique (lib.attrValues samples);
|
|
stri = x: "${x}";
|
|
sampleText = writeText "sample-text" (lib.concatStringsSep "\n" (lib.unique (map stri samplePaths)));
|
|
stringReferencesText =
|
|
writeStringReferencesToFile
|
|
((lib.concatMapStringsSep "fillertext"
|
|
stri
|
|
(lib.attrValues samples)) + ''
|
|
STORE=${builtins.storeDir};\nsystemctl start bar-foo.service
|
|
'');
|
|
in
|
|
runCommand "test-writeStringReferencesToFile" { } ''
|
|
diff -U3 <(sort ${stringReferencesText}) <(sort ${sampleText})
|
|
touch $out
|
|
''
|