mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-05-11 20:49:30 +00:00
feat: add flake (#85)
* feat: add flake * fix: pr feedback * fix: removing dylib for libchat not used and it was causing the error with panic abort
This commit is contained in:
parent
6c7b3a4252
commit
df84fc87cf
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
@ -54,3 +54,17 @@ jobs:
|
||||
- name: Run C FFI smoketest under valgrind
|
||||
run: make valgrind
|
||||
working-directory: crates/client-ffi/examples/message-exchange
|
||||
|
||||
nix-build:
|
||||
name: Nix Build
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v31
|
||||
with:
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
- run: nix build --print-build-logs
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@ -30,6 +30,9 @@ target
|
||||
# Temporary data folder
|
||||
tmp
|
||||
|
||||
# Nix build output symlink
|
||||
result
|
||||
|
||||
.DS_Store
|
||||
|
||||
# Generated C headers (produced by `make` in examples/c-ffi; do not commit)
|
||||
|
||||
@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
crate-type = ["rlib","staticlib","dylib"]
|
||||
crate-type = ["rlib","staticlib"]
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.22"
|
||||
|
||||
48
flake.lock
generated
Normal file
48
flake.lock
generated
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1775710090,
|
||||
"narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4c1018dae018162ec878d42fec712642d214fdfa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775877051,
|
||||
"narHash": "sha256-wpSQm2PD/w4uRo2wb8utk0b5hOBkkg/CZ1xICY+qB7M=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "08b4f3633471874c8894632ade1b78d75dbda002",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
88
flake.nix
Normal file
88
flake.nix
Normal file
@ -0,0 +1,88 @@
|
||||
{
|
||||
description = "libchat - Logos Chat cryptographic library";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay }:
|
||||
let
|
||||
systems = [ "aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" ];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f {
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ rust-overlay.overlays.default ];
|
||||
};
|
||||
});
|
||||
in
|
||||
{
|
||||
packages = forAllSystems ({ pkgs }:
|
||||
let
|
||||
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust_toolchain.toml;
|
||||
rustPlatform = pkgs.makeRustPlatform {
|
||||
cargo = rustToolchain;
|
||||
rustc = rustToolchain;
|
||||
};
|
||||
in
|
||||
{
|
||||
default = rustPlatform.buildRustPackage {
|
||||
pname = "libchat";
|
||||
version = (builtins.fromTOML (builtins.readFile ./crates/client-ffi/Cargo.toml)).package.version;
|
||||
src = pkgs.lib.cleanSourceWith {
|
||||
src = ./.;
|
||||
filter = path: type:
|
||||
let base = builtins.baseNameOf path;
|
||||
in !(builtins.elem base [ "target" "nim-bindings" ".git" ".github" "tmp" ]);
|
||||
};
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"chat-proto-0.1.0" = "sha256-aCl80VOIkd/GK3gnmRuFoSAvPBfeE/FKCaNlLt5AbUU=";
|
||||
};
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ pkgs.perl pkgs.pkg-config pkgs.cmake ];
|
||||
buildType = "release";
|
||||
doCheck = false;
|
||||
|
||||
postBuild = ''
|
||||
cargo run --frozen --release --bin generate-headers --features headers -p client-ffi -- crates/client-ffi/client_ffi.h
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/lib $out/include
|
||||
cp target/${pkgs.stdenv.hostPlatform.rust.rustcTarget}/release/libclient_ffi.a $out/lib/
|
||||
cp crates/client-ffi/client_ffi.h $out/include/
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "Logos Chat library (C FFI)";
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
devShells = forAllSystems ({ pkgs }:
|
||||
let
|
||||
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust_toolchain.toml;
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
nativeBuildInputs = [
|
||||
rustToolchain
|
||||
pkgs.pkg-config
|
||||
pkgs.cmake
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user