How to add a non-packaged cpan perl module

Looking at Perl - Official NixOS Wiki seeking to add the non-packaged perl moduleAI::FANN seems complicated. In most other Linux:

  1. install the development package fann-dev
  2. runcpan AI:FANN or similar

works. I do not know how to run nix-generate-from-cpan.pl and add it to pkgs/top-level/perl-packages.nix. I just would like to make sure this is the only way to getting a non-packaged module to work?

It seems to be in maintainers/scripts/nix-generate-from-cpan.pl in the nixpkgs repo now, and packaged accordingly as a top-level attribute, so something like this should work:

nix-shell -p nix-generate-from-cpan
nix-generate-from-cpan Devel::REPL

(replace Devel::REPL, of course)

The wiki is quite outdated and could probably use some revisions on this topic.

1 Like

generates

[nix-shell:~]$ nix-generate-from-cpan AI::FANN
[MSG] No '/home/user/.cpanplus/custom-sources' dir, skipping custom sources
[MSG] No '/home/user/.cpanplus/custom-sources' dir, skipping custom sources
[MSG] No '/home/user/.cpanplus/custom-sources' dir, skipping custom sources
attribute name: AIFANN
module: AI::FANN
version: 0.10
package: AI-FANN-0.10.tar.gz (AI-FANN-0.10, AIFANN)
path: authors/id/S/SA/SALVA
downloaded to: /home/th6mas/.cpanplus/authors/id/S/SA/SALVA/AI-FANN-0.10.tar.gz
hash: sha256-bU9Gzd4IqwAaExMtuL3aDkGd3OHYvtEL11va+EIR8o8=
unpacked to: /home/th6mas/.cpanplus/5.42.0/build/Ql2d5fcscz/AI-FANN-0.10
runtime deps: 
build deps: 
description: Perl wrapper for the Fast Artificial Neural Network library
license: unknown
License 'unknown' is ambiguous, please verify
RSS feed: https://metacpan.org/feed/distribution/AI-FANN
===
  AIFANN = buildPerlPackage {
    pname = "AI-FANN";
    version = "0.10";
    src = fetchurl {
      url = "mirror://cpan/authors/id/S/SA/SALVA/AI-FANN-0.10.tar.gz";
      hash = "sha256-bU9Gzd4IqwAaExMtuL3aDkGd3OHYvtEL11va+EIR8o8=";
    };
    meta = {
      description = "Perl wrapper for the Fast Artificial Neural Network library";
    };
  };

It might need libfann to be available since it is just a wrapper?

Even with it installed, an identical output is obtained.

It is hard to know, if it has been installed or now i.e. if license prevents it.

Is anyone able to reproduce the issue?

Running the script does not install it. This script is a convenience script to automatically generate a nix expression for use else where. This is touched upon in the docs, as follows.

The output can be pasted into pkgs/top-level/perl-packages.nix or wherever else you need it.

This is just a warning to those who are upstreaming it that the license has not been automatically detected to be one in the hashset in the script and to verify and/or set it manually when upstreaming the package into nixpkgs.

1 Like

It does, it is mentioned in the README.

The makefile has vars for it and the README notes that:

You may need to add two extra parameters to the Makefile.PL script to indicate where to find the FANN library and include files if they are not installed on some standard locations. For instance:

perl Makefile.PL

FANN_LIB=/usr/local/fann/lib
FANN_INCLUDE=/usr/local/fann/include

The contributing guidelines notes that:

You can set the variable makeMakerFlags to pass flags to Makefile.PL.

I am not familiar enough with the Perl ecosystem to comment further.

1 Like

Thanks. I think, I now have a good idea of what needs to be done. However, the effort is high for a comparatively small task.

Perhaps, the developers could think of further automating it. I could probably submit a feature request on github.