Skip to content

Commit

Permalink
chore: format and re-add comments to flake.nix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedir Zadniprovskyi authored and fedirz committed Jan 26, 2025
1 parent edc5c02 commit 3f63c4b
Showing 1 changed file with 66 additions and 39 deletions.
105 changes: 66 additions & 39 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,79 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{ nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};

linuxOnlyPkgs = with pkgs; if system == "x86_64-linux" then [
cudaPackages_12.cudnn
cudaPackages_12.libcublas
cudaPackages_12.libcurand
cudaPackages_12.libcufft
cudaPackages_12.cuda_cudart
cudaPackages_12.cuda_nvrtc
] else [];
linuxOnlyPkgs =
with pkgs;
if system == "x86_64-linux" then
[
cudaPackages_12.cudnn
cudaPackages_12.libcublas
cudaPackages_12.libcurand
cudaPackages_12.libcufft
cudaPackages_12.cuda_cudart
cudaPackages_12.cuda_nvrtc
]
else
[ ];

# LD_LIBRARY_PATH seulement sur Linux
linuxLibPath = if system == "x86_64-linux" then "/run/opengl-driver/lib:${
pkgs.lib.makeLibraryPath ([
pkgs.cudaPackages_12.cudnn
pkgs.cudaPackages_12.libcublas
pkgs.cudaPackages_12.libcurand
pkgs.cudaPackages_12.libcufft
pkgs.cudaPackages_12.cuda_cudart
pkgs.cudaPackages_12.cuda_nvrtc
pkgs.portaudio
pkgs.zlib
pkgs.stdenv.cc.cc
pkgs.openssl
])
}" else "";
# https://github.com/nixos/nixpkgs/issues/278976#issuecomment-1879685177
# NOTE: Without adding `/run/...` the following error occurs
# RuntimeError: CUDA failed with error CUDA driver version is insufficient for CUDA runtime version
#
# NOTE: sometimes it still doesn't work but rebooting the system fixes it
# TODO: check if `LD_LIBRARY_PATH` needs to be set on MacOS
linuxLibPath =
if system == "x86_64-linux" then
"/run/opengl-driver/lib:${
pkgs.lib.makeLibraryPath [
# Needed for `faster-whisper`
pkgs.cudaPackages_12.cudnn
pkgs.cudaPackages_12.libcublas
in {
# The 4 cuda packages below are needed for `onnxruntime-gpu`
pkgs.cudaPackages_12.libcurand
pkgs.cudaPackages_12.libcufft
pkgs.cudaPackages_12.cuda_cudart
pkgs.cudaPackages_12.cuda_nvrtc
# Needed for `soundfile`
pkgs.portaudio
pkgs.zlib
pkgs.stdenv.cc.cc
pkgs.openssl
]
}"
else
"";

in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
act
ffmpeg-full
go-task
grafana-loki
parallel
pv
python312
tempo
uv
websocat
] ++ linuxOnlyPkgs;
nativeBuildInputs =
with pkgs;
[
act
ffmpeg-full
go-task
grafana-loki
parallel
pv
python312
tempo
uv
websocat
]
++ linuxOnlyPkgs;

LD_LIBRARY_PATH = linuxLibPath;

Expand All @@ -62,4 +88,5 @@
formatter = pkgs.nixfmt;
}
);
}
}

0 comments on commit 3f63c4b

Please sign in to comment.