clan_lib flake: get select output without nixpkgs

This commit is contained in:
lassulus
2025-05-19 15:28:42 +02:00
parent 8218bd3539
commit 9685e00122

View File

@@ -744,16 +744,35 @@ class Flake:
) )
select_hash = select_flake.hash select_hash = select_flake.hash
# fmt: off
nix_code = f""" nix_code = f"""
let let
flake = builtins.getFlake "path:{self.store_path}?narHash={self.hash}"; flake = builtins.getFlake "path:{self.store_path}?narHash={self.hash}";
selectLib = (builtins.getFlake "path:{select_source()}?narHash={select_hash}").lib; selectLib = (
nixpkgs = flake.inputs.nixpkgs or (builtins.getFlake "path:{nixpkgs_source()}?narHash={fallback_nixpkgs_hash}"); builtins.getFlake
"path:{select_source()}?narHash={select_hash}"
).lib;
in in
nixpkgs.legacyPackages.{config["system"]}.writeText "clan-flake-select" ( derivation {{
builtins.toJSON [ {" ".join([f"(selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake)" for attr in str_selectors])} ] name = "clan-flake-select";
) system = "{config["system"]}";
builder = "/bin/sh";
args = [
"-c"
''
printf %s '${{builtins.toJSON [
{" ".join(
[
f"(selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake)"
for attr in str_selectors
]
)}
]}}' > $out
''
];
}}
""" """
# fmt: on
if tmp_store := nix_test_store(): if tmp_store := nix_test_store():
nix_options += ["--store", str(tmp_store)] nix_options += ["--store", str(tmp_store)]
nix_options.append("--impure") nix_options.append("--impure")