<commit_before>{ stdenv, lib, fetchurl, buildPerlPackage, perlPackages, gnused, nix, dmidecode, pciutils, usbutils, iproute, nettools
, fetchFromGitHub, makeWrapper
}:

buildPerlPackage rec {
  name = "FusionInventory-Agent-${version}";
  version = "2.3.21";
  src = fetchurl {
    url = "mirror://cpan/authors/id/G/GB/GBOUGARD/${name}.tar.gz";
    sha256 = "0c2ijild03bfw125h2gyaip2mg1jxk72dcanrlx9n6pjh2ay90zh";
  };

  patches = [ ./remove_software_test.patch ];

  postPatch = ''
    patchShebangs bin

    substituteInPlace "lib/FusionInventory/Agent/Tools/Linux.pm" \
      --replace /sbin/ip ${iproute}/sbin/ip
    substituteInPlace "lib/FusionInventory/Agent/Task/Inventory/Linux/Networks.pm" \
      --replace /sbin/ip ${iproute}/sbin/ip
  '';

  buildTools = [];
  buildInputs = [ makeWrapper ] ++ (with perlPackages; [
    CGI
    DataStructureUtil
    FileCopyRecursive
    HTTPProxy
    HTTPServerSimple
    HTTPServerSimpleAuthen
    IOCapture
    IOSocketSSL
    IPCRun
    JSON
    LWPProtocolhttps
    ModuleInstall
    NetSNMP
    TestCompile
    TestDeep
    TestException
    TestMockModule
    TestMockObject
    TestNoWarnings
  ]);
  propagatedBuildInputs = with perlPackages; [
    FileWhich
    LWP
    NetIP
    TextTemplate
    UNIVERSALrequire
    XMLTreePP
  ];

  installPhase = ''
    mkdir -p $out

    cp -r bin $out
    cp -r lib $out

    for cur in $out/bin/*; do
      if [ -x "$cur" ]; then
        sed -e "s|./lib|$out/lib|" -i "$cur"
        wrapProgram "$cur" --prefix PATH : ${lib.makeBinPath [nix dmidecode pciutils usbutils nettools]}
      fi
    done
  '';

  outputs = [ "out" ];

  meta = with stdenv.lib; {
    homepage = http://www.fusioninventory.org;
    description = "FusionInventory unified Agent for UNIX, Linux, Windows and MacOSX";
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ maintainers.phile314 ];
  };
}
<commit_msg>FusionInventory: Patch in NixOS support<commit_after>{ stdenv, lib, fetchurl, buildPerlPackage, perlPackages, gnused, nix, dmidecode, pciutils, usbutils, iproute, nettools
, fetchFromGitHub, makeWrapper
}:

buildPerlPackage rec {
  name = "FusionInventory-Agent-${version}";
  version = "2.3.21";

  src = fetchFromGitHub {
    owner = "fusioninventory";
    repo = "fusioninventory-agent";
    rev = version;
    sha256 = "034clffcn0agx85macjgml4lyhvvck7idn94pqd2c77pk6crvw2y";
  };

  patches = [
    ./remove_software_test.patch
    # support for os-release file
    (fetchurl {
      url = https://github.com/fusioninventory/fusioninventory-agent/pull/396.diff;
      sha256 = "0bxrjmff80ab01n23xggci32ajsah6zvcmz5x4hj6ayy6dzwi6jb";
    })
    # support for Nix software inventory
    (fetchurl {
      url = https://github.com/fusioninventory/fusioninventory-agent/pull/397.diff;
      sha256 = "0pyf7mp0zsb3zcqb6yysr1zfp54p9ciwjn1pzayw6s9flmcgrmbw";
    })
    ];

  postPatch = ''

    patchShebangs bin

    substituteInPlace "lib/FusionInventory/Agent/Tools/Linux.pm" \
      --replace /sbin/ip ${iproute}/sbin/ip
    substituteInPlace "lib/FusionInventory/Agent/Task/Inventory/Linux/Networks.pm" \
      --replace /sbin/ip ${iproute}/sbin/ip
  '';

  buildTools = [];
  buildInputs = [ makeWrapper ] ++ (with perlPackages; [
    CGI
    DataStructureUtil
    FileCopyRecursive
    HTTPProxy
    HTTPServerSimple
    HTTPServerSimpleAuthen
    IOCapture
    IOSocketSSL
    IPCRun
    JSON
    LWPProtocolhttps
    ModuleInstall
    NetSNMP
    TestCompile
    TestDeep
    TestException
    TestMockModule
    TestMockObject
    TestNoWarnings
  ]);
  propagatedBuildInputs = with perlPackages; [
    FileWhich
    LWP
    NetIP
    TextTemplate
    UNIVERSALrequire
    XMLTreePP
  ];

  installPhase = ''
    mkdir -p $out

    cp -r bin $out
    cp -r lib $out

    for cur in $out/bin/*; do
      if [ -x "$cur" ]; then
        sed -e "s|./lib|$out/lib|" -i "$cur"
        wrapProgram "$cur" --prefix PATH : ${lib.makeBinPath [nix dmidecode pciutils usbutils nettools iproute]}
      fi
    done
  '';

  outputs = [ "out" ];

  meta = with stdenv.lib; {
    homepage = http://www.fusioninventory.org;
    description = "FusionInventory unified Agent for UNIX, Linux, Windows and MacOSX";
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ maintainers.phile314 ];
  };
}

{'fraction_non_alphanumeric': 0.10940051317937952, 'fraction_numerical': 0.021693491952414275, 'mean_word_length': 2.9231473010064044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4550277', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1537, 'n_words': 296}