-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This implements the `fallback-paths.nix` format in NixOS
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ lib, formats, nix, packages, stdenv, ... }: | ||
|
||
let | ||
randomPick = packages."x86_64-linux"; | ||
packages1 = { inherit (packages) x86_64-linux aarch64-darwin; }; | ||
in | ||
let packages = packages1; in | ||
stdenv.mkDerivation { | ||
version = randomPick.version; | ||
pname = "nix-all-output-paths"; | ||
passAsFile = [ "content" ]; | ||
nativeBuildInputs = [ nix ]; | ||
json = (formats.json {}).generate "all-output-paths.json" (lib.mapAttrs (name: pkg: "${lib.getBin pkg}") packages); | ||
nix = '' | ||
{ | ||
${ | ||
lib.concatStringsSep "\n " ( | ||
lib.mapAttrsToList | ||
(name: pkg: "${lib.strings.escapeNixIdentifier name} = ${lib.strings.escapeNixString "${lib.getBin pkg}"};") | ||
packages | ||
) | ||
} | ||
} | ||
''; | ||
buildCommand = '' | ||
mkdir -p $out | ||
cp $json $out/all-output-paths.json | ||
echo "$nix" > $out/all-output-paths.nix | ||
mkdir -p $out/nix-support | ||
{ | ||
echo "file all-output-paths $out/all-output-paths.json" | ||
echo "file all-output-paths-nix-deprecated $out/all-output-paths.nix" | ||
} >> $out/nix-support/hydra-build-products | ||
r=$(nix-instantiate --store dummy:// --expr --eval --json \ | ||
'builtins.fromJSON (builtins.readFile '$out'/all-output-paths.json) == import '$out'/all-output-paths.nix') | ||
if ! [[ $r == "true" ]]; then | ||
echo "The generated Nix file does not match the JSON file" | ||
echo "Nix file: $out/all-output-paths.nix" | ||
cat -n $out/all-output-paths.nix | ||
echo "JSON file: $out/all-output-paths.json" | ||
cat -n $out/all-output-paths.json | ||
exit 1 | ||
fi | ||
''; | ||
meta = { | ||
description = "A lookup file that gives a store path containing the Nix package manager for all supported system types"; | ||
}; | ||
} |