diff --git a/src/lib/Hydra/View/NARInfo.pm b/src/lib/Hydra/View/NARInfo.pm index 00dd6a68..b2532500 100644 --- a/src/lib/Hydra/View/NARInfo.pm +++ b/src/lib/Hydra/View/NARInfo.pm @@ -4,6 +4,7 @@ use strict; use base qw/Catalyst::View/; use File::Basename; use Nix::Store; +use Nix::Crypto; sub process { my ($self, $c) = @_; @@ -29,6 +30,15 @@ sub process { } } + # Optionally, sign the NAR info file we just created. + my $privateKeyFile = $c->config->{binary_cache_private_key_file}; + my $keyName = $c->config->{binary_cache_key_name}; + + if (defined $privateKeyFile && defined $keyName) { + my $sig = signString($privateKeyFile, $info); + $info .= "Signature: 1;$keyName;$sig\n"; + } + $c->response->body($info); return 1;