Attempt to get basic leptos site working in devshell and nix package
This commit is contained in:
parent
0ff2b12fb0
commit
af3c61d75c
19 changed files with 3051 additions and 2 deletions
104
mx-aliases/default.nix
Normal file
104
mx-aliases/default.nix
Normal file
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
crane,
|
||||
advisory-db,
|
||||
}:
|
||||
let
|
||||
runtimeInputs = [ ];
|
||||
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
||||
src = craneLib.cleanCargoSource ./.;
|
||||
commonArgs = {
|
||||
inherit src;
|
||||
strictDeps = true;
|
||||
buildInputs = [ ];
|
||||
nativeBuildInputs = [
|
||||
pkgs.leptosfmt
|
||||
pkgs.cargo-leptos
|
||||
pkgs.binaryen
|
||||
pkgs.dart-sass
|
||||
];
|
||||
};
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
individualCrateArgs = commonArgs // {
|
||||
inherit cargoArtifacts;
|
||||
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
|
||||
doCheck = false;
|
||||
};
|
||||
fileSet = lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = lib.fileset.unions [
|
||||
./Cargo.lock
|
||||
./Cargo.toml
|
||||
./rust-analyzer.toml
|
||||
./rust-toolchain.toml
|
||||
./rustfmt.toml
|
||||
./styles
|
||||
./src
|
||||
./public
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
rustPackage = craneLib.buildPackage (
|
||||
individualCrateArgs
|
||||
// {
|
||||
pname = "mx-aliases";
|
||||
src = fileSet;
|
||||
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [ pkgs.makeWrapper ];
|
||||
buildPhaseCargoCommand = ''
|
||||
cargoBuildLog=$(mktemp cargoBuildLogXXXX.json)
|
||||
cargo leptos build --release > "$cargoBuildLog"
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin/
|
||||
cp target/release/mx-aliases $out/bin/
|
||||
cp -r target/mx-aliases $out/lib
|
||||
'';
|
||||
postFixup = ''
|
||||
wrapProgram $out/bin/mx-aliases \
|
||||
--set PATH "${lib.makeBinPath runtimeInputs}" \
|
||||
--set LEPTOS_SITE_ROOT $out/lib \
|
||||
--set LEPTOS_SITE_PKG_DIR assets
|
||||
'';
|
||||
meta = {
|
||||
mainProgram = "mx-aliases";
|
||||
};
|
||||
}
|
||||
);
|
||||
checks = {
|
||||
mx-aliases-clippy = craneLib.cargoClippy (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||
}
|
||||
);
|
||||
mx-aliases-doc = craneLib.cargoDoc (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
}
|
||||
);
|
||||
mx-aliases-fmt = craneLib.cargoFmt (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
}
|
||||
);
|
||||
# Not used currently, as I have some other formatter changing toml formatting
|
||||
# not sure where it comes from, but I need to find out and decide on a formatter
|
||||
mx-aliases-toml-fmt = craneLib.taploFmt {
|
||||
src = lib.sources.sourceFilesBySuffices src [ ".toml" ];
|
||||
};
|
||||
mx-aliases-audit = craneLib.cargoAudit {
|
||||
inherit src advisory-db;
|
||||
};
|
||||
};
|
||||
devDeps = [
|
||||
rustToolchain
|
||||
]
|
||||
++ commonArgs.buildInputs
|
||||
++ commonArgs.nativeBuildInputs;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue