Reputation: 1473
Suppose you have a simple collection of bash
scripts making up a command line tool, with a primary script in bin/
and some library scripts in lib/
, all to be packaged with Nix using tool.nix
with a default.nix
for convenience:
scriptdir
└─ bin/
└─ tool
└─ lib/
└─ default.nix
└─ tool.nix
What should tool.nix
look like in order to correctly package this tool, allowing to execute tool
in the shell with tool <args>
?
Upvotes: 3
Views: 611
Reputation: 1473
After some help from IRC, the following tool.nix
works:
{ stdenv }:
let
version = "0.0.1";
in stdenv.mkDerivation
rec
{
name = "tool-${version}";
src = ./.;
installPhase =
''
mkdir -p $out
cp -R ./bin $out/bin
cp -R ./lib $out/lib
'';
}
For completeness, default.nix
would look like
{ pkgs ? import <nixpkgs> {} }:
pkgs.callPackage ./tool.nix {}
and can be installed by calling nix-env -f ./default.nix -i
from scriptdir
.
Upvotes: 3