-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
76 lines (61 loc) · 1.81 KB
/
flake.nix
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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
rec {
formatter = pkgs.nixpkgs-fmt;
devShells = {
default = pkgs.mkShell {
hardeningDisable = [ "all" ];
inputsFrom = pkgs.lib.attrsets.attrValues packages;
packages = with pkgs; [
criterion
gcc13
gcovr
glibc
gnumake
python310Packages.compiledb
valgrind
];
};
};
packages = rec {
default = libmy;
libmy = pkgs.stdenv.mkDerivation rec {
name = "libmy.a";
src = ./.;
makeFlags = [ "CC=${pkgs.gcc13}/bin/gcc" ];
buildInputs = [ pkgs.gnumake ];
hardeningDisable = [ "format" "fortify" ];
enableParallelBuilding = true;
installPhase = ''
runHook preInstall
mkdir -p $out/lib
cp ${name} $out/lib/${name}
runHook postInstall
'';
};
unit_tests = libmy.overrideAttrs (prev: rec {
name = "unit_tests";
buildInputs = prev.buildInputs ++ [ pkgs.criterion ];
buildPhase = ''
runHook preBuild
make unit_tests NO_COV=1
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp ${name} $out/bin/${name}
runHook postInstall
'';
});
};
});
}