remove_background/flake.nix

80 lines
2.1 KiB
Nix
Raw Normal View History

2026-01-21 21:14:29 +00:00
{
description = "Remove background Rust project with X11/Wayland support";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
rust-overlay,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv;
2026-01-22 20:48:08 +00:00
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" ];
};
2026-01-21 21:18:08 +00:00
2026-01-21 21:14:29 +00:00
nativeBuildInputs = with pkgs; [
rustToolchain
mold
pkg-config
clang
];
2026-01-21 21:18:08 +00:00
2026-01-21 21:14:29 +00:00
xorgBuildInputs = with pkgs; [
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
];
2026-01-21 21:18:08 +00:00
2026-01-21 21:14:29 +00:00
waylandBuildInputs = with pkgs; [
libxkbcommon
wayland
];
2026-01-21 21:18:08 +00:00
2026-01-21 21:17:47 +00:00
# Graphics/rendering libraries needed for wgpu (used by show-image)
graphicsBuildInputs = with pkgs; [
vulkan-loader
2026-01-21 23:25:11 +00:00
openssl
2026-01-21 21:17:47 +00:00
];
2026-01-21 21:18:08 +00:00
2026-01-21 21:17:47 +00:00
buildInputs = xorgBuildInputs ++ waylandBuildInputs ++ graphicsBuildInputs;
2026-01-21 21:14:29 +00:00
mkShell = pkgs.mkShell.override {
stdenv = stdenv;
};
in
{
packages.default = pkgs.rustPlatform.buildRustPackage {
inherit stdenv buildInputs nativeBuildInputs;
pname = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name;
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
};
devShells.default = mkShell {
inherit buildInputs nativeBuildInputs;
RUST_BACKTRACE = 1;
shellHook = ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath buildInputs}"
'';
};
}
);
}