Debian Codegraph @

crt/s2n/flake.nix

raw symbols SCIP
1 {
2 description = "A flake for s2n-tls";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
6 # Pure nix functions, not relying on nixpkgs https://github.com/numtide/flake-utils
7 flake-utils.url = "github:numtide/flake-utils";
8 awslc.url = "github:aws/aws-lc";
9 awslcfips2022.url = "github:dougch/aws-lc?ref=nixAWS-LC-FIPS-2.0.17";
10 awslcfips2024.url = "github:dougch/aws-lc?ref=nixfips-2024-09-27";
11 };
12
13 outputs = { self, nixpkgs, awslc, awslcfips2022, awslcfips2024, flake-utils }:
14 flake-utils.lib.eachDefaultSystem (system:
15 let
16 pkgs = import nixpkgs {
17 inherit system;
18 config = {
19 permittedInsecurePackages = [ "openssl-1.1.1w" "gradle-7.6.6" ];
20 };
21 };
22 # Internal variable = input.awslc ...<package name from flake>
23 aws-lc = awslc.packages.${system}.aws-lc;
24 aws-lc-fips-2022 = awslcfips2022.packages.${system}.aws-lc-fips-2022;
25 aws-lc-fips-2024 = awslcfips2024.packages.${system}.aws-lc-fips-2024;
26 # Note: we're rebuilding, not importing from nixpkgs for the mkShells.
27 openssl_1_0_2 = import ./nix/openssl_1_0_2.nix { pkgs = pkgs; };
28 openssl_1_1_1 = import ./nix/openssl_1_1_1.nix { pkgs = pkgs; };
29 openssl_3_0 = import ./nix/openssl_3_0.nix { pkgs = pkgs; };
30 common_packages = [
31 # Integration Deps
32 # We're not including openssl1.1.1 in our package list to avoid confusing cmake.
33 # It will be in the PATH of our devShell for use in tests.
34 pkgs.corretto21
35 pkgs.apacheHttpd
36 pkgs.procps
37 # stress testing tool for linux
38 pkgs.stress
39 # GnuTLS-cli and serv utilities needed for some integration tests.
40 pkgs.gnutls
41 pkgs.tshark
42
43 # C Compiler Tooling
44 pkgs.gcc
45 pkgs.gdb
46 pkgs.valgrind
47
48 # Linters/Formatters
49 pkgs.shellcheck
50 # There are 2 nix formatters; use the old one for now.
51 pkgs.nixfmt-classic
52 # Let uv handle all the python things.
53 pkgs.uv
54
55 # Rust
56 pkgs.rustup
57
58 # Quality of Life
59 pkgs.findutils
60 pkgs.git
61 pkgs.which
62 ];
63 writeScript = path:
64 pkgs.writeScript (baseNameOf path)
65 (builtins.readFile (toString path));
66 in rec {
67 packages.s2n-tls = pkgs.stdenv.mkDerivation {
68 src = self;
69 name = "s2n-tls";
70 inherit system;
71
72 # Set GCC as the compiler for package builds
73 CC = "${pkgs.gcc}/bin/gcc";
74 CXX = "${pkgs.gcc}/bin/g++";
75
76 nativeBuildInputs = [ pkgs.cmake ];
77 buildInputs = [ pkgs.openssl_3 ];
78
79 configurePhase = ''
80 cmake -S . -B./build \
81 -DBUILD_SHARED_LIBS=ON \
82 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
83 -DCMAKE_C_COMPILER=${pkgs.gcc}/bin/gcc \
84 -DCMAKE_CXX_COMPILER=${pkgs.gcc}/bin/g++
85 ''; # Explicitly set GCC as the compiler for CMake
86
87 buildPhase = ''
88 cmake --build ./build -j $(nproc)
89 '';
90
91 installPhase = ''
92 cmake --install ./build --prefix $out
93 '';
94
95 checkPhase = ''
96 echo Not running tests here. Run `nix develop` to run tests.
97 '';
98
99 propagatedBuildInputs = [ pkgs.openssl_3 ];
100 };
101 # Import devShells from the separate module
102 devShells = import ./nix/devshells.nix {
103 inherit pkgs system common_packages openssl_1_0_2 openssl_1_1_1
104 openssl_3_0 aws-lc aws-lc-fips-2022 aws-lc-fips-2024 writeScript;
105 };
106 packages.devShell = devShells.default.inputDerivation;
107 # Expose devShell closures as packages so `nix copy --to` can push them to S3.
108 # Usage: nix copy --to s3://bucket .#cache-rust_awslc
109 packages.cache-default = devShells.default.inputDerivation;
110 packages.cache-openssl102 = devShells.openssl102.inputDerivation;
111 packages.cache-openssl111 = devShells.openssl111.inputDerivation;
112 packages.cache-libressl = devShells.libressl.inputDerivation;
113 packages.cache-awslc = devShells.awslc.inputDerivation;
114 packages.cache-awslcfips2022 = devShells.awslcfips2022.inputDerivation;
115 packages.cache-awslcfips2024 = devShells.awslcfips2024.inputDerivation;
116 packages.cache-rust_openssl102 =
117 devShells.rust_openssl102.inputDerivation;
118 packages.cache-rust_openssl111 =
119 devShells.rust_openssl111.inputDerivation;
120 packages.cache-rust_openssl30 =
121 devShells.rust_openssl30.inputDerivation;
122 packages.cache-rust_awslc = devShells.rust_awslc.inputDerivation;
123 packages.cache-rust_awslcfips2024 =
124 devShells.rust_awslcfips2024.inputDerivation;
125 packages.default = packages.s2n-tls;
126 packages.s2n-tls-openssl3 = packages.s2n-tls.overrideAttrs
127 (finalAttrs: previousAttrs: { doCheck = true; });
128 packages.s2n-tls-openssl11 = packages.s2n-tls.overrideAttrs
129 (finalAttrs: previousAttrs: {
130 doCheck = true;
131 buildInputs = [ pkgs.openssl_1_1 ];
132 });
133 formatter = pkgs.nixfmt;
134 });
135 }