2022-05-11 17:26:20 +02:00
|
|
|
{
|
|
|
|
description = "An implementation of the Double Ratchet cryptographic ratchet";
|
|
|
|
|
2022-05-11 20:14:00 +02:00
|
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
# We can't use the current stable release because of
|
2022-05-11 17:26:20 +02:00
|
|
|
# https://github.com/emscripten-core/emscripten/issues/14995
|
|
|
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
2022-05-11 19:59:33 +02:00
|
|
|
inputs.npmlock2nix = {
|
|
|
|
url = "github:nix-community/npmlock2nix";
|
|
|
|
flake = false;
|
|
|
|
};
|
2022-05-11 17:26:20 +02:00
|
|
|
|
2022-05-11 19:59:33 +02:00
|
|
|
outputs = { self, nixpkgs, flake-utils, npmlock2nix }:
|
2022-05-11 17:26:20 +02:00
|
|
|
(
|
2022-05-12 23:05:22 +02:00
|
|
|
# some systems cause issues, e.g. i686-linux is unsupported by gradle,
|
|
|
|
# which causes "nix flake check" to fail. Investigate more later, but for
|
|
|
|
# now, we will just allow x86_64-linux
|
|
|
|
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
|
2022-05-11 17:26:20 +02:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2022-05-11 19:59:33 +02:00
|
|
|
overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
npmlock2nix = final.callPackage npmlock2nix {};
|
|
|
|
})
|
|
|
|
];
|
2022-05-11 17:26:20 +02:00
|
|
|
};
|
2022-05-11 19:59:33 +02:00
|
|
|
node_modules = pkgs.npmlock2nix.node_modules { src = ./javascript; };
|
2022-05-11 17:26:20 +02:00
|
|
|
in
|
|
|
|
rec {
|
2022-05-13 01:42:47 +02:00
|
|
|
checks.gcc-cmake = pkgs.gccStdenv.mkDerivation {
|
2022-05-12 23:05:22 +02:00
|
|
|
name = "olm";
|
|
|
|
|
2022-05-13 01:42:47 +02:00
|
|
|
buildInputs = [ pkgs.cmake ];
|
2022-05-12 23:05:22 +02:00
|
|
|
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
cmake . -Bbuild
|
|
|
|
cmake --build build
|
|
|
|
'';
|
|
|
|
|
2022-05-13 01:57:29 +02:00
|
|
|
doCheck = true;
|
2022-05-12 23:05:22 +02:00
|
|
|
checkPhase = ''
|
|
|
|
cd build/tests
|
|
|
|
ctest .
|
|
|
|
cd ../..
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-05-13 01:42:47 +02:00
|
|
|
checks.clang-cmake = pkgs.clangStdenv.mkDerivation {
|
2022-05-12 23:05:22 +02:00
|
|
|
name = "olm";
|
|
|
|
|
2022-05-13 01:42:47 +02:00
|
|
|
buildInputs = [ pkgs.cmake ];
|
2022-05-12 23:05:22 +02:00
|
|
|
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
cmake . -Bbuild
|
|
|
|
cmake --build build
|
|
|
|
'';
|
|
|
|
|
2022-05-13 01:57:29 +02:00
|
|
|
doCheck = true;
|
2022-05-12 23:05:22 +02:00
|
|
|
checkPhase = ''
|
|
|
|
cd build/tests
|
|
|
|
ctest .
|
|
|
|
cd ../..
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-05-13 01:42:47 +02:00
|
|
|
checks.gcc-make = pkgs.gccStdenv.mkDerivation {
|
2022-05-12 23:05:22 +02:00
|
|
|
name = "olm";
|
|
|
|
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
make
|
|
|
|
'';
|
|
|
|
|
2022-05-13 01:57:29 +02:00
|
|
|
doCheck = true;
|
2022-05-12 23:05:22 +02:00
|
|
|
checkPhase = ''
|
|
|
|
make test
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
make install PREFIX=$out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-05-11 17:26:20 +02:00
|
|
|
packages.javascript = pkgs.buildEmscriptenPackage {
|
2022-05-11 20:29:53 +02:00
|
|
|
pname = "olm";
|
|
|
|
inherit (builtins.fromJSON (builtins.readFile ./javascript/package.json)) version;
|
2022-05-11 17:26:20 +02:00
|
|
|
|
2022-05-11 20:35:37 +02:00
|
|
|
buildInputs = with pkgs; [ gnumake python3 nodejs ];
|
2022-05-11 17:26:20 +02:00
|
|
|
|
|
|
|
src = ./.;
|
|
|
|
|
2022-05-11 19:07:57 +02:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs .
|
|
|
|
'';
|
|
|
|
|
2022-05-11 17:26:20 +02:00
|
|
|
configurePhase = "";
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
export EM_CACHE=$TMPDIR
|
|
|
|
make javascript/exported_functions.json
|
|
|
|
make js
|
|
|
|
'';
|
|
|
|
|
|
|
|
output = [ "out" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/javascript
|
|
|
|
cd javascript
|
|
|
|
echo sha256: > checksums.txt
|
|
|
|
sha256sum olm.js olm_legacy.js olm.wasm >> checksums.txt
|
|
|
|
echo sha512: >> checksums.txt
|
|
|
|
sha512sum olm.js olm_legacy.js olm.wasm >> checksums.txt
|
|
|
|
cp package.json olm.js olm.wasm olm_legacy.js index.d.ts README.md checksums.txt $out/javascript
|
|
|
|
cd ..
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
cd javascript
|
|
|
|
export HOME=$TMPDIR
|
2022-05-11 19:59:33 +02:00
|
|
|
ln -s ${node_modules}/node_modules ./node_modules
|
2022-05-11 20:35:37 +02:00
|
|
|
npm test
|
2022-05-11 17:26:20 +02:00
|
|
|
cd ..
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-05-13 02:47:48 +02:00
|
|
|
packages.default = packages.javascript;
|
2022-05-11 17:26:20 +02:00
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|