{ description = "A Nix-flake-based Rust development environment"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs-stable.url = "github:NixOS/nixpkgs/0ef56bec7281e2372338f2dfe7c13327ce96f6bb"; rust-overlay.url = "github:oxalica/rust-overlay"; flake-utils.url = "github:numtide/flake-utils"; npmlock2nix = { url = "github:nix-community/npmlock2nix"; flake = false; }; llama-cpp = { url = "git+https://git.vlt81.de/tristan/llama.cpp.git"; }; }; outputs = { self , nixpkgs , nixpkgs-stable , rust-overlay , flake-utils , npmlock2nix , llama-cpp }: flake-utils.lib.eachDefaultSystem (system: let rocmtoolkit_joined = pkgs.symlinkJoin { name = "rocm-merged"; paths = with pkgs-stable.rocmPackages; [ rocm-core clr rccl miopen miopengemm rocrand rocblas rocsparse hipsparse rocthrust rocprim hipcub roctracer rocfft rocsolver hipfft hipsolver hipblas rocminfo rocm-thunk rocm-comgr rocm-device-libs rocm-runtime clr.icd hipify ]; }; overlays = [ rust-overlay.overlays.default (final: prev: { customRustToolchain = prev.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; }) (final: prev: { npmlock2nix = import npmlock2nix { pkgs = prev; }; }) ]; pkgs = import nixpkgs { inherit system overlays; }; pkgs-stable = import nixpkgs-stable { inherit system overlays; }; customNodeModules = pkgs.npmlock2nix.v2.node_modules { src = ./.; nodejs = pkgs.nodejs_20; }; myllamacpp = llama-cpp.packages.${system}.rocm.override { rocmTargets = [ "gfx1100" ]; llamaNative = true; llamaLTO = false; }; buildInputs = with pkgs; [ atk cairo gdk-pixbuf glib glibc gtk3 harfbuzz libsoup_3 openssl pango sqlite webkitgtk_4_1 zlib rocmtoolkit_joined pkgs-stable.clang pkgs-stable.gzip pkgs-stable.coreutils ]; in { packages = { cargo-leptos = pkgs.callPackage ./.nix/cargo-leptos.nix { }; }; devShells.default = pkgs.mkShell { packages = with pkgs; [ customNodeModules customRustToolchain binaryen cacert cargo-bloat cargo-docset cargo-machete cargo-limit cargo-deny cargo-edit cargo-watch cargo-make cargo-udeps self.packages.${system}.cargo-leptos (wasm-bindgen-cli.override { version = "0.2.92"; hash = "sha256-1VwY8vQy7soKEgbki4LD+v259751kKxSxmo/gqE6yV0="; cargoHash = "sha256-aACJ+lYNEU8FFBs158G1/JG8sc6Rq080PeKCMnwdpH0="; }) cargo-outdated cargo-release dart-sass fish inotify-tools leptosfmt mold nodejs_20 pkg-config rustywind sccache sqlx-cli unzip myllamacpp ] ++ buildInputs; buildInputs = buildInputs; shellHook = '' # allow runinng llamafiles # export PATH=${rocmtoolkit_joined}/bin:$PATH # export PATH=$PATH:${pkgs-stable.clang}/bin # export PATH=$PATH:${pkgs-stable.coreutils}/bin # export PATH=$PATH:${pkgs-stable.gzip}/bin export HIPCC_COMPILE_FLAGS_APPEND="-I${rocmtoolkit_joined}/include -I${rocmtoolkit_joined}/include/rocblas" export HIPCC_LINK_FLAGS_APPEND="-L${rocmtoolkit_joined}/lib" export ROCM_PATH=${rocmtoolkit_joined} export ROCM_SOURCE_DIR=${rocmtoolkit_joined} export HSA_OVERRIDE_GFX_VERSION=10.3.0 # this needs to be changed depending on your AMD gpu # setup node-modules export NPM_LOCAL_PREFIX=${customNodeModules}/node_modules (ln -s $NPM_LOCAL_PREFIX ./node_modules 2>/dev/null || unlink ./node_modules) && ln -s $NPM_LOCAL_PREFIX ./node_modules 2>/dev/null # export NIX_LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath buildInputs}:$NIX_LD_LIBRARY_PATH export LEPTOS_SASS_VERSION=1.71.0 export LEPTOS_TAILWIND_VERSION=3.4.3 export MALLOC_CONF=thp:always,metadata_thp:always ''; }; }); }