add nix package
This commit is contained in:
parent
0b6b49ddee
commit
3ff8bf71d5
21
flake.lock
21
flake.lock
|
@ -1,5 +1,25 @@
|
|||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722960479,
|
||||
"narHash": "sha256-NhCkJJQhD5GUib8zN9JrmYGMwt4lCRp6ZVNzIiYCl0Y=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "4c6c77920b8d44cd6660c1621dea6b3fc4b4c4f4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1723151029,
|
||||
|
@ -18,6 +38,7 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
|
|
70
flake.nix
70
flake.nix
|
@ -3,33 +3,57 @@
|
|||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:chayleaf/nixpkgs/unbound";
|
||||
crane.url = "github:ipetkov/crane";
|
||||
crane.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }: {
|
||||
outputs = { self, nixpkgs, crane }: let
|
||||
gen = func: nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ] (system: func (import nixpkgs { inherit system; }));
|
||||
in {
|
||||
|
||||
packages.x86_64-linux.bindings = let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
in pkgs.unbound-full.overrideAttrs (old: {
|
||||
name = "unbound-dynmod-bindings.rs";
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.rust-bindgen pkgs.rustfmt ];
|
||||
phases = ["unpackPhase" "patchPhase" "configurePhase" "installPhase"];
|
||||
outputs = [ "out" ];
|
||||
installPhase = ''
|
||||
cp ${./dummy.h} ./dummy.h
|
||||
bindgen ./dummy.h -- -I $PWD > $out
|
||||
'';
|
||||
packages = gen (pkgs: rec {
|
||||
bindings = pkgs.unbound-full.overrideAttrs (old: {
|
||||
name = "unbound-dynmod-bindings.rs";
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.rust-bindgen pkgs.rustfmt ];
|
||||
phases = ["unpackPhase" "patchPhase" "configurePhase" "installPhase"];
|
||||
outputs = [ "out" ];
|
||||
installPhase = ''
|
||||
cp ${./dummy.h} ./dummy.h
|
||||
bindgen ./dummy.h -- -I $PWD > $out
|
||||
'';
|
||||
});
|
||||
unbound-mod = let
|
||||
craneLib = crane.mkLib pkgs;
|
||||
inherit (nixpkgs) lib;
|
||||
in craneLib.buildPackage {
|
||||
pname = "unbound-mod";
|
||||
version = "0.1.0";
|
||||
postPatch = ''
|
||||
cp ${bindings} src/bindings.rs
|
||||
'';
|
||||
src = nixpkgs.lib.cleanSourceWith {
|
||||
src = ./.;
|
||||
filter = path: type: lib.hasSuffix ".h" path || craneLib.filterCargoSources path type;
|
||||
};
|
||||
doCheck = false;
|
||||
LIBMNL_LIB_DIR = "${nixpkgs.lib.getLib pkgs.libmnl}/lib";
|
||||
LIBNFTNL_LIB_DIR = "${nixpkgs.lib.getLib (pkgs.libnftnl.overrideAttrs (old: {
|
||||
patches = (old.patches or []) ++ [ ./libnftnl-fix.patch ];
|
||||
}))}/lib";
|
||||
};
|
||||
default = unbound-mod;
|
||||
});
|
||||
|
||||
devShells.x86_64-linux.default = let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
in pkgs.mkShell rec {
|
||||
name = "unbound-rust-mod-shell";
|
||||
nativeBuildInputs = [ pkgs.rustc pkgs.cargo pkgs.nftables ];
|
||||
LIBMNL_LIB_DIR = "${nixpkgs.lib.getLib pkgs.libmnl}/lib";
|
||||
LIBNFTNL_LIB_DIR = "${nixpkgs.lib.getLib (pkgs.libnftnl.overrideAttrs (old: {
|
||||
patches = (old.patches or []) ++ [ ./libnftnl-fix.patch ];
|
||||
}))}/lib";
|
||||
LD_LIBRARY_PATH = "${LIBMNL_LIB_DIR}:${LIBNFTNL_LIB_DIR}";
|
||||
};
|
||||
devShells = gen (pkgs: {
|
||||
default = pkgs.mkShell rec {
|
||||
name = "unbound-rust-mod-shell";
|
||||
nativeBuildInputs = [ pkgs.rustc pkgs.cargo pkgs.nftables ];
|
||||
LIBMNL_LIB_DIR = "${nixpkgs.lib.getLib pkgs.libmnl}/lib";
|
||||
LIBNFTNL_LIB_DIR = "${nixpkgs.lib.getLib (pkgs.libnftnl.overrideAttrs (old: {
|
||||
patches = (old.patches or []) ++ [ ./libnftnl-fix.patch ];
|
||||
}))}/lib";
|
||||
LD_LIBRARY_PATH = "${LIBMNL_LIB_DIR}:${LIBNFTNL_LIB_DIR}";
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue