aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml1
-rw-r--r--default.nix44
-rw-r--r--flake.lock48
-rw-r--r--flake.nix79
-rw-r--r--src/luax/tests/preprocessor.rs5
5 files changed, 176 insertions, 1 deletions
diff --git a/Cargo.toml b/Cargo.toml
index d99526c..07f5951 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,6 +2,7 @@
name = "reluax"
version = "0.1.0"
edition = "2021"
+description = "A LuaX-based web framework"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..de6b72a
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,44 @@
+{ lib
+, naersk
+, targetPlatform
+, pkg-config
+, libiconv
+, rustfmt
+, cargo
+, rustc
+, luajit
+}:
+
+let
+ cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
+in
+
+naersk.lib."${targetPlatform.system}".buildPackage rec {
+ src = ./.;
+
+ buildInputs = [
+ rustfmt
+ pkg-config
+ cargo
+ rustc
+ libiconv
+ luajit
+ ];
+ checkInputs = [ cargo rustc ];
+
+ doCheck = true;
+ CARGO_BUILD_INCREMENTAL = "false";
+ RUST_BACKTRACE = "full";
+ copyLibs = true;
+
+ name = cargoToml.package.name;
+ version = cargoToml.package.version;
+
+ meta = with lib; {
+ description = cargoToml.package.description;
+ homepage = cargoToml.package.homepage;
+ license = with licenses; [ mit ];
+ maintainers = with maintainers; [ ];
+ };
+}
+
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..ead9452
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,48 @@
+{
+ "nodes": {
+ "naersk": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1698420672,
+ "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
+ "owner": "nmattia",
+ "repo": "naersk",
+ "rev": "aeb58d5e8faead8980a807c840232697982d47b9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nmattia",
+ "repo": "naersk",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1704842529,
+ "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "naersk": "naersk",
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..0417539
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,79 @@
+{
+ description = "Reluax, a LuaX web framework";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ naersk.url = "github:nmattia/naersk";
+ naersk.inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ outputs = { self, nixpkgs, naersk }:
+ let
+ cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
+ supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
+ forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
+ in
+ {
+ overlay = final: prev: {
+ "${cargoToml.package.name}" = final.callPackage ./. { inherit naersk; };
+ };
+
+ packages = forAllSystems (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [
+ self.overlay
+ ];
+ };
+ in
+ {
+ "${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
+ });
+
+
+ defaultPackage = forAllSystems (system: (import nixpkgs {
+ inherit system;
+ overlays = [ self.overlay ];
+ })."${cargoToml.package.name}");
+
+ checks = forAllSystems (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [
+ self.overlay
+ ];
+ };
+ in
+ {
+ format = pkgs.runCommand "check-format"
+ {
+ buildInputs = with pkgs; [ rustfmt cargo ];
+ } ''
+ ${pkgs.rustfmt}/bin/cargo-fmt fmt --manifest-path ${./.}/Cargo.toml -- --check
+ ${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check ${./.}
+ touch $out # it worked!
+ '';
+ "${cargoToml.package.name}" = pkgs."${cargoToml.package.name}";
+ });
+ devShell = forAllSystems (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [ self.overlay ];
+ };
+ in
+ pkgs.mkShell {
+ inputsFrom = with pkgs; [
+ pkgs."${cargoToml.package.name}"
+ ];
+ buildInputs = with pkgs; [
+ rustfmt
+ nixpkgs-fmt
+ ];
+ LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
+ });
+ };
+}
+
diff --git a/src/luax/tests/preprocessor.rs b/src/luax/tests/preprocessor.rs
index 6769288..9411126 100644
--- a/src/luax/tests/preprocessor.rs
+++ b/src/luax/tests/preprocessor.rs
@@ -239,7 +239,10 @@ fn function_returning_nested_html_with_code() -> Result<()> {
#[test]
fn component() -> Result<()> {
- compare_output("return <Hello />", "return Hello ({ attrs={}, children={} })")
+ compare_output(
+ "return <Hello />",
+ "return Hello ({ attrs={}, children={} })",
+ )
}
#[test]