depot/third_party/nixpkgs/pkgs/build-support/trivial-builders/test/writeStringReferencesToFile.nix
Default email ce641f4048 Project import generated by Copybara.
GitOrigin-RevId: bc5d68306b40b8522ffb69ba6cff91898c2fbbff
2021-12-06 17:07:01 +01:00

18 lines
680 B
Nix

{ callPackage, lib, pkgs, runCommand, writeText, writeStringReferencesToFile }:
let
sample = import ./sample.nix { inherit pkgs; };
samplePaths = lib.unique (lib.attrValues sample);
stri = x: "${x}";
sampleText = writeText "sample-text" (lib.concatStringsSep "\n" (lib.unique (map stri samplePaths)));
stringReferencesText =
writeStringReferencesToFile
((lib.concatMapStringsSep "fillertext"
stri
(lib.attrValues sample)) + ''
STORE=${builtins.storeDir};\nsystemctl start bar-foo.service
'');
in
runCommand "test-writeStringReferencesToFile" { } ''
diff -U3 <(sort ${stringReferencesText}) <(sort ${sampleText})
touch $out
''