From 9685e001223cf3cf413e98c1e80b913b9494552e Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 19 May 2025 15:28:42 +0200 Subject: [PATCH] clan_lib flake: get select output without nixpkgs --- pkgs/clan-cli/clan_lib/flake/flake.py | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/pkgs/clan-cli/clan_lib/flake/flake.py b/pkgs/clan-cli/clan_lib/flake/flake.py index ead91889d..839688198 100644 --- a/pkgs/clan-cli/clan_lib/flake/flake.py +++ b/pkgs/clan-cli/clan_lib/flake/flake.py @@ -744,16 +744,35 @@ class Flake: ) select_hash = select_flake.hash + # fmt: off nix_code = f""" let flake = builtins.getFlake "path:{self.store_path}?narHash={self.hash}"; - selectLib = (builtins.getFlake "path:{select_source()}?narHash={select_hash}").lib; - nixpkgs = flake.inputs.nixpkgs or (builtins.getFlake "path:{nixpkgs_source()}?narHash={fallback_nixpkgs_hash}"); + selectLib = ( + builtins.getFlake + "path:{select_source()}?narHash={select_hash}" + ).lib; in - nixpkgs.legacyPackages.{config["system"]}.writeText "clan-flake-select" ( - builtins.toJSON [ {" ".join([f"(selectLib.applySelectors (builtins.fromJSON ''{attr}'') flake)" for attr in str_selectors])} ] - ) + derivation {{ + 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(): nix_options += ["--store", str(tmp_store)] nix_options.append("--impure")