servicepoint-simulator/flake.nix

152 lines
4 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.11";
2024-11-09 20:42:13 +01:00
nix-filter.url = "github:numtide/nix-filter";
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-09 20:04:44 +01:00
nix-filter,
2024-11-09 18:53:11 +01:00
}:
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-09 20:42:13 +01:00
make-rust-toolchain-core =
pkgs:
pkgs.symlinkJoin {
name = "rust-toolchain-core";
paths = with pkgs; [
rustc
cargo
rustPlatform.rustcSrc
];
};
2024-11-07 23:24:41 +01:00
in
rec {
packages = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages."${system}";
2024-11-09 20:42:13 +01:00
rust-toolchain-core = make-rust-toolchain-core pkgs;
2024-11-09 18:53:11 +01:00
naersk' = pkgs.callPackage naersk {
2024-11-09 20:42:13 +01:00
cargo = rust-toolchain-core;
rustc = rust-toolchain-core;
2024-11-09 18:53:11 +01:00
};
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-09 20:04:44 +01:00
src = nix-filter.lib.filter {
root = ./.;
include = [
./Cargo.toml
./Cargo.lock
./src
./Web437_IBM_BIOS.woff
./README.md
./LICENSE
];
};
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
xz
2024-11-07 23:24:41 +01:00
]
++ lib.optionals pkgs.stdenv.isLinux (
2024-11-07 23:24:41 +01:00
with pkgs;
[
# gpu
2024-11-09 18:53:11 +01:00
libGL
vulkan-headers
vulkan-loader
vulkan-tools vulkan-tools-lunarg
vulkan-extension-layer
vulkan-validation-layers
# keyboard
libxkbcommon
# font loading
fontconfig
freetype
2024-11-09 18:53:11 +01:00
# 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
]
)
++ lib.optionals pkgs.stdenv.isDarwin (
2024-11-28 19:36:58 +01:00
with pkgs.darwin.apple_sdk.frameworks;
[
Carbon
QuartzCore
AppKit
]
);
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}
'';
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}";
2024-11-09 20:42:13 +01:00
rust-toolchain = pkgs.symlinkJoin {
name = "rust-toolchain";
paths = with pkgs; [
(make-rust-toolchain-core pkgs)
rustfmt
clippy
cargo-expand
];
};
2024-11-07 23:24:41 +01:00
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 = [ rust-toolchain pkgs.gdb ];
2024-11-09 20:42:13 +01:00
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) 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
};
}