From 92c1ef1af95740077282d773242fdd1820c8d15b Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sun, 7 Mar 2021 23:52:19 +0100 Subject: Added basic nixos module (and restructured some files) Right now, this is capable of setting up a running instance of picarones in a couple lines of config (both backend server and the webapp, using nginx). More options should still be added, especially to make the backend's port configurable (but this requires adding features to the haskell code) --- picarones-elm/cover.html | 19 ------------------- picarones-elm/default.nix | 24 ++++++++++++++++-------- picarones-elm/index.html | 21 +++------------------ picarones-elm/slide.html | 34 ++++++++++++++++++++++++++++++++++ picarones-elm/src/Cover.elm | 2 +- 5 files changed, 54 insertions(+), 46 deletions(-) delete mode 100644 picarones-elm/cover.html create mode 100644 picarones-elm/slide.html (limited to 'picarones-elm') diff --git a/picarones-elm/cover.html b/picarones-elm/cover.html deleted file mode 100644 index d92eba9..0000000 --- a/picarones-elm/cover.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Main - - - - - -
- - - diff --git a/picarones-elm/default.nix b/picarones-elm/default.nix index ed71959..b5e9d9d 100644 --- a/picarones-elm/default.nix +++ b/picarones-elm/default.nix @@ -1,9 +1,10 @@ -{ nixpkgs ? -, config ? {} +{ stdenv +, elmPackages +, lib +, baseurl ? "example.org" +, serverurl ? "wss://example.org" }: -with (import nixpkgs config); - let mkDerivation = { srcs ? ./elm-srcs.nix @@ -13,13 +14,15 @@ let , targets ? [] , registryDat ? ./registry.dat , outputJavaScript ? true + , patchPhase ? "" + , ... }: stdenv.mkDerivation { - inherit name src; + inherit name src patchPhase; buildInputs = [ elmPackages.elm ]; - buildPhase = pkgs.elmPackages.fetchElmDeps { + buildPhase = elmPackages.fetchElmDeps { elmPackages = import srcs; elmVersion = "0.19.1"; inherit registryDat; @@ -32,7 +35,7 @@ let mkdir -p $out/share/doc ${lib.concatStrings (map (module: '' echo "compiling ${elmfile module}" - elm make ${elmfile module} --output $out/${module}.${extension} + elm make ${elmfile module} --optimize --output $out/${module}.${extension} '') targets)} cp *.html $out cp *.css $out @@ -41,7 +44,12 @@ let }; in mkDerivation { name = "picarones"; - + + patchPhase = '' + substituteInPlace index.html --replace "{{ baseurl }}" ${lib.escapeShellArg baseurl} + substituteInPlace slide.html --replace "{{ serverurl }}" ${lib.escapeShellArg serverurl} + ''; + srcs = ./elm-srcs.nix; src = ./.; targets = ["Main" "Cover"]; diff --git a/picarones-elm/index.html b/picarones-elm/index.html index 4fe72c7..156eb9c 100644 --- a/picarones-elm/index.html +++ b/picarones-elm/index.html @@ -3,32 +3,17 @@ Main - +
diff --git a/picarones-elm/slide.html b/picarones-elm/slide.html new file mode 100644 index 0000000..a72fb3c --- /dev/null +++ b/picarones-elm/slide.html @@ -0,0 +1,34 @@ + + + + + Main + + + + + +
+ + + diff --git a/picarones-elm/src/Cover.elm b/picarones-elm/src/Cover.elm index 5c9d040..fee40c0 100644 --- a/picarones-elm/src/Cover.elm +++ b/picarones-elm/src/Cover.elm @@ -56,7 +56,7 @@ mkNumberInput i = mkLink : Model -> Html Msg mkLink (p, max, baseurl) = case p of "" -> text "(none yet)" - prefix -> let link = baseurl ++ "/slide#" ++ prefix ++ "#" ++ (String.fromInt max) + prefix -> let link = baseurl ++ "/slide.html#" ++ prefix ++ "#" ++ (String.fromInt max) in a [ href link ] [ text link ] -- cgit v1.2.3