Skip to content

Instantly share code, notes, and snippets.

@stepbrobd
Last active September 27, 2024 13:31
Show Gist options
  • Save stepbrobd/4141c411f5413e55f807702fcfe2d051 to your computer and use it in GitHub Desktop.
Save stepbrobd/4141c411f5413e55f807702fcfe2d051 to your computer and use it in GitHub Desktop.
bruh idk how to get it to run
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
parts.url = "github:hercules-ci/flake-parts";
nixgl.url = "github:nix-community/nixgl";
};
outputs = inputs @ { self, nixpkgs, parts, nixgl }: parts.lib.mkFlake { inherit inputs; } {
systems = [ "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ];
perSystem = { system, pkgs, ... }: {
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [ nixgl.overlay ];
config = {
allowUnfree = true;
cudaSupport = true;
};
};
packages.default =
let
# https://github.com/nix-community/nixgl/blob/dd3ba2637f626086a24fba3f8de2805a77a9b00c/README.md#usage
wrap = binary: drv: pkgs.symlinkJoin {
name = "${drv.name}-nixglwrapped";
paths = [ drv ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
# This will break if wrapProgram is ever changed, so fingers crossed
makeShellWrapper() {
local original="$1"
local wrapper="$2"
cat << EOF > "$wrapper"
#! ${pkgs.bash}/bin/bash -e
exec "${pkgs.nixgl.auto.nixGLDefault}/bin/nixGL" "$original"
EOF
chmod +x "$wrapper"
}
wrapProgram "$out/bin/${binary}"
'';
};
in
wrap "hello" pkgs.hello;
devShells.default = pkgs.mkShell {
packages = with pkgs; [ nvtopPackages.full cudaPackages.cuda_cccl.dev ];
shellHook = ''
export CUDA_PATH=${pkgs.cudaPackages.cudatoolkit}
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath (with pkgs; [ cudaPackages.cudatoolkit linuxPackages.nvidia_x11])}:$LD_LIBRARY_PATH
export EXTRA_LDFLAGS="-L/lib -L${pkgs.linuxPackages.nvidia_x11}/lib"
export EXTRA_CCFLAGS="-I/usr/include"
'';
};
formatter = pkgs.nixpkgs-fmt;
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment