Skip to content

Commit fec3654

Browse files
committed
fix: use a wildcard that doesn't match nested attrs
1 parent 3ab0c3f commit fec3654

File tree

6 files changed

+20
-15
lines changed

6 files changed

+20
-15
lines changed

by-name-config.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# In the attrsets that make up by_name_dirs:
55
# * The aliases_path field is optional.
66
# * The ID field must be short and unique.
7-
# * Exactly one attr_path_regex must be a wildcard ("[^\\.]*").
7+
# * Exactly one attr_path_regex must be a wildcard ("^[^\\.]*$").
88
# * All non-wildcard attr_path_regexes must be mutually exclusive.
99
# * Exactly one unversioned_attr_prefix must be the empty string.
1010
# * All non-wildcard unversioned_attr_prefixes must be mutually exclusive.
@@ -14,22 +14,22 @@
1414
# {
1515
# id = "py";
1616
# path = "pkgs/development/python-modules/by-name";
17-
# attr_path_regex = "^(python3\\d*Packages|python3\\d*.pkgs)\\..*";
17+
# attr_path_regex = "^(python3\\d*Packages|python3\\d*.pkgs)\\..*$";
1818
# unversioned_attr_prefix = "python3Packages";
1919
# all_packages_path = "/pkgs/top-level/python-packages.nix";
2020
# aliases_path = "/pkgs/top-level/python-aliases.nix";
2121
# }
2222
{
2323
id = "tcl";
2424
path = "pkgs/development/tcl-modules/by-name";
25-
attr_path_regex = "^(tcl\\d*Packages)\\..*";
25+
attr_path_regex = "^(tcl\\d*Packages)\\..*$";
2626
unversioned_attr_prefix = "tclPackages";
2727
all_packages_path = "/pkgs/top-level/tcl-packages.nix";
2828
}
2929
{
3030
id = "main";
3131
path = "pkgs/by-name";
32-
attr_path_regex = "[^\\.]*";
32+
attr_path_regex = "^[^\\.]*$";
3333
unversioned_attr_prefix = "";
3434
all_packages_path = "/pkgs/top-level/all-packages.nix";
3535
aliases_path = "/pkgs/top-level/aliases.nix";

src/eval.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ let
111111
# Information on all attributes that are in a `by-name` directory.
112112
byNameAttrsForDir =
113113
byNameDir:
114-
pkgs.lib.foldl pkgs.lib.recursiveUpdate { } (
114+
pkgs.lib.mergeAttrsList (
115+
# pkgs.lib.foldl pkgs.lib.recursiveUpdate { } (
115116
map (
116117
package:
117118
let
@@ -141,7 +142,8 @@ let
141142
attrSetIsOrContainsDerivation =
142143
name: value:
143144
if (!((builtins.tryEval value).success) || !(builtins.isAttrs value)) then
144-
(builtins.trace "attrSetIsOrContainsDerivation: returning false for ${name}. tryEval is ${pkgs.lib.boolToString ((builtins.tryEval value).success)}, and isAttrs is ${pkgs.lib.boolToString (builtins.isAttrs value)}" false)
145+
false
146+
# (builtins.trace "attrSetIsOrContainsDerivation: returning false for ${name}. tryEval is ${pkgs.lib.boolToString ((builtins.tryEval value).success)}, and isAttrs is ${pkgs.lib.boolToString (builtins.isAttrs value)}" false)
145147
else
146148
(
147149
if pkgs.lib.isDerivation value then

src/eval.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ pub fn check_values(
261261
.into());
262262
}
263263

264-
println!("{}:{}: result (stderr): {}", file!(), line!(), std::str::from_utf8(result.stderr.as_slice()).unwrap());
265-
println!("{}:{}: result (stdout): {}", file!(), line!(), std::str::from_utf8(result.stdout.as_slice()).unwrap());
264+
// println!("{}:{}: result (stderr): {}", file!(), line!(), std::str::from_utf8(result.stderr.as_slice()).unwrap());
265+
// println!("{}:{}: result (stdout): {}", file!(), line!(), std::str::from_utf8(result.stdout.as_slice()).unwrap());
266266

267267
// Parse the resulting JSON value
268268
let attributes: Vec<(Vec<String>, Attribute)> = serde_json::from_slice(&result.stdout)
@@ -277,7 +277,7 @@ pub fn check_values(
277277
attributes
278278
.into_iter()
279279
.map(|(attribute_name, attribute_value)| {
280-
println!("{}:{}: attribute_name: {attribute_name:?}; attribute_value: {attribute_value:?}", file!(), line!());
280+
// println!("{}:{}: attribute_name: {attribute_name:?}; attribute_value: {attribute_value:?}", file!(), line!());
281281
let check_result = match attribute_value {
282282
Attribute::NonByName(non_by_name_attribute) => handle_non_by_name_attribute(
283283
nixpkgs_path,
@@ -303,7 +303,7 @@ pub fn check_values(
303303
elems
304304
.into_iter()
305305
.map(|(attribute_name, package)| {
306-
println!("{}:{}: attribute_name: {}, package: {package:?}", file!(), line!(), attribute_name.join("."));
306+
// println!("{}:{}: attribute_name: {}, package: {package:?}", file!(), line!(), attribute_name.join("."));
307307
(attribute_name.join("."), package)
308308
})
309309
.collect()
@@ -564,7 +564,10 @@ fn handle_non_by_name_attribute(
564564
let uses_by_name =
565565
// Only process attributes that could belong to the current by name directory.
566566
match structure::expected_by_name_dir_for_package(attribute_name, config) {
567-
None => {println!("{}:{}: attribute_name {attribute_name} has expected by-name dir None", file!(), line!()); NonApplicable},
567+
None => {
568+
// println!("{}:{}: attribute_name {attribute_name} has expected by-name dir None", file!(), line!());
569+
NonApplicable
570+
},
568571
// Some(by_name_dir) if by_name_dir.id != => {println!("{}:{}: attribute_name {attribute_name} has expected by-name dir Some({x}), which is not {}", file!(), line!(), by_name_dir.path); NonApplicable},
569572
Some(_) => {
570573
// This is a big ol' match on various properties of the attribute

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn process(
192192
main_nixpkgs: &Path,
193193
config: &Config,
194194
) -> Status {
195-
println!("{}:{}: base_nixpkgs {base_nixpkgs:?}, main_nixpkgs {main_nixpkgs:?}", file!(), line!());
195+
// println!("{}:{}: base_nixpkgs {base_nixpkgs:?}, main_nixpkgs {main_nixpkgs:?}", file!(), line!());
196196
let (base_result, main_result) = std::thread::scope(|s| {
197197
let base_thread = s.spawn(move || check_nixpkgs(base_nixpkgs, config));
198198
let main_thread = s.spawn(move || check_nixpkgs(main_nixpkgs, config));

src/problem/npv_162.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl fmt::Display for NewTopLevelPackageShouldBeByName {
2929
structure::expected_by_name_dir_for_package(package_name, config).unwrap().path;
3030
let relative_package_file =
3131
structure::relative_file_for_package(package_name, &by_name_path);
32-
println!("{}:{}: package_name {package_name}, by_name_path {by_name_path}, relative_package_file {relative_package_file}", file!(), line!());
32+
// println!("{}:{}: package_name {package_name}, by_name_path {by_name_path}, relative_package_file {relative_package_file}", file!(), line!());
3333
let call_package_arg = call_package_path
3434
.as_ref()
3535
.map_or_else(|| "...".into(), |path| format!("./{}", path));

src/structure.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ pub fn expected_by_name_dir_for_package(
147147
let dir1 = matching_dirs[0];
148148
let dir2 = matching_dirs[1];
149149
// println!("{}:{}: attr_name is {attr_name}, dirs are {dir1:?} and {dir2:?}", file!(), line!());
150-
if dir2.attr_path_regex.as_str() == "[^\\.]*" {
150+
if dir2.attr_path_regex.as_str() == "^[^\\.]*$" {
151151
Some(dir1.clone())
152-
} else if dir1.attr_path_regex.as_str() == "[^\\.]*" {
152+
} else if dir1.attr_path_regex.as_str() == "^[^\\.]*$" {
153153
Some(dir2.clone())
154154
} else {
155155
panic!("Multiple wildcard regexes, or overlapping regexes, detected.")

0 commit comments

Comments
 (0)