mirror of
https://github.com/NixOS/nix.git
synced 2025-11-12 13:36:02 +01:00
Add nix-all-output-paths
This implements the `fallback-paths.nix` format in NixOS
This commit is contained in:
parent
ca3fc1693b
commit
7bd3f3b324
2 changed files with 52 additions and 0 deletions
|
|
@ -223,6 +223,10 @@
|
|||
default = self.packages.${system}.nix-ng;
|
||||
nix-internal-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-internal-api-docs;
|
||||
nix-external-api-docs = nixpkgsFor.${system}.native.nixComponents.nix-external-api-docs;
|
||||
nix-all-output-paths = nixpkgsFor.${system}.native.callPackage ./packaging/nix-all-output-paths.nix {
|
||||
packages =
|
||||
lib.mapAttrs (system: packages: packages.nix) self.packages;
|
||||
};
|
||||
}
|
||||
# We need to flatten recursive attribute sets of derivations to pass `flake check`.
|
||||
// flatMapAttrs
|
||||
|
|
|
|||
48
packaging/nix-all-output-paths.nix
Normal file
48
packaging/nix-all-output-paths.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{ lib, formats, nix, packages, stdenv, ... }:
|
||||
|
||||
let
|
||||
randomPick = packages."x86_64-linux";
|
||||
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";
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue