diff options
| author | LLLL Colonq <llll@colonq> | 2025-03-17 03:42:04 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-03-17 03:42:04 -0400 |
| commit | 6fc5ba5332f19c0867c7b6a96e37af172db0ce46 (patch) | |
| tree | 50f97c26c8fba40159051d82cbcf83a4e8647068 /flake.nix | |
| parent | 9e02a3362ea7136afecbc98df219368590b061b4 (diff) | |
Update flake.nix
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 126 |
1 files changed, 71 insertions, 55 deletions
@@ -31,16 +31,6 @@ craneLib = ((crane.mkLib pkgs).overrideToolchain rustToolchain).overrideScope (_final: _prev: { inherit (import nixpkgs-for-wasm-bindgen { inherit system; }) wasm-bindgen-cli; }); - src = lib.cleanSourceWith { - src = ./.; - filter = path: type: - (lib.hasSuffix "\.html" path) || - (lib.hasSuffix "\.js" path) || - (lib.hasSuffix "\.css" path) || - (lib.hasInfix "/assets/" path) || - (craneLib.filterCargoSources path type) - ; - }; native = rec { nativeBuildInputs = [ @@ -59,57 +49,83 @@ pkgs.libglvnd pkgs.alsa-lib ]; - commonArgs = { - inherit src nativeBuildInputs buildInputs; - strictDeps = true; - CARGO_BUILD_TARGET = "x86_64-unknown-linux-gnu"; - inherit (craneLib.crateNameFromCargoToml { inherit src; }) version; - }; - cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { - doCheck = false; - }); - build = nm: craneLib.buildPackage (commonArgs // { - inherit cargoArtifacts; - pname = nm; - cargoExtraArgs = "-p ${nm}"; - }); + build = path: nm: + let + src = lib.cleanSourceWith { + src = ./.; + filter = path: type: + (lib.hasSuffix "\.html" path) || + (lib.hasSuffix "\.js" path) || + (lib.hasSuffix "\.css" path) || + (lib.hasInfix "/assets/" path) || + (craneLib.filterCargoSources path type) + ; + }; + commonArgs = { + inherit src nativeBuildInputs buildInputs; + strictDeps = true; + CARGO_BUILD_TARGET = "x86_64-unknown-linux-gnu"; + inherit (craneLib.crateNameFromCargoToml { inherit src; }) version; + }; + cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { + doCheck = false; + }); + in + craneLib.buildPackage (commonArgs // { + inherit cargoArtifacts; + pname = nm; + cargoExtraArgs = "-p ${nm}"; + }); }; wasm = rec { - commonArgs = { - inherit src; - strictDeps = true; - CARGO_BUILD_TARGET = "wasm32-unknown-unknown"; - buildInputs = []; - inherit (craneLib.crateNameFromCargoToml { inherit src; }) version; - wasm-bindgen-cli = pkgs.buildWasmBindgenCli rec { - src = pkgs.fetchCrate { - pname = "wasm-bindgen-cli"; - version = "0.2.100"; - hash = "sha256-3RJzK7mkYFrs7C/WkhW9Rr4LdP5ofb2FdYGz1P7Uxog="; + build = path: nm: + let + src = lib.cleanSourceWith { + src = ./.; + filter = path: type: + (lib.hasSuffix "\.html" path) || + (lib.hasSuffix "\.js" path) || + (lib.hasSuffix "\.css" path) || + (lib.hasInfix "/assets/" path) || + (craneLib.filterCargoSources path type) + ; }; - cargoDeps = pkgs.rustPlatform.fetchCargoVendor { + commonArgs = { inherit src; - inherit (src) pname version; - hash = "sha256-qsO12332HSjWCVKtf1cUePWWb9IdYUmT+8OPj/XP2WE="; + strictDeps = true; + CARGO_BUILD_TARGET = "wasm32-unknown-unknown"; + buildInputs = []; + inherit (craneLib.crateNameFromCargoToml { inherit src; }) version; + wasm-bindgen-cli = pkgs.buildWasmBindgenCli rec { + src = pkgs.fetchCrate { + pname = "wasm-bindgen-cli"; + version = "0.2.100"; + hash = "sha256-3RJzK7mkYFrs7C/WkhW9Rr4LdP5ofb2FdYGz1P7Uxog="; + }; + cargoDeps = pkgs.rustPlatform.fetchCargoVendor { + inherit src; + inherit (src) pname version; + hash = "sha256-qsO12332HSjWCVKtf1cUePWWb9IdYUmT+8OPj/XP2WE="; + }; + }; }; - }; - }; - build = nm: craneLib.buildTrunkPackage (commonArgs // rec { - pname = nm; - cargoExtraArgs = "-p ${nm}"; - cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { - inherit cargoExtraArgs; - doCheck = false; - }); - preBuild = '' - cd ./crates/throwshade - ''; - postBuild = '' - mv ./dist ../.. - cd ../.. - ''; - }); + in + craneLib.buildTrunkPackage (commonArgs // rec { + pname = nm; + cargoExtraArgs = "-p ${nm}"; + cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { + inherit cargoExtraArgs; + doCheck = false; + }); + preBuild = '' + cd ./crates/throwshade + ''; + postBuild = '' + mv ./dist ../.. + cd ../.. + ''; + }); }; shell = craneLib.devShell { |
