restic: use subPackages, installShellFiles

This commit is contained in:
zowoq 2020-04-26 18:34:20 +10:00
parent 7c399a4ee0
commit 3e4f1e5b67

@ -1,4 +1,4 @@
{ stdenv, lib, buildGoPackage, fetchFromGitHub, nixosTests}:
{ stdenv, lib, buildGoPackage, fetchFromGitHub, installShellFiles, nixosTests}:
buildGoPackage rec {
pname = "restic";
@ -13,23 +13,19 @@ buildGoPackage rec {
sha256 = "0lydll93n1lcn1fl669b9cikmzz9d6vfpc8ky3ng5fi8kj3v1dz7";
};
subPackages = [ "cmd/restic" ];
nativeBuildInputs = [ installShellFiles ];
passthru.tests.restic = nixosTests.restic;
# Use a custom install phase here as by default the
# build-release-binaries and prepare-releases binaries are
# installed.
installPhase = ''
mkdir -p "$bin/bin"
cp go/bin/restic "$bin/bin"
'' + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
mkdir -p \
$bin/etc/bash_completion.d \
$bin/share/zsh/vendor-completions \
$bin/share/man/man1
postInstall = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
$bin/bin/restic generate \
--bash-completion $bin/etc/bash_completion.d/restic.sh \
--zsh-completion $bin/share/zsh/vendor-completions/_restic \
--man $bin/share/man/man1
--bash-completion restic.bash \
--zsh-completion restic.zsh \
--man .
installShellCompletion restic.{bash,zsh}
installManPage *.1
'';
meta = with lib; {