~maelkum/viuavm

0a9510347068e0312e69e75cb5692b3dc108e9d9 — Marek Marecki 8 months ago 3becabf devel
To Nix, or not to Nix - that is the question

I think the idea of Nix is a cool one. It would be awesome to have a way
of ensuring a consistent development environment wherever I will happen
to work on the project. Nix seems a bit arcane at the moment, though...

Anyway, let's explore.

What I would like to have is a script to build and test the VM in a
nix-shell--with both GCC and Clang--that would be independent of the
machine on which it is running. This should be doable, and provide a
really convenient process:

    ]$ git clone .../viuavm
    ]$ cd viuavm
    # This would build the VM's toolchain using gcc.
    ]$ bash ./nix-build.sh gcc
    # This would test the result.
    ]$ bash ./nix-test.sh

No messing around with dependencies if you only want to build, test, and
work on the code. You would only have to provide the dependencies if you
wanted to install the VM on your machine. The only things that would be
needed to work on the VM without would be Git, Nix, and BASH.
2 files changed, 20 insertions(+), 0 deletions(-)

A new/nix-gcc.sh
A new/viua.nix
A new/nix-gcc.sh => new/nix-gcc.sh +3 -0
@@ 0,0 1,3 @@
#!/usr/bin/env bash

nix-shell --pure --run 'make clean && make -j && make test' viua.nix

A new/viua.nix => new/viua.nix +17 -0
@@ 0,0 1,17 @@
let
    nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11";
    pkgs = import nixpkgs { config = {}; overlays = []; };
in

pkgs.mkShellNoCC {
    packages = with pkgs; [
        gcc13
        gnumake
        python3Minimal
        python311Packages.colored
        liburing
        libuuid
        openssl
        git
    ];
}