Prefer shorter attribute paths in the package database

E.g. "python" is better than "python27Packages.python".
This commit is contained in:
Eelco Dolstra 2015-09-02 18:06:27 +02:00
parent bc1b2301df
commit 0cd5fe7808

View file

@ -45,16 +45,28 @@ sub process_dir {
for my $system ("x86_64-linux", "i686-linux") {
print STDERR "indexing programs for $system...\n";
my $out = `nix-env -f $nixExprs -qaP \\* --out-path --argstr system $system`;
my $out = `nix-env -f $nixExprs -qaP \\* --drv-path --out-path --argstr system $system`;
die "cannot evaluate Nix expressions for $system" if $? != 0;
my %packages;
foreach my $line (split "\n", $out) {
my ($attrName, $name, $outPath) = split ' ', $line;
my ($attrName, $name, $drvPath, $outPath) = split ' ', $line;
die unless $attrName && $name && $outPath;
next unless defined $narFiles{$outPath};
next unless -d $outPath;
process_dir($system, $attrName, "$outPath/bin");
process_dir($system, $attrName, "$outPath/sbin");
my $prev = $packages{$drvPath};
# Prefer shorter attribute names.
next if defined $prev &&
(length($prev->{attrName}) < length($attrName) ||
(length($prev->{attrName}) == length($attrName) && $prev->{attrName} le $attrName));
$packages{$drvPath} = { attrName => $attrName, outPath => $outPath };
}
foreach my $drvPath (keys %packages) {
my $pkg = $packages{$drvPath};
process_dir($system, $pkg->{attrName}, "$pkg->{outPath}/bin");
process_dir($system, $pkg->{attrName}, "$pkg->{outPath}/sbin");
}
}