Skip to content

Instantly share code, notes, and snippets.

@Pandapip1
Created October 27, 2025 08:40
Show Gist options
  • Save Pandapip1/e63393311646a837393fb613b63ece3f to your computer and use it in GitHub Desktop.
Save Pandapip1/e63393311646a837393fb613b63ece3f to your computer and use it in GitHub Desktop.
Check bootstrap
{ pkgs }:
let
# Recursively collect derivations safely, skipping anything that throws
collectDerivationsSafe = root:
let
processQueue = values: seen:
if values == [] then [] else
let
head = builtins.head values;
tail = builtins.tail values;
res = builtins.tryEval head;
val = if res.success then res.value else null;
key = builtins.toString head;
alreadySeen = builtins.elem key seen;
nextSeen = if alreadySeen then seen else seen ++ [key];
# flatten derivations / attr sets / lists safely
nextValues =
if alreadySeen || val == null then []
else if pkgs.lib.isDerivation val then [ val ]
else if builtins.isAttrs val then
builtins.concatLists (
builtins.map (v:
let r = builtins.tryEval v; in
if r.success then [ r.value ] else []
) (builtins.attrValues val)
)
else if builtins.isList val then
builtins.concatLists (
builtins.map (v:
let r = builtins.tryEval v; in
if r.success then [ r.value ] else []
) val
)
else [];
in
nextValues ++ processQueue tail nextSeen;
in
processQueue [root] [];
allDerivations = collectDerivationsSafe pkgs;
# Check if a derivation is binaryNativeCode
isBinaryNative = drv:
if !pkgs.lib.isDerivation drv then false
else let
sp = ((drv.meta or {}).sourceProvenance or []);
spList = if builtins.isList sp then sp else [ sp ];
in
builtins.elem pkgs.lib.sourceTypes.binaryNativeCode spList;
# Filter derivations: binaryNativeCode and free
filtered = builtins.filter (drv:
drv != null &&
pkgs.lib.isDerivation drv &&
isBinaryNative drv &&
(
let license = (drv.meta or {}).license or null; in
license == null || (license.free or true)
)
) allDerivations;
in
builtins.map (drv: drv.outPath) filtered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment