Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

niv->flake #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 34 additions & 17 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
{ pkgs ? import ./nix/default.nix {}
{ stdenv
, naersk
, libiconv
, pkgconfig
}:

with pkgs;

let

self = {
inherit (tokenizersPackages)
tokenizers
tokenizers-haskell
;

shell = import ./shell.nix {
inherit pkgs;
};
patchLibs =
if stdenv.isDarwin
then ''
install_name_tool -id $out/lib/libtokenizers_haskell.dylib $out/lib/libtokenizers_haskell.dylib
''
else ''
patchelf --set-rpath "${stdenv.cc.cc.lib}/lib:$out/lib" $out/lib/libtokenizers_haskell.so
'';
in {
tokenizers = naersk.buildPackage {
src = ./.;
buildInputs = [ libiconv pkgconfig ];
release = true;
cargoBuildOptions = x: x ++ [ "-p" "tokenizers" ];
cargoTestOptions = x: x ++ [ "-p" "tokenzers" ];
copyBins = true;
copyLibs = true;
copyTarget = false;
};

in

self
tokenizers-haskell = naersk.buildPackage {
src = ./.;
buildInputs = [ libiconv pkgconfig ];
release = true;
cargoBuildOptions = x: x ++ [ "-p" "tokenizers-haskell" ];
cargoTestOptions = x: x ++ [ "-p" "tokenizers-haskell" ];
copyBins = false;
copyLibs = true;
copyTarget = false;
overrideMain = x: x // { postInstall = patchLibs; };
};
}
74 changes: 74 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
description = "huggingface tokenizers";

inputs = {
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
};

outputs = { self, nixpkgs, utils, naersk, ... }: {

overlay = final: prev: rec {
tokenizersPackages = prev.callPackage ./. { naersk = naersk.lib."${final.system}"; };
tokenizers-haskell = tokenizersPackages.tokenizers-haskell;
};

} // (utils.lib.eachSystem ["x86_64-darwin" "x86_64-linux"] (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ naersk.overlay ]; };
in {
packages = pkgs.callPackage ./. {};
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ cargo rustc rls libiconv pkgconfig ];
};
}
));
}
19 changes: 0 additions & 19 deletions nix/default.nix

This file was deleted.

8 changes: 0 additions & 8 deletions nix/pkgs.nix

This file was deleted.

45 changes: 0 additions & 45 deletions nix/rust.nix

This file was deleted.

38 changes: 0 additions & 38 deletions nix/sources.json

This file was deleted.

Loading