From 62ef80a1e58da2bfc25f2720a1e4fc78b9e55f9b Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Mon, 17 Apr 2023 15:46:40 -0400
Subject: [PATCH] Set up Nix derivations for our unpublished Haskell library
 dependencies

Each generated with `cabal2nix https://.../` and then mangled by alejandro
---
 flake.lock                      |   8 +-
 flake.nix                       |   8 ++
 nix/haskell-packages.nix        |   4 +
 nix/tahoe-chk.nix               | 123 +++++++++++++++++++++++++++++++
 nix/tahoe-great-black-swamp.nix | 125 ++++++++++++++++++++++++++++++++
 5 files changed, 264 insertions(+), 4 deletions(-)
 create mode 100644 nix/haskell-packages.nix
 create mode 100644 nix/tahoe-chk.nix
 create mode 100644 nix/tahoe-great-black-swamp.nix

diff --git a/flake.lock b/flake.lock
index 6c3fe1b..9a56af9 100644
--- a/flake.lock
+++ b/flake.lock
@@ -75,11 +75,11 @@
         "pre-commit-hooks": "pre-commit-hooks"
       },
       "locked": {
-        "lastModified": 1677773826,
-        "narHash": "sha256-xJmOtHugr4k2zNhP/AF6JdIUnIEyM+TEspLn2n5kloc=",
+        "lastModified": 1681762240,
+        "narHash": "sha256-+PLx9xHBvV70dA7Gy/+YTH1w3PcSOrGV0z0rGxts8jU=",
         "ref": "main",
-        "rev": "d3a83fdd9563546ca41771186427638e685a2e2b",
-        "revCount": 9,
+        "rev": "a51e591b7fdf8881ac0237452691df7b1aceecd3",
+        "revCount": 10,
         "type": "git",
         "url": "https://whetstone.private.storage/jcalderone/hs-flake-utils.git"
       },
diff --git a/flake.nix b/flake.nix
index 3e41a5a..4a94328 100644
--- a/flake.nix
+++ b/flake.nix
@@ -21,12 +21,20 @@
       # Get a nixpkgs customized for this system and including our overlay.
       pkgs = import nixpkgs {
         inherit system;
+        config = {
+          # XXX haskellPackages.language-ecmascript is marked as broken.  It
+          # is a dependency of an executable of tahoe-great-black-swamp (which
+          # we don't use, but gets dragged in because we depend on the
+          # tahoe-great-black-swamp library).
+          allowBroken = true;
+        };
       };
       hslib = hs-flake-utils.lib {
         inherit pkgs;
         src = ./.;
         compilerVersion = ghcVersion;
         packageName = "gbs-downloader";
+        hsPkgsOverrides = import ./nix/haskell-packages.nix;
       };
     in {
       checks = hslib.checks {};
diff --git a/nix/haskell-packages.nix b/nix/haskell-packages.nix
new file mode 100644
index 0000000..4162d14
--- /dev/null
+++ b/nix/haskell-packages.nix
@@ -0,0 +1,4 @@
+hfinal: hprev: {
+  tahoe-chk = hfinal.callPackage ./tahoe-chk.nix {};
+  tahoe-great-black-swamp = hfinal.callPackage ./tahoe-great-black-swamp.nix {};
+}
diff --git a/nix/tahoe-chk.nix b/nix/tahoe-chk.nix
new file mode 100644
index 0000000..d903eed
--- /dev/null
+++ b/nix/tahoe-chk.nix
@@ -0,0 +1,123 @@
+{
+  mkDerivation,
+  aeson,
+  async,
+  base,
+  base32,
+  base64,
+  binary,
+  bytestring,
+  cereal,
+  cipher-aes128,
+  concurrency,
+  containers,
+  crypto-api,
+  cryptonite,
+  directory,
+  extra,
+  fec,
+  fetchgit,
+  filepath,
+  hedgehog,
+  lib,
+  megaparsec,
+  memory,
+  monad-loops,
+  mtl,
+  network-byte-order,
+  optparse-applicative,
+  parser-combinators,
+  primitive,
+  scientific,
+  tagged,
+  tasty,
+  tasty-hedgehog,
+  tasty-hunit,
+  temporary,
+  text,
+  tree-diff,
+  utility-ht,
+  vector,
+  yaml,
+}:
+mkDerivation {
+  pname = "tahoe-chk";
+  version = "0.1.0.0";
+  src = fetchgit {
+    url = "https://whetstone.private.storage/PrivateStorage/tahoe-chk.git";
+    sha256 = "1gbrf2j8zmy1772rxywi5ld8y7rnfqccxwr1igbbwxaj5lbphcsq";
+    rev = "1de296b50c4269d95097d924fac34f0725e8fa9e";
+    fetchSubmodules = true;
+  };
+  isLibrary = true;
+  isExecutable = true;
+  libraryHaskellDepends = [
+    aeson
+    async
+    base
+    base32
+    base64
+    binary
+    bytestring
+    cereal
+    cipher-aes128
+    concurrency
+    containers
+    crypto-api
+    cryptonite
+    directory
+    extra
+    fec
+    filepath
+    megaparsec
+    memory
+    monad-loops
+    mtl
+    network-byte-order
+    parser-combinators
+    primitive
+    tagged
+    text
+    tree-diff
+    utility-ht
+  ];
+  executableHaskellDepends = [
+    base
+    base32
+    bytestring
+    optparse-applicative
+    text
+  ];
+  testHaskellDepends = [
+    aeson
+    base
+    base32
+    base64
+    binary
+    bytestring
+    cereal
+    cipher-aes128
+    containers
+    crypto-api
+    cryptonite
+    directory
+    fec
+    filepath
+    hedgehog
+    megaparsec
+    scientific
+    tagged
+    tasty
+    tasty-hedgehog
+    tasty-hunit
+    temporary
+    text
+    tree-diff
+    vector
+    yaml
+  ];
+  homepage = "https://gitlab.com/exarkun/chk.hs";
+  description = "The Tahoe-LAFS' Content-Hash-Key (CHK) cryptographic protocol";
+  license = lib.licenses.bsd3;
+  mainProgram = "tahoe-chk-encrypt";
+}
diff --git a/nix/tahoe-great-black-swamp.nix b/nix/tahoe-great-black-swamp.nix
new file mode 100644
index 0000000..c3c1ac0
--- /dev/null
+++ b/nix/tahoe-great-black-swamp.nix
@@ -0,0 +1,125 @@
+{
+  mkDerivation,
+  aeson,
+  async,
+  base,
+  base32string,
+  base64-bytestring,
+  binary,
+  bytestring,
+  cborg,
+  cborg-json,
+  containers,
+  deriving-aeson,
+  directory,
+  fetchgit,
+  filepath,
+  foldl,
+  hspec,
+  hspec-expectations,
+  hspec-wai,
+  http-api-data,
+  http-media,
+  http-types,
+  lib,
+  optparse-applicative,
+  primitive,
+  QuickCheck,
+  quickcheck-instances,
+  safe-exceptions,
+  scientific,
+  serialise,
+  servant-client,
+  servant-docs,
+  servant-js,
+  servant-server,
+  temporary,
+  text,
+  unordered-containers,
+  utf8-string,
+  vector,
+  wai,
+  wai-extra,
+  warp,
+  warp-tls,
+}:
+mkDerivation {
+  pname = "tahoe-great-black-swamp";
+  version = "0.1.0.0";
+  src = fetchgit {
+    url = "https://whetstone.private.storage/PrivateStorage/tahoe-great-black-swamp.git";
+    sha256 = "07y0pggiws4cc827w3afnyscbqb4pifvb416l0pyhpcbpiz7fpk1";
+    rev = "55152d2bbb8567c2f3f53ee11d147bedca5c2f8d";
+    fetchSubmodules = true;
+  };
+  isLibrary = true;
+  isExecutable = true;
+  libraryHaskellDepends = [
+    aeson
+    async
+    base
+    base64-bytestring
+    binary
+    bytestring
+    cborg
+    cborg-json
+    containers
+    deriving-aeson
+    directory
+    filepath
+    foldl
+    http-api-data
+    http-media
+    http-types
+    primitive
+    safe-exceptions
+    scientific
+    serialise
+    servant-client
+    servant-docs
+    servant-server
+    text
+    unordered-containers
+    utf8-string
+    vector
+    wai
+    warp
+    warp-tls
+  ];
+  executableHaskellDepends = [
+    base
+    filepath
+    optparse-applicative
+    servant-js
+    warp
+  ];
+  testHaskellDepends = [
+    aeson
+    async
+    base
+    base32string
+    binary
+    bytestring
+    containers
+    deriving-aeson
+    directory
+    filepath
+    foldl
+    hspec
+    hspec-expectations
+    hspec-wai
+    http-types
+    primitive
+    QuickCheck
+    quickcheck-instances
+    safe-exceptions
+    temporary
+    text
+    unordered-containers
+    vector
+    wai-extra
+  ];
+  homepage = "https://whetstone.private.storage/PrivateStorage/tahoe-great-black-swamp";
+  description = "An implementation of the \"Great Black Swamp\" LAFS protocol";
+  license = lib.licenses.bsd3;
+}
-- 
GitLab