servicepoint-binding-ruby/flake.nix

156 lines
4.1 KiB
Nix
Raw Normal View History

2024-11-09 21:25:46 +01:00
{
2025-02-08 14:49:04 +01:00
description = "Flake for the servicepoint library.";
2024-11-09 21:25:46 +01:00
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
2024-11-09 21:25:46 +01:00
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
nixpkgs,
naersk,
}:
let
lib = nixpkgs.lib;
supported-systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
2025-02-15 09:29:29 +01:00
forAllSystems =
f:
lib.genAttrs supported-systems (
system:
f rec {
pkgs = nixpkgs.legacyPackages.${system};
inherit system;
}
);
2024-11-09 21:25:46 +01:00
in
rec {
packages = forAllSystems (
2025-02-15 09:29:29 +01:00
{ pkgs, ... }:
2024-11-09 21:25:46 +01:00
let
2025-02-15 09:29:29 +01:00
naersk' = pkgs.callPackage naersk { };
2024-11-10 01:06:55 +01:00
nativeBuildInputs = with pkgs; [
pkg-config
makeWrapper
];
buildInputs = with pkgs; [
xe
xz
2024-11-10 01:06:55 +01:00
];
makeExample =
2024-11-23 22:57:10 +01:00
{
package,
example,
features ? "",
}:
2024-11-10 01:06:55 +01:00
naersk'.buildPackage {
pname = example;
cargoBuildOptions =
x:
x
++ [
"--package"
package
];
src = ./.;
2025-02-15 09:29:29 +01:00
inherit nativeBuildInputs buildInputs;
2024-11-10 01:06:55 +01:00
strictDeps = true;
2024-11-23 22:57:10 +01:00
gitSubmodules = true;
2024-11-10 01:06:55 +01:00
overrideMain = old: {
2024-11-23 17:38:50 +01:00
preConfigure = ''
2024-11-23 22:57:10 +01:00
cargo_build_options="$cargo_build_options --example ${example} ${
if features == "" then "" else "--features " + features
}"
2024-11-23 17:38:50 +01:00
'';
};
2024-11-10 01:06:55 +01:00
};
makePackage =
package:
let
package-param = [
"--package"
package
];
in
naersk'.buildPackage {
pname = package;
cargoBuildOptions = x: x ++ package-param;
cargoTestOptions = x: x ++ package-param;
src = ./.;
doCheck = true;
strictDeps = true;
2025-02-15 09:29:29 +01:00
inherit nativeBuildInputs buildInputs;
2024-11-10 01:06:55 +01:00
};
2024-11-09 21:25:46 +01:00
in
rec {
2024-11-10 01:06:55 +01:00
servicepoint = makePackage "servicepoint";
2024-11-23 22:57:10 +01:00
announce = makeExample {
package = "servicepoint";
example = "announce";
};
game-of-life = makeExample {
package = "servicepoint";
example = "game_of_life";
features = "rand";
};
moving-line = makeExample {
package = "servicepoint";
example = "moving_line";
};
random-brightness = makeExample {
package = "servicepoint";
example = "random_brightness";
features = "rand";
};
wiping-clear = makeExample {
package = "servicepoint";
example = "wiping_clear";
};
2024-11-09 21:25:46 +01:00
}
);
legacyPackages = packages;
devShells = forAllSystems (
2025-02-15 09:29:29 +01:00
{ pkgs, system }:
2024-11-09 21:25:46 +01:00
{
default = pkgs.mkShell rec {
inputsFrom = [ self.packages.${system}.servicepoint ];
2024-11-23 17:38:50 +01:00
packages = with pkgs; [
2025-02-15 09:29:29 +01:00
(pkgs.symlinkJoin
{
name = "rust-toolchain";
paths = with pkgs; [
rustc
cargo
rustPlatform.rustcSrc
rustfmt
clippy
cargo-expand
cargo-tarpaulin
];
})
2024-11-23 17:38:50 +01:00
ruby
dotnet-sdk_8
gcc
gnumake
];
2024-11-09 21:25:46 +01:00
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
}
);
2025-02-15 09:29:29 +01:00
formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
2024-11-09 21:25:46 +01:00
};
}