Skip to content

Commit

Permalink
Compile all dependencies with nix
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaymankar committed Apr 21, 2022
1 parent 2ba906a commit c271307
Show file tree
Hide file tree
Showing 36 changed files with 1,664 additions and 24 deletions.
7 changes: 4 additions & 3 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ watch_file nix/overlays/wire-cli.nix
nix build -o $PWD/.direnv
env="$PWD/.direnv"

load_prefix "${env}"
path_add XDG_DATA_DIRS "${env}/share"
path_add GI_TYPELIB_PATH "${env}/lib/girepository-1.0"
PATH_add "${env}/bin"

# path_add XDG_DATA_DIRS "${env}/share"
# path_add GI_TYPELIB_PATH "${env}/lib/girepository-1.0"
6 changes: 2 additions & 4 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
import Autopack (defaultMainAutoModules)

main :: IO ()
main = defaultMainAutoModules
import Distribution.Simple
main = defaultMain
48 changes: 48 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{ mkDerivation, aeson, async, base, base64, bytestring
, bytestring-conversion, containers, cookie, cryptobox-haskell
, deriving-aeson, directory, extra, filepath, generic-random
, ghc-source-gen, gi-gio, gi-gio-hs-list-model, gi-glib, gi-gtk
, gi-pango, haskell-gi-base, HsOpenSSL, HsOpenSSL-x509-system
, hspec, hspec-core, hspec-discover, http-client
, http-client-openssl, http-client-websockets, http-types, keys
, lens-family, lib, network-arbitrary, network-uri
, optparse-applicative, polysemy, polysemy-mocks, polysemy-plugin
, polysemy-zoo, profunctors, proto-lens, proto-lens-arbitrary
, QuickCheck, quickcheck-instances, random, retry
, schema-profunctor, servant, servant-client, servant-client-core
, shelly, swagger2, temporary, text, time, types-common, unagi-chan
, unordered-containers, uuid, websockets, wire-api, wire-message
}:
mkDerivation {
pname = "wire-cli";
version = "0.1.0.0";
src = ./.;
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
aeson async base base64 bytestring bytestring-conversion containers
cookie cryptobox-haskell deriving-aeson directory extra filepath
ghc-source-gen gi-gio gi-gio-hs-list-model gi-glib gi-gtk gi-pango
haskell-gi-base HsOpenSSL HsOpenSSL-x509-system http-client
http-client-openssl http-client-websockets http-types keys
lens-family network-uri optparse-applicative polysemy
polysemy-plugin polysemy-zoo profunctors proto-lens
schema-profunctor servant servant-client servant-client-core
swagger2 text time types-common unagi-chan unordered-containers
uuid websockets wire-api wire-message
];
executableHaskellDepends = [ base ];
testHaskellDepends = [
aeson base base64 bytestring containers cookie cryptobox-haskell
generic-random HsOpenSSL HsOpenSSL-x509-system hspec hspec-core
http-client http-client-openssl http-types lens-family
network-arbitrary network-uri optparse-applicative polysemy
polysemy-mocks polysemy-plugin polysemy-zoo proto-lens
proto-lens-arbitrary QuickCheck quickcheck-instances random retry
shelly temporary text time types-common unagi-chan uuid wire-api
wire-message
];
testToolDepends = [ hspec-discover ];
license = "unknown";
hydraPlatforms = lib.platforms.none;
}
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,44 @@
pkgs.harfbuzz.dev
pkgs.harfbuzz.out
pkgs.vulkan-loader.dev

# cabal2nix
pkgs.cabal2nix
pkgs.yq
];
};
packages.wire-cli =
let hlib = pkgs.haskell.lib;
haskellPackages = pkgs.haskell.packages.ghc8107.override {
overrides = hself: hsuper:
let generated = import ./nix/overlays/haskell/overrides.nix hself hsuper;
manual = {
wire-message =
let basic = hself.callPackage ./wire-message/default.nix {};
in hlib.addBuildTool basic pkgs.protobuf;
wire-cli = hself.callPackage ./default.nix {};
network-arbitrary = hlib.markUnbroken (hlib.doJailbreak hsuper.network-arbitrary);
polysemy-zoo = hlib.markUnbroken (hlib.doJailbreak hsuper.polysemy-zoo);
cql = hlib.markUnbroken hsuper.cql;
cql-io = hlib.dontCheck hsuper.cql-io;
lens-datetime = hlib.markUnbroken (hlib.doJailbreak hsuper.lens-datetime);
wai-predicates = hlib.markUnbroken hsuper.wai-predicates;
gi-gio-hs-list-model = hlib.markUnbroken hsuper.gi-gio-hs-list-model;
http-client-websockets = hlib.markUnbroken (hlib.dontCheck hsuper.http-client-websockets);
polysemy = hsuper.polysemy_1_7_1_0;
polysemy-plugin = hsuper.polysemy-plugin_0_4_3_0;
hsaml2 = hlib.dontCheck generated.hsaml2;
universe-base = hlib.addExtraLibrary hsuper.universe-base hsuper.OneTuple;
wire-message-proto-lens = hlib.addBuildTool generated.wire-message-proto-lens pkgs.protobuf;
hscim = hlib.doJailbreak generated.hscim;
bytestring-arbitrary = hlib.markUnbroken (hlib.doJailbreak hsuper.bytestring-arbitrary);
servant-server = hlib.dontCheck hsuper.servant-server;
singeltons = hlib.doJailbreak generated.singletons;
saml2-web-sso = hlib.dontCheck generated.saml2-web-sso;
};
in generated // manual;
};
in haskellPackages.wire-cli;
defaultPackage = packages.dev-env;
});
}
27 changes: 27 additions & 0 deletions nix/overlays/haskell/cassandra-util.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ mkDerivation, aeson, base, conduit, containers, cql, cql-io
, cql-io-tinylog, exceptions, fetchgit, hpack, imports, lens
, lens-aeson, lib, optparse-applicative, retry, split, text, time
, tinylog, uuid, wreq
}:
mkDerivation {
pname = "cassandra-util";
version = "0.16.5";
src = fetchgit {
url = "https://github.com/wireapp/wire-server";
sha256 = "0pq8kwdzs87ivjci8js8bspz50v15mjr36san88d044wq1jkv4fg";
rev = "7fe73c7338b397140f1aca12c79f320ac277d8c3";
fetchSubmodules = true;
};
postUnpack = "sourceRoot+=/libs/cassandra-util; echo source root reset to $sourceRoot";
libraryHaskellDepends = [
aeson base conduit containers cql cql-io cql-io-tinylog exceptions
imports lens lens-aeson optparse-applicative retry split text time
tinylog uuid wreq
];
libraryToolDepends = [ hpack ];
doHaddock = false;
doCheck = false;
prePatch = "hpack";
description = "Cassandra Utilities";
license = lib.licenses.agpl3Only;
}
22 changes: 22 additions & 0 deletions nix/overlays/haskell/cryptobox-haskell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ mkDerivation, base, bytestring, cryptobox, fetchgit, hashable
, lib, unordered-containers
}:
mkDerivation {
pname = "cryptobox-haskell";
version = "0.1.1";
src = fetchgit {
url = "https://github.com/wireapp/cryptobox-haskell";
sha256 = "1mf9wv5w4vmp36srabaq6nwmimvyjkvfiwm4krbdnf22vax7n2sn";
rev = "3a65e2fa055ae2f4ffaea4c168a3edfe8958d84d";
fetchSubmodules = true;
};
libraryHaskellDepends = [
base bytestring hashable unordered-containers
];
librarySystemDepends = [ cryptobox ];
doHaddock = false;
doCheck = false;
homepage = "https://github.com/wireapp/cryptobox-haskell/";
description = "Haskell bindings to cryptobox";
license = lib.licenses.gpl3Only;
}
20 changes: 20 additions & 0 deletions nix/overlays/haskell/deriving-swagger2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ mkDerivation, base, extra, fetchgit, hpack, imports, lib
, swagger2
}:
mkDerivation {
pname = "deriving-swagger2";
version = "0.1.0";
src = fetchgit {
url = "https://github.com/wireapp/wire-server";
sha256 = "0pq8kwdzs87ivjci8js8bspz50v15mjr36san88d044wq1jkv4fg";
rev = "7fe73c7338b397140f1aca12c79f320ac277d8c3";
fetchSubmodules = true;
};
postUnpack = "sourceRoot+=/libs/deriving-swagger2; echo source root reset to $sourceRoot";
libraryHaskellDepends = [ base extra imports swagger2 ];
libraryToolDepends = [ hpack ];
doHaddock = false;
doCheck = false;
prePatch = "hpack";
license = lib.licenses.agpl3Only;
}
35 changes: 35 additions & 0 deletions nix/overlays/haskell/extended.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ mkDerivation, aeson, base, bytestring, cassandra-util, containers
, errors, exceptions, extra, fetchgit, hpack, hspec, hspec-discover
, http-types, imports, lib, metrics-wai, optparse-applicative
, servant, servant-server, servant-swagger, string-conversions
, temporary, tinylog, wai
}:
mkDerivation {
pname = "extended";
version = "0.1.0";
src = fetchgit {
url = "https://github.com/wireapp/wire-server";
sha256 = "0pq8kwdzs87ivjci8js8bspz50v15mjr36san88d044wq1jkv4fg";
rev = "7fe73c7338b397140f1aca12c79f320ac277d8c3";
fetchSubmodules = true;
};
postUnpack = "sourceRoot+=/libs/extended; echo source root reset to $sourceRoot";
libraryHaskellDepends = [
aeson base bytestring cassandra-util containers errors exceptions
extra http-types imports metrics-wai optparse-applicative servant
servant-server servant-swagger string-conversions tinylog wai
];
libraryToolDepends = [ hpack ];
testHaskellDepends = [
aeson base bytestring cassandra-util containers errors exceptions
extra hspec http-types imports metrics-wai optparse-applicative
servant servant-server servant-swagger string-conversions temporary
tinylog wai
];
testToolDepends = [ hspec-discover ];
doHaddock = false;
doCheck = false;
prePatch = "hpack";
description = "Extended versions of common modules";
license = lib.licenses.agpl3Only;
}
43 changes: 43 additions & 0 deletions nix/overlays/haskell/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

set -euo pipefail

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

rm -f "$SCRIPT_DIR/"*.nix

overridesFile="$SCRIPT_DIR/overrides.nix"

echo "hsuper: hself: {" > "$overridesFile"

mkDrv() {
local drv name
drv=$(eval "$1")
name=$(echo "$drv" | sed -n 's|.*pname = "\(.*\)";|\1|p')
echo "$drv" > "$SCRIPT_DIR/$name.nix"
echo " $name = hself.callPackage ./$name.nix {};" >> "$overridesFile"
}

gitCabal2Nix=$(cat <<-'EOF'
.gitPins[] |
"cabal2nix \(.location) --no-check --no-haddock --revision \(.commit)" as $basecmd |
if .subdirs == null
then $basecmd
else (
.subdirs[] | "\($basecmd) --subpath \(.)"
)
end
EOF
)

while IFS="\n"; read cmd; do
mkDrv "$cmd"
done < <(yq -r "$gitCabal2Nix" "$SCRIPT_DIR/sources.yaml")

hackageCabal2Nix='.hackagePins[] | "cabal2nix cabal://\(.package)-\(.version) --no-check --no-haddock"'

while IFS="\n"; read cmd; do
mkDrv "$cmd"
done < <(yq -r "$hackageCabal2Nix" "$SCRIPT_DIR/sources.yaml")

echo "}" >> "$overridesFile"
40 changes: 40 additions & 0 deletions nix/overlays/haskell/hsaml2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{ mkDerivation, asn1-encoding, asn1-types, base, base64-bytestring
, bytestring, cryptonite, data-default, fetchgit, hpack, http-types
, HUnit, hxt, hxt-charproperties, hxt-http, hxt-unicode, invertible
, invertible-hxt, lens, lib, libxml2, memory, mtl, network-uri
, process, semigroups, silently, string-conversions
, template-haskell, time, utf8-string, x509, zlib
}:
mkDerivation {
pname = "hsaml2";
version = "0.1";
src = fetchgit {
url = "https://github.com/wireapp/hsaml2";
sha256 = "1y5ibjca4dbqknpr902rrjj94cklwrnl353y6kq5fdxl93v3kdq5";
rev = "b652ec6e69d1647e827cbee0fa290605ac09dc63";
fetchSubmodules = true;
};
libraryHaskellDepends = [
asn1-encoding asn1-types base base64-bytestring bytestring
cryptonite data-default http-types hxt hxt-charproperties
hxt-unicode invertible invertible-hxt lens memory mtl network-uri
process semigroups silently string-conversions template-haskell
time utf8-string x509 zlib
];
libraryPkgconfigDepends = [ libxml2 ];
libraryToolDepends = [ hpack ];
testHaskellDepends = [
asn1-encoding asn1-types base base64-bytestring bytestring
cryptonite data-default http-types HUnit hxt hxt-charproperties
hxt-http hxt-unicode invertible invertible-hxt lens memory mtl
network-uri process semigroups silently string-conversions
template-haskell time utf8-string x509 zlib
];
testPkgconfigDepends = [ libxml2 ];
doHaddock = false;
doCheck = false;
prePatch = "hpack";
homepage = "https://github.com/dylex/hsaml2#readme";
description = "OASIS Security Assertion Markup Language (SAML) V2.0";
license = lib.licenses.asl20;
}
59 changes: 59 additions & 0 deletions nix/overlays/haskell/hscim.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{ mkDerivation, aeson, aeson-qq, attoparsec, base, bytestring
, case-insensitive, email-validate, fetchgit, hashable, hedgehog
, hpack, hspec, hspec-discover, hspec-expectations, hspec-wai
, http-api-data, http-media, http-types, hw-hspec-hedgehog
, indexed-traversable, lib, list-t, microlens, mmorph, mtl
, network-uri, retry, scientific, servant, servant-client
, servant-client-core, servant-server, stm, stm-containers
, string-conversions, template-haskell, text, time
, unordered-containers, uuid, wai, wai-extra, warp
}:
mkDerivation {
pname = "hscim";
version = "0.3.6";
src = fetchgit {
url = "https://github.com/wireapp/wire-server";
sha256 = "0pq8kwdzs87ivjci8js8bspz50v15mjr36san88d044wq1jkv4fg";
rev = "7fe73c7338b397140f1aca12c79f320ac277d8c3";
fetchSubmodules = true;
};
postUnpack = "sourceRoot+=/libs/hscim; echo source root reset to $sourceRoot";
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
aeson aeson-qq attoparsec base bytestring case-insensitive
email-validate hashable hedgehog hspec hspec-expectations hspec-wai
http-api-data http-media http-types hw-hspec-hedgehog list-t
microlens mmorph mtl network-uri retry scientific servant
servant-client servant-client-core servant-server stm
stm-containers string-conversions template-haskell text time
unordered-containers uuid wai wai-extra warp
];
libraryToolDepends = [ hpack ];
executableHaskellDepends = [
aeson aeson-qq attoparsec base bytestring case-insensitive
email-validate hashable hedgehog hspec hspec-expectations hspec-wai
http-api-data http-media http-types hw-hspec-hedgehog list-t
microlens mmorph mtl network-uri retry scientific servant
servant-client servant-client-core servant-server stm
stm-containers string-conversions template-haskell text time
unordered-containers uuid wai wai-extra warp
];
testHaskellDepends = [
aeson aeson-qq attoparsec base bytestring case-insensitive
email-validate hashable hedgehog hspec hspec-expectations hspec-wai
http-api-data http-media http-types hw-hspec-hedgehog
indexed-traversable list-t microlens mmorph mtl network-uri retry
scientific servant servant-client servant-client-core
servant-server stm stm-containers string-conversions
template-haskell text time unordered-containers uuid wai wai-extra
warp
];
testToolDepends = [ hspec-discover ];
doHaddock = false;
doCheck = false;
prePatch = "hpack";
homepage = "https://github.com/wireapp/wire-server/libs/hscim/README.md";
description = "hscim json schema and server implementation";
license = lib.licenses.agpl3Only;
}
Loading

0 comments on commit c271307

Please sign in to comment.