Packaging/Binaries: Difference between revisions
imported>NilsIrl m →Extra Dynamic Libraries: Fix syntax highlighting |
imported>Makefu autopatchelf is the preferred way |
||
| Line 5: | Line 5: | ||
However sometimes this is not enough, more hardcoded paths may be scattered all over the place. For this you may need to set up an FHSUserEnv, a Linux Standard Base style directory structure with a final <code>chroot</code> call to fixate all paths. For a tutorial on how to use this technique, check out [https://reflexivereflection.com/posts/2015-02-28-deb-installation-nixos.html Anders Papittos blog post on installing debian packages in nixos]. | However sometimes this is not enough, more hardcoded paths may be scattered all over the place. For this you may need to set up an FHSUserEnv, a Linux Standard Base style directory structure with a final <code>chroot</code> call to fixate all paths. For a tutorial on how to use this technique, check out [https://reflexivereflection.com/posts/2015-02-28-deb-installation-nixos.html Anders Papittos blog post on installing debian packages in nixos]. | ||
== Starting Point == | |||
== Using AutoPatchelfHook == | |||
<code>autoPatchelfHook</code> is the current (as of 19.09) preferred way to package binaries. | |||
<syntaxHighlight lang=nix> | |||
{ stdenv | |||
, fetchurl | |||
, alsaLib | |||
, unzip | |||
, openssl_1_0_2 | |||
, zlib | |||
, libjack2 | |||
, autoPatchelfHook | |||
}: | |||
stdenv.mkDerivation rec { | |||
name = "studio-link-${version}"; | |||
version = "17.03.1-beta"; | |||
src = fetchurl { | |||
url = "https://github.com/Studio-Link-v2/backend/releases/download/v${version}/studio-link-standalone-linux.zip"; | |||
sha256 = "1y21nymin7iy64hcffc8g37fv305b1nvmh944hkf7ipb06kcx6r9"; | |||
}; | |||
nativeBuildInputs = [ | |||
unzip | |||
autoPatchelfHook | |||
]; | |||
buildInputs = [ | |||
alsaLib | |||
openssl_1_0_2 | |||
zlib | |||
libjack2 | |||
]; | |||
unpackPhase = '' | |||
unzip $src | |||
''; | |||
installPhase = '' | |||
install -m755 -D studio-link-standalone $out/bin/studio-link | |||
''; | |||
meta = with stdenv.lib; { | |||
homepage = https://studio-link.com; | |||
description = "Voip transfer"; | |||
platforms = platforms.linux; | |||
maintainers = with maintainers; [ makefu ]; | |||
}; | |||
} | |||
</syntaxHighlight> | |||
See [https://github.com/NixOS/nixpkgs/commit/ea5787ad5291ee1c131326cb9c9fec03d359edff this commit], or the example in method 5 of [https://unix.stackexchange.com/a/522823 this answer], for more details. | |||
== Manual Method == | |||
This sections describes the manual method of packaging a binary. It serves as a reference on the packaging issue with binaries and how these issues can be solved in nix derivations. | |||
=== Starting Point === | |||
We want to package a tool called "MasterPDFEditor", the package for debian can be found at [http://get.code-industry.net/public/master-pdf-editor-4.3.10_qt5.amd64.deb] ([https://web.archive.org/web/20170914112947/http://get.code-industry.net/public/master-pdf-editor-4.3.10_qt5.amd64.deb archive.org mirror]). | We want to package a tool called "MasterPDFEditor", the package for debian can be found at [http://get.code-industry.net/public/master-pdf-editor-4.3.10_qt5.amd64.deb] ([https://web.archive.org/web/20170914112947/http://get.code-industry.net/public/master-pdf-editor-4.3.10_qt5.amd64.deb archive.org mirror]). | ||
This tutorial assumes you run nixos-17.09 or later (for <code>nix-index</code> to work). | This tutorial assumes you run nixos-17.09 or later (for <code>nix-index</code> to work). | ||
| Line 206: | Line 264: | ||
== autoPatchelfHook == | == autoPatchelfHook == | ||
<code>autoPatchelfHook</code> can make the manual written patchelf invocations unnecessary. | <code>autoPatchelfHook</code> can make the manual written patchelf invocations unnecessary. [[Category:Tutorial]] | ||
[[Category:Tutorial]] | |||
[[Category:nixpkgs]] | [[Category:nixpkgs]] | ||