diff options
author | Akshay <[email protected]> | 2021-04-09 07:42:26 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-04-09 07:42:26 +0100 |
commit | 5ea5a4b62486e2c1c06c7483dfa83581837581b2 (patch) | |
tree | cbe54c5cbb5babc80d54c45ce1e0c42317ed07a2 /flake.nix |
init
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b8892fa --- /dev/null +++ b/flake.nix | |||
@@ -0,0 +1,40 @@ | |||
1 | { | ||
2 | inputs = { | ||
3 | utils.url = "github:numtide/flake-utils"; | ||
4 | }; | ||
5 | |||
6 | outputs = { self, nixpkgs, utils, ... }: | ||
7 | utils.lib.eachDefaultSystem (system: | ||
8 | let | ||
9 | pkgs = nixpkgs.legacyPackages."${system}"; | ||
10 | nativeBuildInputs = with pkgs; [ | ||
11 | flex | ||
12 | bison | ||
13 | ]; | ||
14 | |||
15 | buildScript = pkgs.writeScriptBin "build-script" | ||
16 | '' | ||
17 | set -e | ||
18 | prog_name="$1" | ||
19 | outdir="outputs/$prog_name" | ||
20 | mkdir -p "$outdir" | ||
21 | |||
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 | ||
24 | |||
25 | ./"$outdir"/exec < "$prog_name"/input | ||
26 | rm -r "outputs"/* | ||
27 | ''; | ||
28 | |||
29 | in rec { | ||
30 | devShell = pkgs.mkShell { | ||
31 | nativeBuildInputs = nativeBuildInputs ++ (with pkgs; [ | ||
32 | gcc | ||
33 | ]); | ||
34 | }; | ||
35 | defaultApp = { | ||
36 | type = "app"; | ||
37 | program = "${buildScript}/bin/build-script"; | ||
38 | }; | ||
39 | }); | ||
40 | } | ||