diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 59 |
1 files changed, 30 insertions, 29 deletions
@@ -4,37 +4,38 @@ | |||
4 | }; | 4 | }; |
5 | 5 | ||
6 | outputs = { self, nixpkgs, utils, ... }: | 6 | outputs = { self, nixpkgs, utils, ... }: |
7 | utils.lib.eachDefaultSystem (system: | 7 | utils.lib.eachDefaultSystem (system: |
8 | let | 8 | let |
9 | pkgs = nixpkgs.legacyPackages."${system}"; | 9 | pkgs = nixpkgs.legacyPackages."${system}"; |
10 | nativeBuildInputs = with pkgs; [ | 10 | nativeBuildInputs = with pkgs; [ |
11 | flex | 11 | flex |
12 | bison | 12 | bison |
13 | ]; | 13 | ]; |
14 | 14 | ||
15 | buildScript = pkgs.writeScriptBin "build-script" | 15 | buildScript = pkgs.writeScriptBin "build-script" |
16 | '' | 16 | '' |
17 | set -e | 17 | set -e |
18 | prog_name="$1" | 18 | prog_name="$1" |
19 | outdir="outputs/$prog_name" | 19 | outdir="outputs/$prog_name" |
20 | mkdir -p "$outdir" | 20 | mkdir -p "$outdir" |
21 | 21 | ||
22 | ${pkgs.flex}/bin/flex -o "$outdir"/lex.yy.cc "$prog_name"/main.l | 22 | ${pkgs.flex}/bin/flex -o "$outdir"/lex.yy.cc "$prog_name"/main.l |
23 | ${pkgs.gcc}/bin/gcc "$outdir"/lex.yy.cc -o "$outdir"/exec | 23 | ${pkgs.gcc}/bin/gcc "$outdir"/lex.yy.cc -o "$outdir"/exec |
24 | 24 | ||
25 | ./"$outdir"/exec < "$prog_name"/input | 25 | ./"$outdir"/exec < "$prog_name"/input |
26 | rm -r "outputs"/* | 26 | rm -r outputs |
27 | ''; | 27 | ''; |
28 | 28 | ||
29 | in rec { | 29 | in |
30 | devShell = pkgs.mkShell { | 30 | rec { |
31 | nativeBuildInputs = nativeBuildInputs ++ (with pkgs; [ | 31 | devShell = pkgs.mkShell { |
32 | gcc | 32 | nativeBuildInputs = nativeBuildInputs ++ (with pkgs; [ |
33 | ]); | 33 | gcc |
34 | }; | 34 | ]); |
35 | defaultApp = { | 35 | }; |
36 | type = "app"; | 36 | defaultApp = { |
37 | program = "${buildScript}/bin/build-script"; | 37 | type = "app"; |
38 | }; | 38 | program = "${buildScript}/bin/build-script"; |
39 | }); | 39 | }; |
40 | }); | ||
40 | } | 41 | } |