2023-11-01 16:17:51 +08:00
|
|
|
{
|
|
|
|
inputs = {
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
|
|
|
};
|
|
|
|
outputs = { nixpkgs, fenix, ... }:
|
|
|
|
let
|
|
|
|
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
|
|
foreachSystem = nixpkgs.lib.genAttrs systems;
|
|
|
|
|
|
|
|
buildTools = pkgs: with pkgs; [
|
2023-11-02 10:13:50 +08:00
|
|
|
pkg-config # hooks pc files into environment variable for futher usage
|
2023-11-01 16:17:51 +08:00
|
|
|
];
|
|
|
|
developmentTools = pkgs: with pkgs; [
|
|
|
|
cargo-expand
|
|
|
|
];
|
2023-11-01 22:55:39 +08:00
|
|
|
libraries = pkgs: with pkgs; [
|
2023-11-01 16:17:51 +08:00
|
|
|
libseccomp
|
|
|
|
];
|
|
|
|
|
|
|
|
buildRustPlatform = pkgs: with fenix.packages."${pkgs.stdenv.system}"; let toolchain = combine [ complete.toolchain targets."x86_64-unknown-linux-musl".latest.rust-std ]; in pkgs.makeRustPlatform {
|
|
|
|
cargo = toolchain;
|
|
|
|
rustc = toolchain;
|
|
|
|
};
|
|
|
|
|
|
|
|
buildWithPackages = pkgs: pkgsStatic: (buildRustPlatform pkgsStatic).buildRustPackage rec {
|
2023-11-01 21:53:20 +08:00
|
|
|
pname = "x2t-sandbox";
|
2023-11-01 16:17:51 +08:00
|
|
|
version = "1.0.0";
|
|
|
|
|
|
|
|
nativeBuildInputs = buildTools pkgs;
|
|
|
|
buildInputs = libraries pkgsStatic;
|
|
|
|
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with nixpkgs.lib; {
|
2023-11-01 22:55:39 +08:00
|
|
|
description = "seccomp sandbox with rules defined at build stage";
|
|
|
|
homepage = "https://gitea.jianguoyun.net.cn/guochao/x2t-sandbox";
|
2023-11-01 16:17:51 +08:00
|
|
|
license = licenses.unlicense;
|
|
|
|
maintainers = [ ];
|
|
|
|
};
|
2023-11-01 22:55:39 +08:00
|
|
|
};
|
2023-11-01 16:17:51 +08:00
|
|
|
in
|
|
|
|
rec {
|
|
|
|
packages = foreachSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
in
|
|
|
|
rec {
|
2023-11-02 10:13:50 +08:00
|
|
|
x2t-sandbox-static = buildWithPackages pkgs pkgs.pkgsStatic;
|
|
|
|
x2t-sandbox = buildWithPackages pkgs pkgs;
|
2023-11-01 16:17:51 +08:00
|
|
|
|
2023-11-02 10:13:50 +08:00
|
|
|
default = x2t-sandbox-static;
|
2023-11-01 16:17:51 +08:00
|
|
|
});
|
|
|
|
devShells = foreachSystem
|
|
|
|
(system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
in
|
|
|
|
with pkgs; rec {
|
|
|
|
default = packages."${system}".default.overrideAttrs (prevAttrs: {
|
2023-11-01 22:55:39 +08:00
|
|
|
nativeBuildInputs = prevAttrs.nativeBuildInputs ++ (with fenix.packages."${system}".combine; with fenix.packages."${system}"; with pkgs; [
|
2023-11-01 16:17:51 +08:00
|
|
|
complete.rust-analyzer
|
2023-11-01 22:55:39 +08:00
|
|
|
complete.rust-src
|
2023-11-01 16:17:51 +08:00
|
|
|
]) ++ (developmentTools pkgs);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|