Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Nix flake and devShell #2189

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 251 additions & 0 deletions flake.lock

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

32 changes: 32 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
description = "AWS-LC is a general-purpose cryptographic library";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we have to keep this up to date? Is there an option for latest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest is essentially a development branch and comes with the risk of breakage. There are only 2 releases a year (similar to Canonical's cadence), so the version bumps can be infrequent.


outputs = { self, nix, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
shells = import ./nix/devshell.nix { pkgs = pkgs; };

in rec {
packages.aws-lc = pkgs.stdenv.mkDerivation {
src = self;
name = "aws-lc";
inherit system;
nativeBuildInputs = [ pkgs.ninja pkgs.cmake pkgs.perl pkgs.golang ];
cmakeFlags = [
"-GNinja"
"-DBUILD_SHARED_LIBS=ON"
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
];
checkPhase = ''
ninja run_minimal_tests
'';
};
formatter = pkgs.nixfmt;
packages.default = packages.aws-lc;
devShells.default = shells;
});
}

24 changes: 24 additions & 0 deletions nix/devshell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{pkgs}:
pkgs.mkShell rec {
buildInputs = [ pkgs.cmake ];
packages = [ pkgs.gdb pkgs.nixfmt pkgs.ninja pkgs.cmake pkgs.perl pkgs.go ];
shellHook = ''
echo "Entering a devShell..."
export PS1="[awslc nix] $PS1"
function clean {(set -e
rm -rf ./build
)}
function configure {(set -e
cmake -S . -B./build \
-GNinja \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
)}
function build {
cmake --build ./build -j $(nproc)
}
function unit {
ninja -C build run_tests
}
'';
}
Loading