Files
nix/tests/functional/flakes/get-flake.sh
Eelco Dolstra 6992698ac5 builtins.getFlake: Support path values
This allows doing `builtins.getFlake ./subflake` instead of ugly hacks.
2026-02-18 22:12:09 +01:00

27 lines
670 B
Bash

#!/usr/bin/env bash
source ./common.sh
createFlake1
mkdir -p "$flake1Dir/subflake"
cat > "$flake1Dir/subflake/flake.nix" <<EOF
{
outputs = { self }:
let
# Bad, legacy way of getting a flake from an input.
parentFlake = builtins.getFlake (builtins.flakeRefToString { type = "path"; path = self.sourceInfo.outPath; narHash = self.narHash; });
# Better way using a path value.
parentFlake2 = builtins.getFlake ./..;
in {
x = parentFlake.number;
y = parentFlake2.number;
};
}
EOF
git -C "$flake1Dir" add subflake/flake.nix
[[ $(nix eval "$flake1Dir/subflake#x") = 123 ]]
[[ $(nix eval "$flake1Dir/subflake#y") = 123 ]]