blob: c85db6e41ba047dfec277c0b89247a55ddea8a91 (
plain)
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
|
{
inputs = {
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}";
nativeBuildInputs = with pkgs; [
flex
bison
];
buildScript = pkgs.writeScriptBin "build-script"
''
set -e
prog_name="$1"
outdir="outputs/$prog_name"
mkdir -p "$outdir"
${pkgs.flex}/bin/flex -o "$outdir"/lex.yy.cc "$prog_name"/main.l
${pkgs.gcc}/bin/gcc "$outdir"/lex.yy.cc -o "$outdir"/exec
./"$outdir"/exec < "$prog_name"/input
rm -r outputs
'';
in
rec {
devShell = pkgs.mkShell {
nativeBuildInputs = nativeBuildInputs ++ (with pkgs; [
gcc
]);
};
defaultApp = {
type = "app";
program = "${buildScript}/bin/build-script";
};
});
}
|