Created
November 4, 2020 22:36
-
-
Save guibou/a5ca776ec560d4b78d17645fe9a77d68 to your computer and use it in GitHub Desktop.
Nix shell for my compilation course
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let | |
| # Fetch a reproducible clone of nixpkgs. | |
| # That one is a pull request to nixpkgs which includes antlr 4.8. | |
| pkgs = import (fetchTarball { | |
| url = "https://github.com/guibou/nixpkgs/archive/d4cfc8694c7536a79c9d0260b171ee7983394896.tar.gz"; | |
| }) {}; | |
| in | |
| rec { | |
| # Create an alias for "spike $(which pk)" to run-spike. | |
| runspike = pkgs.writeShellScriptBin "run-spike" | |
| '' | |
| ${pkgs.spike}/bin/spike ${pkgs.pkgsCross.riscv64-embedded.riscv-pk}/bin/pk $@ | |
| ''; | |
| paths = with pkgs; [ | |
| # spike and riscv64 toolchain | |
| runspike | |
| pkgsCross.riscv64-embedded.buildPackages.gcc | |
| # Antlr | |
| zulu | |
| antlr4_8 | |
| # Python stuffs (with antlr) | |
| (python3.withPackages(p: with p; [pytest p.antlr4-python3-runtime p.networkx p.graphviz p.pytestcov])) | |
| ]; | |
| # A shell, which works for the TP. | |
| # Enter it with `nix-shell ./ -A shell` | |
| # Or we can also create a `shell.nix` file which contains | |
| # (import ./default.nix).shell | |
| # Then, entering the shell is as simple as `nix-shell`. | |
| # This shell contains the tools for the TP (riscv64 toolchain, antlr) | |
| shell = pkgs.mkShell { | |
| buildInputs = paths; | |
| # Set a few environment variables so the makefile are working correctly. | |
| SHELL="${pkgs.bashInteractive}/bin/bash"; | |
| ANTLR4 = "antlr4"; | |
| CLASSPATH="$CLASSPATH:."; | |
| }; | |
| # Docker image with all the tools for the TP. | |
| # `docker load < $(nix-build ./default.nix -A image)` | |
| image = pkgs.dockerTools.buildImage { | |
| name = "docker"; | |
| contents = paths ++ ( | |
| # Added coreutils so users can uses `ls` and niceties like that ;) | |
| with pkgs; [coreutils]); | |
| config = { | |
| Cmd = [ "${pkgs.bashInteractive}/bin/bash" ]; | |
| }; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment