diff --git a/.gitignore b/.gitignore index 21ef6af..4978251 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/target +/backend/target mi.db diff --git a/Cargo.lock b/backend/Cargo.lock similarity index 100% rename from Cargo.lock rename to backend/Cargo.lock diff --git a/Cargo.toml b/backend/Cargo.toml similarity index 100% rename from Cargo.toml rename to backend/Cargo.toml diff --git a/diesel.toml b/backend/diesel.toml similarity index 100% rename from diesel.toml rename to backend/diesel.toml diff --git a/migrations/.gitkeep b/backend/migrations/.gitkeep similarity index 100% rename from migrations/.gitkeep rename to backend/migrations/.gitkeep diff --git a/migrations/2020-09-13-154110_switches/down.sql b/backend/migrations/2020-09-13-154110_switches/down.sql similarity index 100% rename from migrations/2020-09-13-154110_switches/down.sql rename to backend/migrations/2020-09-13-154110_switches/down.sql diff --git a/migrations/2020-09-13-154110_switches/up.sql b/backend/migrations/2020-09-13-154110_switches/up.sql similarity index 100% rename from migrations/2020-09-13-154110_switches/up.sql rename to backend/migrations/2020-09-13-154110_switches/up.sql diff --git a/migrations/2020-09-13-155542_system/down.sql b/backend/migrations/2020-09-13-155542_system/down.sql similarity index 100% rename from migrations/2020-09-13-155542_system/down.sql rename to backend/migrations/2020-09-13-155542_system/down.sql diff --git a/migrations/2020-09-13-155542_system/up.sql b/backend/migrations/2020-09-13-155542_system/up.sql similarity index 100% rename from migrations/2020-09-13-155542_system/up.sql rename to backend/migrations/2020-09-13-155542_system/up.sql diff --git a/migrations/2020-09-13-163914_webmention/down.sql b/backend/migrations/2020-09-13-163914_webmention/down.sql similarity index 100% rename from migrations/2020-09-13-163914_webmention/down.sql rename to backend/migrations/2020-09-13-163914_webmention/down.sql diff --git a/migrations/2020-09-13-163914_webmention/up.sql b/backend/migrations/2020-09-13-163914_webmention/up.sql similarity index 100% rename from migrations/2020-09-13-163914_webmention/up.sql rename to backend/migrations/2020-09-13-163914_webmention/up.sql diff --git a/src/build.rs b/backend/src/build.rs similarity index 100% rename from src/build.rs rename to backend/src/build.rs diff --git a/src/main.rs b/backend/src/main.rs similarity index 100% rename from src/main.rs rename to backend/src/main.rs diff --git a/src/models.rs b/backend/src/models.rs similarity index 100% rename from src/models.rs rename to backend/src/models.rs diff --git a/src/schema.rs b/backend/src/schema.rs similarity index 100% rename from src/schema.rs rename to backend/src/schema.rs diff --git a/templates/foo.rs.html b/backend/templates/foo.rs.html similarity index 100% rename from templates/foo.rs.html rename to backend/templates/foo.rs.html diff --git a/frontend/default.nix b/frontend/default.nix new file mode 100644 index 0000000..af7d671 --- /dev/null +++ b/frontend/default.nix @@ -0,0 +1,53 @@ +{ nixpkgs ? +, config ? {} +}: + +with (import nixpkgs config); + +let + mkDerivation = + { srcs ? ./elm-srcs.nix + , src + , name + , srcdir ? "./src" + , targets ? [] + , registryDat ? ./registry.dat + , outputJavaScript ? false + }: + stdenv.mkDerivation { + inherit name src; + + buildInputs = [ elmPackages.elm ] + ++ lib.optional outputJavaScript nodePackages_10_x.uglify-js; + + buildPhase = pkgs.elmPackages.fetchElmDeps { + elmPackages = import srcs; + elmVersion = "0.19.1"; + inherit registryDat; + }; + + installPhase = let + elmfile = module: "${srcdir}/${builtins.replaceStrings ["."] ["/"] module}.elm"; + extension = if outputJavaScript then "js" else "html"; + in '' + mkdir -p $out/share/doc + ${lib.concatStrings (map (module: '' + echo "compiling ${elmfile module}" + elm make ${elmfile module} --output $out/${module}.${extension} --docs $out/share/doc/${module}.json + ${lib.optionalString outputJavaScript '' + echo "minifying ${elmfile module}" + uglifyjs $out/${module}.${extension} --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' \ + | uglifyjs --mangle --output=$out/${module}.min.${extension} + ''} + '') targets)} + ''; + }; +in mkDerivation { + name = "mi-frontend-0.1.0"; + srcs = ./elm-srcs.nix; + src = ./.; + targets = ["Main"]; + srcdir = "./src"; + outputJavaScript = true; +} + diff --git a/frontend/elm-srcs.nix b/frontend/elm-srcs.nix new file mode 100644 index 0000000..63df5b9 --- /dev/null +++ b/frontend/elm-srcs.nix @@ -0,0 +1,37 @@ +{ + + "elm/html" = { + sha256 = "1n3gpzmpqqdsldys4ipgyl1zacn0kbpc3g4v3hdpiyfjlgh8bf3k"; + version = "1.0.0"; + }; + + "elm/browser" = { + sha256 = "0nagb9ajacxbbg985r4k9h0jadqpp0gp84nm94kcgbr5sf8i9x13"; + version = "1.0.2"; + }; + + "elm/core" = { + sha256 = "19w0iisdd66ywjayyga4kv2p1v9rxzqjaxhckp8ni6n8i0fb2dvf"; + version = "1.0.5"; + }; + + "elm/json" = { + sha256 = "0kjwrz195z84kwywaxhhlnpl3p251qlbm5iz6byd6jky2crmyqyh"; + version = "1.1.3"; + }; + + "elm/url" = { + sha256 = "0av8x5syid40sgpl5vd7pry2rq0q4pga28b4yykn9gd9v12rs3l4"; + version = "1.0.0"; + }; + + "elm/time" = { + sha256 = "0vch7i86vn0x8b850w1p69vplll1bnbkp8s383z7pinyg94cm2z1"; + version = "1.0.0"; + }; + + "elm/virtual-dom" = { + sha256 = "0q1v5gi4g336bzz1lgwpn5b1639lrn63d8y6k6pimcyismp2i1yg"; + version = "1.0.2"; + }; +} diff --git a/frontend/elm.json b/frontend/elm.json new file mode 100644 index 0000000..dea3450 --- /dev/null +++ b/frontend/elm.json @@ -0,0 +1,24 @@ +{ + "type": "application", + "source-directories": [ + "src" + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/browser": "1.0.2", + "elm/core": "1.0.5", + "elm/html": "1.0.0" + }, + "indirect": { + "elm/json": "1.1.3", + "elm/time": "1.0.0", + "elm/url": "1.0.0", + "elm/virtual-dom": "1.0.2" + } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} + } +} diff --git a/frontend/registry.dat b/frontend/registry.dat new file mode 100644 index 0000000..7d12c07 Binary files /dev/null and b/frontend/registry.dat differ diff --git a/frontend/result b/frontend/result new file mode 120000 index 0000000..f520983 --- /dev/null +++ b/frontend/result @@ -0,0 +1 @@ +/nix/store/r27d8p3jcpydwx8g4v2svl7p9f7f3f3k-mi-frontend-0.1.0 \ No newline at end of file diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm new file mode 100644 index 0000000..8f4839c --- /dev/null +++ b/frontend/src/Main.elm @@ -0,0 +1,7 @@ +module Main exposing (main) + +import Html exposing (Html, text) + +main : Html msg +main = + text "Hello, World!" diff --git a/shell.nix b/shell.nix index 2a816d5..7246ab2 100644 --- a/shell.nix +++ b/shell.nix @@ -8,6 +8,7 @@ let in pkgs.mkShell { buildInputs = with pkgs; [ + # rust ruststable pkgconfig openssl @@ -17,6 +18,12 @@ in pkgs.mkShell { diesel-cli sqlite + # elm + elmPackages.elm + elmPackages.elm-format + elmPackages.elm-language-server + elm2nix + # keep this line if you use bash bashInteractive ];