nix-generate-from-cpan: generate SRI hashes

Changed files
+9 -2
maintainers
+9 -2
maintainers/scripts/nix-generate-from-cpan.pl
···
use CPAN::Meta();
use CPANPLUS::Backend();
+
use MIME::Base64;
use Module::CoreList;
use Getopt::Long::Descriptive qw( describe_options );
use JSON::PP qw( encode_json );
···
return $license_line;
}
+
sub sha256_to_sri {
+
my ($sha256) = @_;
+
return "sha256-" . encode_base64(pack("H*", $sha256), '');
+
}
+
my ( $opt, $module_name ) = handle_opts();
Log::Log4perl->easy_init(
···
INFO( "path: ", $module->path );
my $tar_path = $module->fetch();
+
my $sri_hash = sha256_to_sri($module->status->checksum_value);
INFO( "downloaded to: ", $tar_path );
-
INFO( "sha-256: ", $module->status->checksum_value );
+
INFO( "hash: ", $sri_hash );
my $pkg_path = $module->extract();
INFO( "unpacked to: ", $pkg_path );
···
version = "$pkg_version";
src = fetchurl {
url = "mirror://cpan/${\$module->path}/${\$module->package}";
-
sha256 = "${\$module->status->checksum_value}";
+
hash = "$sri_hash";
};
EOF
print <<EOF if scalar @build_deps > 0;