150 lines
4.2 KiB
Nix
150 lines
4.2 KiB
Nix
{
|
|
description = "A basic flake with a shell";
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
|
inputs.naersk.url = "github:nix-community/naersk";
|
|
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
|
|
inputs.trunk = {
|
|
url = "github:thedodd/trunk";
|
|
flake = false;
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
flake-utils,
|
|
naersk,
|
|
rust-overlay,
|
|
trunk,
|
|
}:
|
|
(flake-utils.lib.eachDefaultSystem (system: let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [(import rust-overlay)];
|
|
};
|
|
rust = pkgs.rust-bin.stable.latest.default.override {
|
|
targets = ["wasm32-unknown-unknown"];
|
|
};
|
|
naersk' = pkgs.callPackage naersk {
|
|
cargo = rust;
|
|
rustc = rust;
|
|
};
|
|
rustPlatform = pkgs.makeRustPlatform {
|
|
cargo = rust;
|
|
rustc = rust;
|
|
};
|
|
in {
|
|
devShell = pkgs.mkShell {
|
|
nativeBuildInputs = [
|
|
rustPlatform.bindgenHook
|
|
pkgs.cmake
|
|
rust
|
|
self.packages.${system}.dioxus
|
|
(naersk'.buildPackage trunk)
|
|
pkgs.httpie
|
|
pkgs.sea-orm-cli
|
|
];
|
|
RUST_PATH = "${rust}";
|
|
RUST_DOC_PATH = "${rust}/share/doc/rust/html/std/index.html";
|
|
};
|
|
|
|
packages = {
|
|
dioxus = pkgs.callPackage ({
|
|
rustPlatform,
|
|
pkg-config,
|
|
cacert,
|
|
openssl,
|
|
coreutils-full,
|
|
}:
|
|
rustPlatform.buildRustPackage rec {
|
|
pname = "dioxus-cli";
|
|
version = "0.4.0";
|
|
src = pkgs.fetchCrate {
|
|
inherit version pname;
|
|
hash = "sha256-4BIuD/rrA398hPEoNt5PwWylPAR0fA1UKc90xyH5Fd0=";
|
|
};
|
|
|
|
nativeBuildInputs = [pkg-config cacert coreutils-full];
|
|
buildInputs = [openssl];
|
|
|
|
OPENSSL_NO_VENDOR = 1;
|
|
|
|
cargoHash = "sha256-ok+fjvwz4k0/M5j7wut2A2AK6tuO3UfZtgoCXaCaHXY=";
|
|
}) {};
|
|
server = naersk'.buildPackage ./.;
|
|
frontend = let
|
|
pkg = {
|
|
stdenv,
|
|
makeRustPlatform,
|
|
wasm-bindgen-cli,
|
|
apiServerBase ? "http://localhost:8085",
|
|
frontendRoot ? "http://localhost:8080",
|
|
fetchzip,
|
|
bootstrap ? let
|
|
version = "5.3.1";
|
|
in
|
|
fetchzip {
|
|
url = "https://github.com/twbs/bootstrap/releases/download/v${version}/bootstrap-${version}-dist.zip";
|
|
hash = "sha256-BKtQB7IaslmmW6cLF4m/uUJQaBDndRf7tJ9gjItKVI4=";
|
|
},
|
|
bootstrapIcons ? let
|
|
version = "1.10.5";
|
|
in
|
|
fetchzip {
|
|
url = "https://github.com/twbs/icons/releases/download/v${version}/bootstrap-icons-${version}.zip";
|
|
hash = "sha256-o+owSIRMIXOH/GvQlVNlnCv/hcWD6kmoXNwm7F1Dmxs=";
|
|
},
|
|
}: let
|
|
rustPlatformWasm = makeRustPlatform {
|
|
rustc = rust;
|
|
cargo = rust;
|
|
};
|
|
in
|
|
stdenv.mkDerivation {
|
|
pname = "regalade-web";
|
|
version = "0.1.0";
|
|
|
|
src = ./.;
|
|
|
|
cargoDeps = rustPlatformWasm.importCargoLock {lockFile = ./Cargo.lock;};
|
|
|
|
REGALADE_API_SERVER_BASE = apiServerBase;
|
|
REGALADE_FRONTEND_DOMAIN = frontendRoot;
|
|
|
|
nativeBuildInputs = [
|
|
self.packages.${system}.dioxus
|
|
wasm-bindgen-cli
|
|
rustPlatformWasm.cargoSetupHook
|
|
rustPlatformWasm.cargoBuildHook
|
|
];
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
export XDG_DATA_HOME=/build/data
|
|
mkdir -p $XDG_DATA_HOME
|
|
|
|
cd web
|
|
dx build --release
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
cp -R dist $out
|
|
ln -s ${bootstrap} $out/bootstrap
|
|
ln -s ${bootstrapIcons} $out/bootstrap-icons
|
|
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
in
|
|
pkgs.callPackage pkg {};
|
|
};
|
|
}))
|
|
// {
|
|
nixosModules.default = import ./nixos self;
|
|
};
|
|
}
|