split flake.nix, shell per package, generate pkg-config
This commit is contained in:
parent
d205ed44b7
commit
7b6b4f7e5b
51
devShells.nix
Normal file
51
devShells.nix
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
fenix,
|
||||||
|
selfPkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
(builtins.mapAttrs (
|
||||||
|
packageName: package:
|
||||||
|
pkgs.mkShell {
|
||||||
|
inputsFrom = [ package ];
|
||||||
|
packages = with pkgs; [
|
||||||
|
rustfmt
|
||||||
|
clippy
|
||||||
|
cargo-expand
|
||||||
|
cargo-tarpaulin
|
||||||
|
gdb
|
||||||
|
];
|
||||||
|
|
||||||
|
RUST_BACKTRACE = 1;
|
||||||
|
RUST_LOG = "all";
|
||||||
|
}
|
||||||
|
) selfPkgs)
|
||||||
|
// {
|
||||||
|
test = pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
(pkgs.symlinkJoin {
|
||||||
|
name = "rust-toolchain";
|
||||||
|
paths = with pkgs; [
|
||||||
|
rustc
|
||||||
|
cargo
|
||||||
|
rustPlatform.rustcSrc
|
||||||
|
rustPlatform.rustLibSrc
|
||||||
|
rustfmt
|
||||||
|
clippy
|
||||||
|
cargo-expand
|
||||||
|
cargo-tarpaulin
|
||||||
|
];
|
||||||
|
})
|
||||||
|
gcc
|
||||||
|
gnumake
|
||||||
|
xe
|
||||||
|
libgcc
|
||||||
|
libunwind
|
||||||
|
pkgsStatic.gcc
|
||||||
|
pkgsStatic.libgcc
|
||||||
|
pkgsStatic.musl
|
||||||
|
];
|
||||||
|
|
||||||
|
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
|
||||||
|
};
|
||||||
|
}
|
39
flake.lock
39
flake.lock
|
@ -1,5 +1,26 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"fenix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1748759782,
|
||||||
|
"narHash": "sha256-MJNhEBsAbxRp/53qsXv6/eaWkGS8zMGX9LuCz1BLeck=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"rev": "9be40ad995bac282160ff374a47eed67c74f9c2a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "fenix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1748302896,
|
"lastModified": 1748302896,
|
||||||
|
@ -18,8 +39,26 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"fenix": "fenix",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"rust-analyzer-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1748695646,
|
||||||
|
"narHash": "sha256-VwSuuRF4NvAoeHZJRRlX8zAFZ+nZyuiIvmVqBAX0Bcg=",
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"rev": "2a388d1103450d814a84eda98efe89c01b158343",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "rust-lang",
|
||||||
|
"ref": "nightly",
|
||||||
|
"repo": "rust-analyzer",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
56
flake.nix
56
flake.nix
|
@ -3,15 +3,19 @@
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
|
||||||
|
fenix = {
|
||||||
|
url = "github:nix-community/fenix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
inputs@{
|
inputs@{
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
|
fenix,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
lib = nixpkgs.lib;
|
|
||||||
supported-systems = [
|
supported-systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
|
@ -20,56 +24,20 @@
|
||||||
];
|
];
|
||||||
forAllSystems =
|
forAllSystems =
|
||||||
f:
|
f:
|
||||||
lib.genAttrs supported-systems (
|
nixpkgs.lib.genAttrs supported-systems (
|
||||||
system:
|
system:
|
||||||
f rec {
|
f rec {
|
||||||
|
inherit system self;
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
inherit system;
|
lib = pkgs.lib;
|
||||||
|
fenix = inputs.fenix.packages.${system};
|
||||||
|
selfPkgs = self.packages.${system};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells = forAllSystems (
|
packages = forAllSystems (import ./packages.nix);
|
||||||
{ pkgs, system }:
|
devShells = forAllSystems (import ./devShells.nix);
|
||||||
let
|
|
||||||
toolchain = pkgs.symlinkJoin {
|
|
||||||
name = "rust-toolchain";
|
|
||||||
paths = with pkgs; [
|
|
||||||
rustc
|
|
||||||
cargo
|
|
||||||
rustPlatform.rustcSrc
|
|
||||||
rustPlatform.rustLibSrc
|
|
||||||
rustfmt
|
|
||||||
clippy
|
|
||||||
cargo-expand
|
|
||||||
cargo-tarpaulin
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
default = pkgs.mkShell rec {
|
|
||||||
packages = with pkgs; [
|
|
||||||
toolchain
|
|
||||||
gcc
|
|
||||||
gdb
|
|
||||||
gnumake
|
|
||||||
pkg-config
|
|
||||||
xe
|
|
||||||
xz
|
|
||||||
libgcc
|
|
||||||
libunwind
|
|
||||||
pkgsStatic.gcc
|
|
||||||
pkgsStatic.libgcc
|
|
||||||
pkgsStatic.musl
|
|
||||||
];
|
|
||||||
|
|
||||||
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
|
|
||||||
RUST_BACKTRACE = 1;
|
|
||||||
RUST_LOG = "all";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
|
formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
59
packages.nix
Normal file
59
packages.nix
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
fenix,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
mkServicepointBindingC =
|
||||||
|
{
|
||||||
|
rustPlatform,
|
||||||
|
buildType,
|
||||||
|
}:
|
||||||
|
rustPlatform.buildRustPackage (finalAttrs: {
|
||||||
|
inherit buildType;
|
||||||
|
|
||||||
|
pname = "servicepoint-binding-c";
|
||||||
|
version = "0.15.0";
|
||||||
|
src = ./.;
|
||||||
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
|
meta = {
|
||||||
|
description = "C bindings for the servicepoint crate.";
|
||||||
|
homepage = "https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c";
|
||||||
|
license = lib.licenses.gpl3Plus;
|
||||||
|
pkgConfigModules = [ "servicepoint" ];
|
||||||
|
};
|
||||||
|
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||||
|
buildInputs = with pkgs; [ xz ];
|
||||||
|
|
||||||
|
preBuild = ''
|
||||||
|
mkdir -p include
|
||||||
|
export SERVICEPOINT_HEADER_OUT=$(realpath "include")
|
||||||
|
|
||||||
|
echo "Rust version: $(rustc --version)"
|
||||||
|
echo "preBuild hook: set SERVICEPOINT_HEADER_OUT to $SERVICEPOINT_HEADER_OUT"
|
||||||
|
'';
|
||||||
|
postInstall = ''
|
||||||
|
cp -r include $out
|
||||||
|
|
||||||
|
mkdir -p $out/lib/pkgconfig
|
||||||
|
sed "s:\$out:$out:g" ${./servicepoint.pc.in} | sed "s:\$version:$version:g" > $out/lib/pkgconfig/servicepoint.pc
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
rustPlatform-stable = pkgs.rustPlatform;
|
||||||
|
rustPlatform-unstable = pkgs.makeRustPlatform {
|
||||||
|
cargo = fenix.minimal.cargo;
|
||||||
|
rustc = fenix.minimal.rustc;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
servicepoint-binding-c-release = mkServicepointBindingC {
|
||||||
|
buildType = "release";
|
||||||
|
rustPlatform = rustPlatform-stable;
|
||||||
|
};
|
||||||
|
servicepoint-binding-c-size-optimized = mkServicepointBindingC {
|
||||||
|
buildType = "size_optimized";
|
||||||
|
rustPlatform = rustPlatform-unstable;
|
||||||
|
};
|
||||||
|
servicepoint-binding-c = servicepoint-binding-c-release;
|
||||||
|
}
|
6
servicepoint.pc.in
Normal file
6
servicepoint.pc.in
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Name: servicepoint
|
||||||
|
Description: C bindings for the servicepoint library
|
||||||
|
Version: $version
|
||||||
|
URL: https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c
|
||||||
|
Libs: -L$out/lib -lservicepoint_binding_c
|
||||||
|
Cflags: -I$out/include
|
Loading…
Reference in a new issue