Reputation: 594
So my school has a coding style, and thus a program checking it's compliance.
Recently they added libclang
as a dependency of the python environment to their tool.
Only problem is, this env is managed by banana-vera
using boost
, which i succesfully ported to nix so time ago.
So i have a flake:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
ruleset.url = "git+ssh://[email protected]/Epitech/banana-coding-style-checker.git";
ruleset.flake = false;
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, ruleset, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem
(system:
let pkgs = nixpkgs.legacyPackages.${system}; in
rec {
packages = flake-utils.lib.flattenTree rec {
report = (pkgs.writeShellScriptBin "cs" ''
custom script, running `${pkgs.banana-vera}/bin/vera++ --profile epitech --root ${ruleset}/vera`
'');
default = report;
};
apps.report.type = "app";
apps.report.program = "${packages.report}/bin/cs";
apps.default = apps.report;
});
}
So i thought at first i could just override the python env
banana = pkgs.banana-vera.overrideAttrs { buildInputs = pkgs.banana-vera.buildInputs ++ [ pkgs.libclang ]; }
which didn't worked.
I realized that libclang
is not the same as the one provided by nixpkgs
, and thus made a build for it:
libclangpy = p: p.buildPythonPackage rec {
pname = "libclang";
version = "16.0.6";
format = "wheel";
src = p.fetchPypi {
inherit pname version format;
platform = "manylinux2010_x86_64";
hash = "sha256-nc3HMJOXiLi2n/1tXXX+U2bj7gB/Hjapl5nsCwwAFJI=";
};
};
pyenv = pkgs.python310.withPackages (p: [ (libclangpy p) ]);
banana = pkgs.banana-vera.override { python310 = pyenv; };
Which didn't worked either...
At this point, i tried to setup a devShell just to see if the package clang.cindex
was installed.
devShells.default = pkgs.mkShell {
packages = [ pyenv ];
};
Turns out, this worked, and clang.cindex
, can be imported from the python env given by the devshell.
However, trying to build or run the cs
script, and it dosn't work.
So, i tried to build it within the shell, and then it finds the package..?
Maybe it could be a propagatedInput
then,
banana = pkgs.banana-vera.overrideAttrs {
propagatedBuildInputs = [ libclangpy ];
};
nope.
Finally i tried this, along some variations of it
banana = pkgs.symlinkJoin {
name = "banana-patched";
paths = [ pkgs.banana-vera ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postPatch = ''
wrapProgram $out/bin/vera++ --prefix PYTHONPATH : ${pyenv}
'';
};
But it doesn't work either I have tried all the thing i can think of, and yet no result. If anyone have an idea to fix this program
Upvotes: 3
Views: 286