Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
104 lines (95 loc) · 2.98 KB
/
Copy pathflake.nix
File metadata and controls
104 lines (95 loc) · 2.98 KB
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
{
description = "Nix flake for MisraStdC";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
lib = nixpkgs.lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = f:
lib.genAttrs systems (system:
f {
inherit system;
pkgs = import nixpkgs { inherit system; };
});
# Mull only ships prebuilt Linux binaries (see nix/mull.nix), so the
# mutation-testing package and dev shell are gated to Linux systems.
isLinux = system: lib.hasSuffix "linux" system;
in
{
packages = forAllSystems ({ system, pkgs }:
let
misraStdC = pkgs.stdenv.mkDerivation {
pname = "misra-std-c";
version = if self ? shortRev then self.shortRev else "dirty";
src = self;
strictDeps = true;
nativeBuildInputs = with pkgs; [
meson
ninja
pkg-config
];
doCheck = true;
checkPhase = ''
runHook preCheck
meson test --print-errorlogs
runHook postCheck
'';
meta = with pkgs.lib; {
description = "Macro-based generic containers, formatting, and utilities for C11";
homepage = "https://git.anvielabs.com/bp/MisraStdC.git";
license = licenses.unlicense;
platforms = platforms.unix;
};
};
in
{
default = misraStdC;
"misra-std-c" = misraStdC;
}
// lib.optionalAttrs (isLinux system) {
mull = pkgs.callPackage ./nix/mull.nix { };
});
checks = forAllSystems ({ system, ... }: {
default = self.packages.${system}.default;
});
devShells = forAllSystems ({ system, pkgs }:
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.default ];
packages = with pkgs; [
stdenv.cc
meson
ninja
pkg-config
];
};
}
// lib.optionalAttrs (isLinux system) {
# Mutation-testing shell: clang_19 (compiler whose libLLVM matches the
# mull-ir-frontend-19 plugin) + mull + the usual build tools. Run
# Scripts/mutation.sh from inside `nix develop .#mutation`.
mutation = pkgs.mkShell {
packages = with pkgs; [
llvmPackages_19.clang
self.packages.${system}.mull
meson
ninja
pkg-config
];
shellHook = ''
export CC=clang
export MULL_LLVM_VERSION=19
export MULL_IR_FRONTEND="${self.packages.${system}.mull}/lib/mull-ir-frontend-19"
export MULL_RUNNER="mull-runner-19"
'';
};
});
};
}