Nixos is not fun to use.
THe Problem & the Solution to the Problemo
Due to having an incomplete image of Nixos (or possibly a datacenter image) you may encounter an error when running Rust programs(that require access to your OS’ graphics API)
The solution I have come to use is ensuring these packages are forced down the throat of cargo (this variation is a nix-flake):
{ description = "Nixos expose GL"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; in { devShells.default = pkgs.mkShell { packages = with pkgs; [ rustc cargo pkg-config wayland libxkbcommon libGL libX11 libXcursor libXi libXrandr ]; shellHook = '' export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.lib.makeLibraryPath [ pkgs.wayland pkgs.libxkbcommon pkgs.libGL pkgs.libX11 pkgs.libXcursor pkgs.libXi pkgs.libXrandr ]} ''; }; });}
Note : please ensure you have wayland by default if you do not (if you somehow are on this page without even a compositor)
Leave a Reply