servicepoint-simulator/flake.nix

114 lines
2.9 KiB
Nix
Raw Normal View History

2024-11-07 20:18:49 +01:00
{
description = "Flake for servicepoint-simulator";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
2024-11-09 18:53:11 +01:00
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-11-07 20:18:49 +01:00
};
outputs =
2024-11-09 18:53:11 +01:00
inputs@{
self,
nixpkgs,
naersk,
}:
2024-11-07 20:34:52 +01:00
let
2024-11-07 23:24:41 +01:00
lib = nixpkgs.lib;
2024-11-09 18:53:11 +01:00
supported-systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = lib.genAttrs supported-systems;
2024-11-07 23:24:41 +01:00
in
rec {
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages."${system}";
2024-11-09 18:53:11 +01:00
naersk' = pkgs.callPackage naersk {
cargo = pkgs.cargo;
rustc = pkgs.rustc;
};
2024-11-07 23:24:41 +01:00
in
2024-11-09 18:53:11 +01:00
rec {
servicepoint-simulator = naersk'.buildPackage rec {
2024-11-07 23:24:41 +01:00
src = ./.;
2024-11-09 18:53:11 +01:00
nativeBuildInputs = with pkgs; [
pkg-config
makeWrapper
];
strictDeps = true;
2024-11-07 23:24:41 +01:00
buildInputs =
with pkgs;
[
xe
lzma
]
++ (lib.optionals pkgs.stdenv.isLinux (
with pkgs;
[
libxkbcommon
2024-11-09 18:53:11 +01:00
libGL
# WINIT_UNIX_BACKEND=wayland
wayland
# WINIT_UNIX_BACKEND=x11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libX11
xorg.libX11.dev
2024-11-07 23:24:41 +01:00
]
));
2024-11-07 20:18:49 +01:00
2024-11-09 18:53:11 +01:00
postInstall = ''
wrapProgram $out/bin/servicepoint-simulator \
--suffix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
'';
#postFixup = ''
# patchelf $out/bin/servicepoint-simulator --add-rpath ${pkgs.lib.makeLibraryPath buildInputs}
#'';
#postInstall = ''
# patchelf $out/bin/servicepoint-simulator --add-rpath ${pkgs.lib.makeLibraryPath buildInputs}
#'';
2024-11-07 23:24:41 +01:00
};
2024-11-09 18:53:11 +01:00
default = servicepoint-simulator;
2024-11-07 23:24:41 +01:00
}
);
2024-11-07 20:34:52 +01:00
legacyPackages = packages;
2024-11-07 20:18:49 +01:00
2024-11-07 23:24:41 +01:00
devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages."${system}";
in
{
2024-11-09 18:53:11 +01:00
default = pkgs.mkShell rec {
2024-11-07 23:24:41 +01:00
inputsFrom = [ self.packages.${system}.default ];
packages = with pkgs; [
rustfmt
cargo-expand
clippy
2024-11-07 23:24:41 +01:00
];
2024-11-09 18:53:11 +01:00
# LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (
# builtins.concatMap (d: d.runtimeDependencies) inputsFrom
# )}";
2024-11-07 23:24:41 +01:00
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
}
);
2024-11-07 20:18:49 +01:00
2024-11-07 23:24:41 +01:00
formatter = forAllSystems (system: nixpkgs.legacyPackages."${system}".nixfmt-rfc-style);
2024-11-07 20:18:49 +01:00
};
}