Skip to content

Commit

Permalink
Implement prebuilts for caml-crush
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <[email protected]>
  • Loading branch information
avnik committed Nov 21, 2023
1 parent 9957a02 commit 49c0456
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ Source: https://github.com/tiiuae/ghaf-caml-crush
Copyright: 2023 Technology Innovation Institute (TII) <https://github.com/tiiuae/>
License: Apache-2.0
Files: *.lock *.json docs/*.svg *.conf

Copyright: ANSSI (2013-2016)
License: MIT
Files: prebuilt/*.tar.gz
23 changes: 23 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Except as contained in this notice, the name(s) of the above copyright holders
shall not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ SPDX-License-Identifier: Apache-2.0
# ghaf-caml-crush
Caml Crush package and NixOS-module for ghaf framework

## Flake outputs

* `caml-crush` -- native compiled binary
* `caml-crush-tarballs` -- produce tarballs for upload to [prebuilt](prebuilt/) directory
* `caml-crush-prebuilts` -- produce package from prebuilts mentioned above (to bypass ocaml cross-compilation issues)
* `caml-crush-prebuilt-crossed` -- test output with cross-compiled `aarch64-linux` container with caml-crush-prebuilts. (for testing purposes)

## License
This project is licensed under the Apache-2.0 license - see the
[Apache-2.0.txt](LICENSES/Apache-2.0.txt) file for details.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
./modules
./nix
./pkgs
./tests
];
};
}
24 changes: 24 additions & 0 deletions pkgs/caml-crush/prebuilts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0
{
stdenv,
autoPatchelfHook,
libtirpc,
}: let
prebuilts = {
x86_64-linux = ../../prebuilt/caml-crush-x86_64-linux.tar.gz;
aarch64-linux = ../../prebuilt/caml-crush-aarch64-linux.tar.gz;
};
in
stdenv.mkDerivation {
name = "caml-crush-prebuilt";
# src = prebuilts.${stdenv.hostPlatform.system};
dontUnpack = 1;
nativeBuildInputs = [autoPatchelfHook];
buildInputs = [libtirpc];
installPhase = ''
mkdir $out
(cd $out && tar xvf ${prebuilts.${stdenv.hostPlatform.system}})
'';
}
12 changes: 12 additions & 0 deletions pkgs/caml-crush/tarballs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0
{
runCommandNoCC,
packages,
}:
runCommandNoCC "caml-crush-tarballs" {} ''
mkdir $out
(cd ${packages.x86_64-linux.caml-crush} && tar czvf $out/caml-crush-x86_64-linux.tar.gz .)
(cd ${packages.aarch64-linux.caml-crush} && tar czvf $out/caml-crush-aarch64-linux.tar.gz .)
''
4 changes: 3 additions & 1 deletion pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# SPDX-License-Identifier: Apache-2.0
#
# Packages to be exported from the flake
{
{self, ...}: {
perSystem = {pkgs, ...}: {
packages = {
caml-crush = pkgs.callPackage ./caml-crush {};
caml-crush-prebuilts = pkgs.callPackage ./caml-crush/prebuilts.nix {};
caml-crush-tarballs = pkgs.callPackage ./caml-crush/tarballs.nix {inherit (self) packages;};
};
};
}
Binary file added prebuilt/caml-crush-aarch64-linux.tar.gz
Binary file not shown.
Binary file added prebuilt/caml-crush-x86_64-linux.tar.gz
Binary file not shown.
36 changes: 36 additions & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2023 Technology Innovation Institute (TII)
#
# SPDX-License-Identifier: Apache-2.0
# Build a test cross-compiled container for aarch64-linux
{self, ...}: {
flake = {lib, ...}: {
nixosConfigurations = {
crossed = lib.nixosSystem {
system = "aarch64-linux";
modules = [
{
nixpkgs.hostPlatform.system = "aarch64-linux";
nixpkgs.buildPlatform.system = "x86_64-linux";
nixpkgs.overlays = [
(final: _prev: {
caml-crush = final.callPackage ../pkgs/caml-crush/prebuilts.nix {};
})
];
}
({pkgs, ...}: {
environment.systemPackages = with pkgs; [
# List problematic packages here
caml-crush
];
boot.isContainer = true; # Don't build kernel and other slow things
})
];
};
};
};
perSystem = {system, ...}: {
packages = {
caml-crush-prebuilts-crossed = self.nixosConfigurations.crossed.config.system.build.toplevel;
};
};
}

0 comments on commit 49c0456

Please sign in to comment.