redvault-ai/flake.nix
2024-09-05 22:33:13 +02:00

133 lines
3.8 KiB
Nix

{
description = "A Nix-flake-based Rust development environment";
nixConfig = {
extra-substituters = [ "https://nixcache.vlt81.de" ];
extra-trusted-public-keys = [ "nixcache.vlt81.de:nw0FfUpePtL6P3IMNT9X6oln0Wg9REZINtkkI9SisqQ=" ];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
npmlock2nix = {
url = "github:nix-community/npmlock2nix";
flake = false;
};
};
outputs =
{ self
, nixpkgs
, rust-overlay
, flake-utils
, devshell
, npmlock2nix
,
}:
flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [
rust-overlay.overlays.default
devshell.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;
};
customNodeModules = pkgs.npmlock2nix.v2.node_modules {
src = ./.;
nodejs = pkgs.nodejs_20;
};
buildInputs = with pkgs; [
harfbuzz
openssl
pango
sqlite
mariadb
zlib
clang
libclang
gzip
coreutils
gdb
glib
glibc
wayland-utils
waylandpp
kdePackages.wayland
libxkbcommon
webkitgtk_4_1
libsoup_3
gtk3
libGL
wayland
];
in
{
apps.devshell = self.outputs.devShells.${system}.default.flakeApp;
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-generate
cargo-udeps
self.packages.${system}.cargo-leptos
(wasm-bindgen-cli.override {
version = "0.2.93";
hash = "sha256-DDdu5mM3gneraM85pAepBXWn3TMofarVR4NbjMdz3r0=";
cargoHash = "sha256-birrg+XABBHHKJxfTKAMSlmTVYLmnmqMDfRnmG6g/YQ=";
})
cargo-outdated
cargo-release
calc
jre8 # needed for xmlls
dart-sass
fish
inotify-tools
leptosfmt
mold
nodejs_20
pkg-config
rustywind
sccache
sqlx-cli
unzip
]
++ buildInputs;
buildInputs = buildInputs;
shellHook = ''
# 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 LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath buildInputs}"
export LEPTOS_SASS_VERSION=1.71.0
export LEPTOS_TAILWIND_VERSION=3.4.1
export MALLOC_CONF=thp:always,metadata_thp:always
'';
};
});
}