aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix70
1 files changed, 70 insertions, 0 deletions
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..bc7afc9
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,70 @@
+
+{pkgs ? import (import ./nix/sources.nix).nixpkgs {}}:
+
+let
+ defaultcards = pkgs.copyPathToStore ./cards.yaml;
+ drvs = with pkgs; rec {
+
+ # server derivation generated using cabal2nix
+ uplcg-server =
+ { mkDerivation, aeson, async, base, blaze-html, bytestring
+ , elm-bridge, fast-logger, hashable, http-types, lens, lib, mtl
+ , process, random, scotty, stm, template-haskell, text, time
+ , unordered-containers, uuid, vector, vector-algorithms
+ , vector-instances, vector-shuffling, wai, wai-extra
+ , wai-websockets, warp, websockets, yaml }:
+
+ mkDerivation {
+ pname = "uplcg";
+ version = "0.1.0";
+ src = ./server;
+ isLibrary = true;
+ isExecutable = true;
+ libraryHaskellDepends = [
+ aeson async base blaze-html bytestring elm-bridge fast-logger
+ hashable http-types lens mtl process random scotty stm
+ template-haskell text time unordered-containers uuid vector
+ vector-algorithms vector-instances vector-shuffling wai wai-extra
+ wai-websockets warp websockets yaml
+ ];
+ executableHaskellDepends = [ base ];
+ description = "Untitled PL Card Game";
+ license = lib.licenses.bsd3;
+
+ # TODO: get the actual version hash in here
+ patchPhase = ''
+ rm lib/Uplcg/Version.hs
+ echo "module Uplcg.Version (version) where" > lib/Uplcg/Version.hs
+ echo "version :: String" >> lib/Uplcg/Version.hs
+ echo "version = \"nixpkgs-uplcg\"" >> lib/Uplcg/Version.hs
+ '';
+ };
+
+ uplcg-client = { cards ? defaultcards, server}:
+ stdenv.mkDerivation {
+ name = "uplcg-client";
+ src = ./client;
+
+ buildInputs = [ elmPackages.elm ];
+
+ buildPhase = elmPackages.fetchElmDeps {
+ elmPackages = import ./client/elm-srcs.nix;
+ elmVersion = "0.19.1";
+ registryDat = ./client/registry.dat;
+ };
+
+ installPhase = ''
+ mkdir -p $out/assets
+ cp -r $src/* .
+ ${server}/bin/uplcg-generate-elm-types > src/Messages.elm
+ elm make src/Client.elm --optimize --output client.js
+ cp client.js $out/assets
+ cp style.css $out/assets
+ cp ${cards} $out/assets/cards.yaml
+ '';
+ };
+ };
+in with pkgs.lib; rec {
+ client = callPackageWith { inherit server; } drvs.uplcg-client {};
+ server = pkgs.haskellPackages.callPackage drvs.uplcg-server {};
+}