diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..ac08325 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,7 @@ +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=lld"] + +[target.aarch64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=lld"] diff --git a/flake-modules/devshell/default.nix b/flake-modules/devshell/default.nix index 8805950..187f30f 100644 --- a/flake-modules/devshell/default.nix +++ b/flake-modules/devshell/default.nix @@ -59,7 +59,7 @@ localFlake: { ... }: { # dependencies for local rust builds pkg-config openssl - gcc + clang lld # faster linking + gcc for some crates ]; motd = "\n Welcome to the {2}picturepro{reset} dev shell. Run {1}menu{reset} for commands.\n"; diff --git a/flake-modules/rust-builds/leptos.nix b/flake-modules/rust-builds/leptos.nix index 76ab037..270c8a6 100644 --- a/flake-modules/rust-builds/leptos.nix +++ b/flake-modules/rust-builds/leptos.nix @@ -3,20 +3,22 @@ inherit (rust-workspace.workspace-base-args) src; inherit (rust-toolchain) craneLib; + # get the leptos options from the Cargo.toml workspace-cargo-manifest = builtins.fromTOML (builtins.readFile ../../Cargo.toml); leptos-options = builtins.elemAt workspace-cargo-manifest.workspace.metadata.leptos 0; + # get the style node_modules for the frontend js2nix = pkgs.callPackage (pkgs.fetchgit { url = "https://github.com/canva-public/js2nix"; hash = "sha256-Bmv0ERVeb6vjYzy4MuCDgSiz9fSm/Bhg+Xk3AxPisBw="; }) { }; style-root = ../../crates/site-app/style/tailwind; - style-node-env = (js2nix { package-json = style-root + "/package.json"; yarn-lock = style-root + "/yarn.lock"; }).nodeModules; + # options for both the frontend and server builds common-args = { inherit src; pname = leptos-options.bin-package; @@ -24,14 +26,14 @@ doCheck = false; - nativeBuildInputs = [ - pkgs.pkg-config - pkgs.binaryen # provides wasm-opt for cargo-leptos - ] ++ pkgs.lib.optionals (system == "x86_64-linux") [ + nativeBuildInputs = (with pkgs; [ + pkg-config + binaryen # provides wasm-opt for cargo-leptos + clang lld + ]) ++ pkgs.lib.optionals (system == "x86_64-linux") [ pkgs.nasm # wasm compiler only for x86_64-linux ]; - buildInputs = [ - ]; + buildInputs = [ ]; }; # build the deps for the frontend bundle, and export the target folder site-frontend-deps = craneLib.mkCargoDerivation (common-args // { @@ -78,7 +80,7 @@ ./crates/site-app/style/tailwind/node_modules ''; - # enable hash_files again + # enable hash_files again, so we generate `hash.txt` buildPhaseCargoCommand = '' LEPTOS_HASH_FILES=true cargo leptos build --release -vvv ''; diff --git a/flake-modules/rust-builds/workspace.nix b/flake-modules/rust-builds/workspace.nix index 7125189..cea15ef 100644 --- a/flake-modules/rust-builds/workspace.nix +++ b/flake-modules/rust-builds/workspace.nix @@ -24,7 +24,7 @@ # inputs assumed to be relevant for all crates nativeBuildInputs = with pkgs; [ - pkg-config + pkg-config clang lld ]; buildInputs = [ ]; };