lib.options.mkPackageOption: use lib.showAttrPath

Make use of `lib.showAttrPath` instead of manually doing `concatStringsSep "."`.

This means edge-cases such as the attr-path including names that are not
valid nix identifiers will be handled better.

See:
- https://nix.dev/manual/nix/2.26/language/identifiers
- https://nixos.org/manual/nixpkgs/unstable/#function-library-lib.attrsets.showAttrPath
This commit is contained in:
Matt Sturgeon
2025-04-12 05:56:30 +01:00
parent 4c26f96059
commit 6107d48bcb
3 changed files with 23 additions and 4 deletions

View File

@@ -57,5 +57,19 @@ in
};
in
lib.mkPackageOption myPkgs "hello" { };
packageInvalidIdentifier =
let
myPkgs."123"."with\"quote" = { inherit (pkgs) hello; };
in
lib.mkPackageOption myPkgs [ "123" "with\"quote" "hello" ] { };
packageInvalidIdentifierExample = lib.mkPackageOption pkgs "hello" {
example = [
"123"
"with\"quote"
"hello"
];
};
};
}