seccomp-sandbox/flake.nix

64 lines
2.0 KiB
Nix
Raw Normal View History

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;
in
rec {
packages = foreachSystem (system:
let
pkgs = import nixpkgs { inherit system; };
2024-01-18 21:24:44 +08:00
rustPlatform = pkgs.makeRustPlatform {
cargo = fenix.packages."${pkgs.stdenv.system}".complete.toolchain;
rustc = fenix.packages."${pkgs.stdenv.system}".complete.toolchain;
};
buildTools = with pkgs; [ pkg-config ];
libraries = with pkgs; [ libseccomp ];
2023-11-01 16:17:51 +08:00
in
rec {
2024-01-18 21:24:44 +08:00
x2t-sandbox = rustPlatform.buildRustPackage rec {
pname = "x2t-sandbox";
version = "1.0.0";
nativeBuildInputs = buildTools;
buildInputs = libraries;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
2023-11-02 11:01:31 +08:00
2024-01-18 21:24:44 +08:00
meta = with nixpkgs.lib; {
description = "seccomp sandbox with rules defined at build stage";
homepage = "https://gitea.jianguoyun.net.cn/guochao/x2t-sandbox";
license = licenses.unlicense;
maintainers = [ ];
};
};
2023-11-01 16:17:51 +08:00
2024-01-18 21:24:44 +08:00
default = x2t-sandbox;
2023-11-01 16:17:51 +08:00
});
devShells = foreachSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
2024-01-18 21:24:44 +08:00
developmentTools = with pkgs; [
cargo-expand
];
2023-11-01 16:17:51 +08:00
in
with pkgs; rec {
default = packages."${system}".default.overrideAttrs (prevAttrs: {
2024-01-18 21:24:44 +08:00
nativeBuildInputs = prevAttrs.nativeBuildInputs ++ (with fenix.packages."${system}".complete; [ rust-analyzer rust-src ]) ++ developmentTools;
2023-11-01 16:17:51 +08:00
});
});
};
2024-01-18 21:24:44 +08:00
}