Some checks failed
Push Workflows / clippy (push) Failing after 50s
Push Workflows / build (push) Failing after 4s
Push Workflows / rustfmt (push) Successful in 6s
Push Workflows / docs (push) Failing after 44s
Push Workflows / test (push) Failing after 55s
Push Workflows / nix-build (push) Successful in 5m12s
134 lines
3.6 KiB
Nix
134 lines
3.6 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }@inputs:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
wasm-bindgen-overlay = (final: prev: {
|
|
wasm-bindgen-cli_0_2_123 = prev.wasm-bindgen-cli_0_2_121.overrideAttrs (old: rec {
|
|
src = prev.fetchCrate {
|
|
pname = "wasm-bindgen-cli";
|
|
version = "0.2.123";
|
|
hash = "sha256-ymeAEYsr7OnupWYJWjSeVGvq3+s+zxSNkODbzY62rYs=";
|
|
};
|
|
|
|
cargoDeps = prev.rustPlatform.fetchCargoVendor {
|
|
inherit src;
|
|
inherit (src) pname version;
|
|
hash = "sha256-d7x6gtx5OqEE4MyT6yjYn/qtgjx7GroTpXJewnBV2dU=";
|
|
};
|
|
});
|
|
});
|
|
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
|
|
overlays = [
|
|
(import rust-overlay)
|
|
wasm-bindgen-overlay
|
|
];
|
|
};
|
|
|
|
daisyui-version = "v5.5.23";
|
|
|
|
daisyui = pkgs.stdenvNoCC.mkDerivation {
|
|
name = "daisyui";
|
|
|
|
src = pkgs.fetchurl {
|
|
url = "https://github.com/saadeghi/daisyui/releases/download/${daisyui-version}/daisyui.js";
|
|
sha256 = "sha256-yu/8ebzKXMfrcHJw2FzcXNzwYOF1hC+nufrTaPOMWeA=";
|
|
};
|
|
|
|
unpackPhase = "true";
|
|
|
|
installPhase = ''
|
|
mkdir "$out"
|
|
cp "$src" "$out/daisyui.js"
|
|
'';
|
|
};
|
|
|
|
daisyui-theme = pkgs.stdenvNoCC.mkDerivation {
|
|
name = "daisyui-theme";
|
|
|
|
src = pkgs.fetchurl {
|
|
url = "https://github.com/saadeghi/daisyui/releases/download/${daisyui-version}/daisyui-theme.js";
|
|
sha256 = "sha256-p/ofznslFSKQ87UuP4XV4bvU7xmAkci/WRlAznJt9MY=";
|
|
};
|
|
|
|
unpackPhase = "true";
|
|
|
|
installPhase = ''
|
|
mkdir "$out"
|
|
cp "$src" "$out/daisyui-theme.js"
|
|
'';
|
|
};
|
|
|
|
rust = pkgs.rust-bin.stable.latest.default.override {
|
|
targets = [ "wasm32-unknown-unknown" ];
|
|
};
|
|
|
|
build-pkgs = with pkgs; [
|
|
rust
|
|
dioxus-cli
|
|
wasm-bindgen-cli_0_2_123
|
|
binaryen
|
|
lld
|
|
tailwindcss_4
|
|
postgresql
|
|
];
|
|
in
|
|
rec {
|
|
devShells.default = pkgs.mkShell {
|
|
DAISYUI_PATH = "${daisyui}";
|
|
DAISYUI_THEME_PATH = "${daisyui-theme}";
|
|
|
|
buildInputs = with pkgs; [
|
|
diesel-cli
|
|
] ++ build-pkgs;
|
|
};
|
|
|
|
packages.default = packages.web;
|
|
|
|
packages.web = pkgs.rustPlatform.buildRustPackage {
|
|
name = "libretunes";
|
|
src = ./.;
|
|
|
|
DAISYUI_PATH = "${daisyui}";
|
|
DAISYUI_THEME_PATH = "${daisyui-theme}";
|
|
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
makeWrapper
|
|
] ++ build-pkgs;
|
|
|
|
buildPhase = ''
|
|
# dx build will run tailwindcss anyways, but doing it first here is faster and clearer if it fails
|
|
tailwindcss --input style/tailwind.css --output assets/tailwind.css
|
|
|
|
dx build --release --frozen --web
|
|
'';
|
|
|
|
installPhase = ''
|
|
mkdir -p "$out/bin"
|
|
install -t "$out" target/dx/libretunes/release/web/server
|
|
|
|
cp -r target/dx/libretunes/release/web/public "$out/public"
|
|
|
|
makeWrapper "$out/server" "$out/bin/libretunes" \
|
|
--set DIOXUS_PUBLIC_PATH "$out/public"
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
}
|