add nix package
This commit is contained in:
parent
0b6b49ddee
commit
3ff8bf71d5
21
flake.lock
21
flake.lock
|
@ -1,5 +1,25 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1723151029,
|
"lastModified": 1723151029,
|
||||||
|
@ -18,6 +38,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
38
flake.nix
38
flake.nix
|
@ -3,13 +3,16 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:chayleaf/nixpkgs/unbound";
|
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
|
packages = gen (pkgs: rec {
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
bindings = pkgs.unbound-full.overrideAttrs (old: {
|
||||||
in pkgs.unbound-full.overrideAttrs (old: {
|
|
||||||
name = "unbound-dynmod-bindings.rs";
|
name = "unbound-dynmod-bindings.rs";
|
||||||
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.rust-bindgen pkgs.rustfmt ];
|
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.rust-bindgen pkgs.rustfmt ];
|
||||||
phases = ["unpackPhase" "patchPhase" "configurePhase" "installPhase"];
|
phases = ["unpackPhase" "patchPhase" "configurePhase" "installPhase"];
|
||||||
|
@ -19,10 +22,30 @@
|
||||||
bindgen ./dummy.h -- -I $PWD > $out
|
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
|
devShells = gen (pkgs: {
|
||||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
default = pkgs.mkShell rec {
|
||||||
in pkgs.mkShell rec {
|
|
||||||
name = "unbound-rust-mod-shell";
|
name = "unbound-rust-mod-shell";
|
||||||
nativeBuildInputs = [ pkgs.rustc pkgs.cargo pkgs.nftables ];
|
nativeBuildInputs = [ pkgs.rustc pkgs.cargo pkgs.nftables ];
|
||||||
LIBMNL_LIB_DIR = "${nixpkgs.lib.getLib pkgs.libmnl}/lib";
|
LIBMNL_LIB_DIR = "${nixpkgs.lib.getLib pkgs.libmnl}/lib";
|
||||||
|
@ -31,5 +54,6 @@
|
||||||
}))}/lib";
|
}))}/lib";
|
||||||
LD_LIBRARY_PATH = "${LIBMNL_LIB_DIR}:${LIBNFTNL_LIB_DIR}";
|
LD_LIBRARY_PATH = "${LIBMNL_LIB_DIR}:${LIBNFTNL_LIB_DIR}";
|
||||||
};
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue