Initial Functional Plugin
This commit is contained in:
68
flake.nix
Normal file
68
flake.nix
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }: let
|
||||
inherit (nixpkgs) lib;
|
||||
systems = ["x86_64-linux"];
|
||||
eachSystem = f: lib.genAttrs systems (system: f {
|
||||
inherit system;
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
ownPkgs = self.packages.${system};
|
||||
});
|
||||
in {
|
||||
packages = eachSystem ({ pkgs, ... }: {
|
||||
default = pkgs.rustPlatform.buildRustPackage (final: {
|
||||
pname = "zathura-typst";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
cargoHash = lib.fakeHash;
|
||||
|
||||
buildInputs = [pkgs.zathuraPkgs.zathura_core pkgs.girara pkgs.cairo pkgs.pkg-config];
|
||||
|
||||
# From https://hoverbear.org/blog/rust-bindgen-in-nix/
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
preBuild = ''
|
||||
# From: https://github.com/NixOS/nixpkgs/blob/1fab95f5190d087e66a3502481e34e15d62090aa/pkgs/applications/networking/browsers/firefox/common.nix#L247-L253
|
||||
# Set C flags for Rust's bindgen program. Unlike ordinary C
|
||||
# compilation, bindgen does not invoke $CC directly. Instead it
|
||||
# uses LLVM's libclang. To make sure all necessary flags are
|
||||
# included we need to look in a few places.
|
||||
export BINDGEN_EXTRA_CLANG_ARGS="$(< ${pkgs.stdenv.cc}/nix-support/libc-crt1-cflags) \
|
||||
$(< ${pkgs.stdenv.cc}/nix-support/libc-cflags) \
|
||||
$(< ${pkgs.stdenv.cc}/nix-support/cc-cflags) \
|
||||
$(< ${pkgs.stdenv.cc}/nix-support/libcxx-cxxflags) \
|
||||
${lib.optionalString pkgs.stdenv.cc.isClang "-idirafter ${pkgs.stdenv.cc.cc}/lib/clang/${lib.getVersion pkgs.stdenv.cc.cc}/include"} \
|
||||
${lib.optionalString pkgs.stdenv.cc.isGNU "-isystem ${pkgs.stdenv.cc.cc}/include/c++/${lib.getVersion pkgs.stdenv.cc.cc} -isystem ${pkgs.stdenv.cc.cc}/include/c++/${lib.getVersion pkgs.stdenv.cc.cc}/${pkgs.stdenv.hostPlatform.config}"} \
|
||||
$(pkg-config --cflags zathura)
|
||||
"
|
||||
'';
|
||||
});
|
||||
});
|
||||
|
||||
devShells = eachSystem ({ pkgs, ownPkgs, ... }: {
|
||||
default = pkgs.mkShell {
|
||||
inputsFrom = [ownPkgs.default];
|
||||
packages = [pkgs.rust-analyzer pkgs.clippy pkgs.rustfmt];
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
shellHook = ''
|
||||
# From: https://github.com/NixOS/nixpkgs/blob/1fab95f5190d087e66a3502481e34e15d62090aa/pkgs/applications/networking/browsers/firefox/common.nix#L247-L253
|
||||
# Set C flags for Rust's bindgen program. Unlike ordinary C
|
||||
# compilation, bindgen does not invoke $CC directly. Instead it
|
||||
# uses LLVM's libclang. To make sure all necessary flags are
|
||||
# included we need to look in a few places.
|
||||
export BINDGEN_EXTRA_CLANG_ARGS="$(< ${pkgs.stdenv.cc}/nix-support/libc-crt1-cflags) \
|
||||
$(< ${pkgs.stdenv.cc}/nix-support/libc-cflags) \
|
||||
$(< ${pkgs.stdenv.cc}/nix-support/cc-cflags) \
|
||||
$(< ${pkgs.stdenv.cc}/nix-support/libcxx-cxxflags) \
|
||||
${lib.optionalString pkgs.stdenv.cc.isClang "-idirafter ${pkgs.stdenv.cc.cc}/lib/clang/${lib.getVersion pkgs.stdenv.cc.cc}/include"} \
|
||||
${lib.optionalString pkgs.stdenv.cc.isGNU "-isystem ${pkgs.stdenv.cc.cc}/include/c++/${lib.getVersion pkgs.stdenv.cc.cc} -isystem ${pkgs.stdenv.cc.cc}/include/c++/${lib.getVersion pkgs.stdenv.cc.cc}/${pkgs.stdenv.hostPlatform.config}"} \
|
||||
$(pkg-config --cflags zathura)
|
||||
"
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user