about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-12T15·28+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-12T15·28+0100
commit2da4b12266322a3cfb7aa31cc24cfa591eb4e3d0 (patch)
treebe1a0fceb5f2e213f077ad4924c71942551687d4
parent4ea55dd0130f33877deed5fc6822ac4d80ce3aef (diff)
Consume buildHaskell functions
Use the newly defined `buildHaskell` function for a few of my existing Haskell
projects. So far, it works as intended!
-rw-r--r--scratch/brilliant/default.nix30
-rw-r--r--website/sandbox/learnpianochords/src/server/default.nix42
-rw-r--r--website/sandbox/learnpianochords/src/server/shell.nix30
3 files changed, 45 insertions, 57 deletions
diff --git a/scratch/brilliant/default.nix b/scratch/brilliant/default.nix
index 5a0ece741764..5fba20d6704d 100644
--- a/scratch/brilliant/default.nix
+++ b/scratch/brilliant/default.nix
@@ -1,26 +1,16 @@
 let
-  pkgs = import (builtins.fetchGit {
-    url = "https://github.com/NixOS/nixpkgs-channels";
-    ref = "nixos-20.03";
-    rev = "afa9ca61924f05aacfe495a7ad0fd84709d236cc";
-  }) {};
-
-  ghc = pkgs.haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
-    optparse-applicative
-    unordered-containers
-    split
-  ]);
-in pkgs.stdenv.mkDerivation {
+  briefcase = import /home/wpcarro/briefcase {};
+in briefcase.buildHaskell.program {
   name = "transform-keyboard";
-  buildInputs = [];
-  src = builtins.path {
+  srcs = builtins.path {
     path = ./.;
     name = "transform-keyboard-src";
   };
-  buildPhase = ''
-    ${ghc}/bin/ghc ./Main.hs
-  '';
-  installPhase = ''
-    mkdir -p $out && mv Main $out/transform-keyboard
-  '';
+  deps = hpkgs: with hpkgs; [
+    optparse-applicative
+    unordered-containers
+    split
+    rio
+  ];
+  ghcExtensions = [];
 }
diff --git a/website/sandbox/learnpianochords/src/server/default.nix b/website/sandbox/learnpianochords/src/server/default.nix
index a39f89b043ba..4efe1183d16a 100644
--- a/website/sandbox/learnpianochords/src/server/default.nix
+++ b/website/sandbox/learnpianochords/src/server/default.nix
@@ -1,27 +1,27 @@
 let
-  pkgs = import /home/wpcarro/nixpkgs {};
-  ghc = pkgs.haskellPackages.ghcWithPackages (hpkgs: [
-    hpkgs.servant-server
-    hpkgs.aeson
-    hpkgs.wai-cors
-    hpkgs.warp
-    hpkgs.jwt
-    hpkgs.unordered-containers
-    hpkgs.base64
-    hpkgs.http-conduit
-    hpkgs.rio
-  ]);
-in pkgs.stdenv.mkDerivation {
-  name = "LearnPianoChords-server";
+  briefcase = import /home/wpcarro/briefcase {};
+in briefcase.buildHaskell.program {
+  name = "server";
   srcs = builtins.path {
     path = ./.;
     name = "LearnPianoChords-server-src";
   };
-  buildPhase = ''
-    ${ghc} -O Main.hs \
-      -XOverloadedStrings \
-      -XNoImplicitPrelude \
-      -XRecordWildCards \
-      -XTypeApplications
-  '';
+  ghcExtensions = [
+    "OverloadedStrings"
+    "NoImplicitPrelude"
+    "RecordWildCards"
+    "TypeApplications"
+  ];
+  deps = hpkgs: with hpkgs; [
+    servant-server
+    aeson
+    wai-cors
+    warp
+    jwt
+    unordered-containers
+    base64
+    http-conduit
+    rio
+    envy
+  ];
 }
diff --git a/website/sandbox/learnpianochords/src/server/shell.nix b/website/sandbox/learnpianochords/src/server/shell.nix
index 6cb5e19e99fa..4d787184bd4a 100644
--- a/website/sandbox/learnpianochords/src/server/shell.nix
+++ b/website/sandbox/learnpianochords/src/server/shell.nix
@@ -1,19 +1,17 @@
 let
-  pkgs = import /home/wpcarro/nixpkgs {};
-in pkgs.mkShell {
-  buildInputs = with pkgs; [
-    (haskellPackages.ghcWithPackages (hpkgs: [
-      hpkgs.hspec
-      hpkgs.servant-server
-      hpkgs.aeson
-      hpkgs.wai-cors
-      hpkgs.warp
-      hpkgs.jwt
-      hpkgs.unordered-containers
-      hpkgs.base64
-      hpkgs.http-conduit
-      hpkgs.rio
-      hpkgs.envy
-    ]))
+  briefcase = import /home/wpcarro/briefcase {};
+in briefcase.buildHaskell.shell {
+  deps = hpkgs: with hpkgs; [
+    hspec
+    servant-server
+    aeson
+    wai-cors
+    warp
+    jwt
+    unordered-containers
+    base64
+    http-conduit
+    rio
+    envy
   ];
 }