ud3tn/flake.nix
Maximilian Nitsch f98dc4c673 nix: Disable compiler/linker hardening features for the devShell environment
With enabled hardening, nix adds `-D_FORTIFY_SOURCE=2` to the compiler
options, which only works in combination with the optimization level
`-O2`.[^1] For debug builds, optimization is disabled in the Makefile,
which leads to the following warning:

`warning _fortify_source requires compiling with optimization (-o)`

To remove this warning, hardening is deactivated for the devShell
environment.

[^1]: https://nixos.org/manual/nixpkgs/stable/#sec-hardening-in-nixpkgs

Signed-off-by: Maximilian Nitsch <maximilian.nitsch@d3tn.com>
2023-11-29 17:05:56 +01:00

83 lines
2 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
};
outputs = { self, nixpkgs }: {
apps.x86_64-linux.default = {
type = "app";
program = "${self.packages.x86_64-linux.ud3tn}/bin/ud3tn";
};
packages.x86_64-linux =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in
{
ud3tn = pkgs.stdenv.mkDerivation {
pname = "ud3tn";
version = "0.12.0";
src = pkgs.lib.sourceByRegex ./. [
"Makefile"
"^components.*"
"^external.*"
"^generated.*"
"^include.*"
"^mk.*"
];
buildPhase = ''
make type=release optimize=yes -j $NIX_BUILD_CORES ud3tn
'';
installPhase = ''
mkdir -p $out/bin
cp build/posix/ud3tn $out/bin/
'';
};
pyd3tn = with pkgs.python3Packages; buildPythonPackage {
name = "pyd3tn";
src = ./pyd3tn;
propagatedBuildInputs = [ cbor ];
};
python-ud3tn-utils = with pkgs.python3Packages; buildPythonPackage {
name = "ud3tn-utils";
src = ./python-ud3tn-utils;
propagatedBuildInputs = [ protobuf setuptools ];
};
};
devShells.x86_64-linux.default =
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in
pkgs.mkShell {
hardeningDisable = [ "all" ];
packages = with self.packages.x86_64-linux; with pkgs; [
# self
pyd3tn
python-ud3tn-utils
ud3tn
# nixpkgs
bear
clang-tools
gdb
llvmPackages.libcxxClang
nixpkgs-fmt
protobuf
python3Packages.flake8
python3Packages.protobuf
python3Packages.pytest
python3Packages.setuptools
];
};
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
};
}