Skip to content

Commit eef4013

Browse files
fix(flake-info): tighten home-manager flake detection (#1235)
Detecting home-manager flakes by `modules/modules.nix` alone produced false positives for unrelated flakes that happen to ship a similarly named file (e.g. `nix-bitcoin`). Once a non-HM flake matched, the subsequent `import` of `modules/lib/stdlib-extended.nix` aborted the whole evaluation, so packages and options for those flakes also failed to index. Also require `modules/lib/stdlib-extended.nix` to be present, which is specific to home-manager and is the helper `readHomeManagerOptions` already imports. Refs #1234
1 parent b11c65c commit eef4013

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

flake-info/assets/commands/flake_info.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,17 @@ rec {
518518
options = readFlakeOptions;
519519
home-manager-options =
520520
let
521-
hasHmModules = builtins.tryEval (builtins.pathExists "${resolved}/modules/modules.nix");
521+
# Require both `modules/modules.nix` and `modules/lib/stdlib-extended.nix`
522+
# to avoid false positives. Other flakes (e.g. `nix-bitcoin`) ship a
523+
# `modules/modules.nix` that is unrelated to home-manager; only
524+
# home-manager itself also provides the `stdlib-extended.nix` helper
525+
# that `readHomeManagerOptions` imports.
526+
isHomeManager = builtins.tryEval (
527+
builtins.pathExists "${resolved}/modules/modules.nix"
528+
&& builtins.pathExists "${resolved}/modules/lib/stdlib-extended.nix"
529+
);
522530
in
523-
if hasHmModules.success && hasHmModules.value then readHomeManagerOptions else [ ];
531+
if isHomeManager.success && isHomeManager.value then readHomeManagerOptions else [ ];
524532
all = packages ++ apps ++ options ++ home-manager-options;
525533

526534
nixos-options = builtins.filter (opt: !(isServiceOption opt)) nixpkgsAllOpts;

0 commit comments

Comments
 (0)