Nixpkgs/Create and debug packages: Difference between revisions

Voklen (talk | contribs)
m 'show-derivation' is a deprecated alias for 'derivation show'
Das-g (talk | contribs)
m Using nix-shell for package development: Improve grammar in note about preConfigurePhase
 
(2 intermediate revisions by one other user not shown)
Line 249: Line 249:
</syntaxhighlight>
</syntaxhighlight>


{{Note|you do not need to run $preConfigurePhase explicitly as it is run, when running configurePhase already.}}
{{Note|You do not need to run $preConfigurePhase explicitly, as it will already be run implicitly when running configurePhase.}}


To list all functions which are declared in '''set''':
To list all functions which are declared in '''set''':
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 {
    pname = "something";
    version = "1";
    strictDeps = true;
     # host/target agnostic programs
     depsBuildBuild = [
      hello
    ];
    # compilers & linkers & dependecy finding programs
    nativeBuildInputs = [
      pkg-config
     ];
    # libraries
     buildInputs = [
      my-library
    ];
   }
) { }
</syntaxhighlight>
</syntaxhighlight>