Nixpkgs/Create and debug packages: Difference between revisions

imported>Cpick
Remove `source $stdenv/setup` since `nix-shell` runs it automatically and redundant runs can duplicate hooks
imported>Jmarmstrong1207
Add == Adding custom libraries and dependencies to a package == section
Line 370: Line 370:


Tip: A git repository can be used for snapshotting attempts at building the package. This also makes it easy to generate patches, should you need to.
Tip: A git repository can be used for snapshotting attempts at building the package. This also makes it easy to generate patches, should you need to.
== Adding custom libraries and dependencies to a package ==
If you are packaging a dependency, such as a library used by applications for them to compile their code, you might have found you'd like to test if the derivation file installs correctly and can be used by other software.
In order to do this, you'll need to make a simple program that references the library, make a derivation for this program, then add the dependency. For example:
Your program to test the library:
<syntaxhighlight lang="nix">
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let yourLibraryName = callPackage /path/to/library/derivation.nix {};
in
stdenv.mkDerivation {
  nativeBuildInputs = [
    yourLibraryName /* Add here if needed at build time */
    /* Add other dependencies if needed */
  ]
  buildInputs = [
    yourLibraryName /* Add here if needed at runtime */
    /* Add other dependencies if needed */
  ]
  /* Add the other stuff as needed */
}
</syntaxhighlight>


== nix channels ==
== nix channels ==