Nixpkgs/Create and debug packages: Difference between revisions

Voklen (talk | contribs)
m 'show-derivation' is a deprecated alias for 'derivation show'
Artturin (talk | contribs)
Line 379: Line 379:
Your program to test the library:
Your program to test the library:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{ pkgs ? import <nixpkgs> {} }:
{
with pkgs;
  pkgs ? import <nixpkgs> {
let yourLibraryName = callPackage /path/to/library/derivation.nix {};
    overlays = [
in
      (final: prev: {
stdenv.mkDerivation {
        my-library = prev.callPackage ./my-library.nix { };
  nativeBuildInputs = [
      })
     yourLibraryName /* Add here if needed at build time */
    ];
     /* Add other dependencies if needed */
  },
  ]
}:
  buildInputs = [
pkgs.callPackage (
     yourLibraryName /* Add here if needed at runtime */
  {
     /* Add other dependencies if needed */
    stdenv,
  ]
    hello,
   /* Add the other stuff as needed */
    pkg-config,
}
    my-library,
  }:
  stdenv.mkDerivation {
    strictDeps = true;
     # host/target agnostic programs
     depsBuildBuild = [
      hello
    ];
    # compilers & linkers & dependecy finding programs
    nativeBuildInputs = [
      pkg-config
    ];
     # libraries
     buildInputs = [
      my-library
    ];
   }
) { }
</syntaxhighlight>
</syntaxhighlight>