think of a package that you know is technologically similar to what you want to package
search in https://github.com/nixos/nixpkgs for that package. entry point is /pkgs/top-level/all.nix, from there you get the path to your desired package
read the default.nix of that package
copy that one and start adapting it to build your source
build the package by being in your nixpkgs checkout and issuing $ nix-env -f . -iA $yourpackagename