File: flake.nix

package info (click to toggle)
aws-crt-python 0.28.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 78,428 kB
  • sloc: ansic: 437,955; python: 27,657; makefile: 5,855; sh: 4,289; ruby: 208; java: 82; perl: 73; cpp: 25; xml: 11
file content (116 lines) | stat: -rw-r--r-- 4,229 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{
  description = "A flake for s2n-tls";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
    # Pure nix functions, not relying on nixpkgs https://github.com/numtide/flake-utils
    flake-utils.url = "github:numtide/flake-utils";
    awslc.url = "github:aws/aws-lc";
    awslcfips2022.url = "github:dougch/aws-lc?ref=nixAWS-LC-FIPS-2.0.17";
    awslcfips2024.url = "github:dougch/aws-lc?ref=nixfips-2024-09-27";
  };

  outputs = { self, nixpkgs, awslc, awslcfips2022, awslcfips2024, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config = { permittedInsecurePackages = [ "openssl-1.1.1w" ]; };
        };
        # Internal variable = input.awslc ...<package name from flake>
        aws-lc = awslc.packages.${system}.aws-lc;
        aws-lc-fips-2022 = awslcfips2022.packages.${system}.aws-lc-fips-2022;
        aws-lc-fips-2024 = awslcfips2024.packages.${system}.aws-lc-fips-2024;
        # Note: we're rebuilding, not importing from nixpkgs for the mkShells.
        openssl_1_0_2 = import ./nix/openssl_1_0_2.nix { pkgs = pkgs; };
        openssl_1_1_1 = import ./nix/openssl_1_1_1.nix { pkgs = pkgs; };
        openssl_3_0 = import ./nix/openssl_3_0.nix { pkgs = pkgs; };
        common_packages = [
          # Integration Deps
          # We're not including openssl1.1.1 in our package list to avoid confusing cmake.
          # It will be in the PATH of our devShell for use in tests.
          pkgs.corretto21
          pkgs.iproute2
          pkgs.apacheHttpd
          pkgs.procps
          # stress testing tool for linux
          pkgs.stress
          # GnuTLS-cli and serv utilities needed for some integration tests.
          pkgs.gnutls
          pkgs.tshark

          # C Compiler Tooling; adding llvm/clang is an involved future task.
          pkgs.gcc
          pkgs.gdb
          pkgs.valgrind

          # Linters/Formatters
          pkgs.shellcheck
          # There are 2 nix formatters; use the old one for now.
          pkgs.nixfmt-classic
          # Let uv handle all the python things.
          pkgs.uv

          # Rust
          pkgs.rustup

          # Quality of Life
          pkgs.findutils
          pkgs.git
          pkgs.which
        ];
        writeScript = path:
          pkgs.writeScript (baseNameOf path)
          (builtins.readFile (toString path));
      in rec {
        packages.s2n-tls = pkgs.stdenv.mkDerivation {
          src = self;
          name = "s2n-tls";
          inherit system;

          # Set GCC as the compiler for package builds
          CC = "${pkgs.gcc}/bin/gcc";
          CXX = "${pkgs.gcc}/bin/g++";

          nativeBuildInputs = [ pkgs.cmake ];
          buildInputs = [ pkgs.openssl_3 ];

          configurePhase = ''
            cmake -S . -B./build \
                  -DBUILD_SHARED_LIBS=ON \
                  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
                  -DCMAKE_C_COMPILER=${pkgs.gcc}/bin/gcc \
                  -DCMAKE_CXX_COMPILER=${pkgs.gcc}/bin/g++
          ''; # Explicitly set GCC as the compiler for CMake

          buildPhase = ''
            cmake --build ./build -j $(nproc)
          '';

          installPhase = ''
            cmake --install ./build --prefix $out
          '';

          checkPhase = ''
            echo Not running tests here. Run `nix develop` to run tests.
          '';

          propagatedBuildInputs = [ pkgs.openssl_3 ];
        };
        # Import devShells from the separate module
        devShells = import ./nix/devshells.nix {
          inherit pkgs system common_packages openssl_1_0_2 openssl_1_1_1
            openssl_3_0 aws-lc aws-lc-fips-2022 aws-lc-fips-2024 writeScript;
        };
        packages.devShell = devShells.default.inputDerivation;
        packages.default = packages.s2n-tls;
        packages.s2n-tls-openssl3 = packages.s2n-tls.overrideAttrs
          (finalAttrs: previousAttrs: { doCheck = true; });
        packages.s2n-tls-openssl11 = packages.s2n-tls.overrideAttrs
          (finalAttrs: previousAttrs: {
            doCheck = true;
            buildInputs = [ pkgs.openssl_1_1 ];
          });
        formatter = pkgs.nixfmt;
      });
}