shithub: m8c

Download patch

ref: 583de43f87a3befdb09d6e806c7dec4473efaab8
parent: f57f91784aed048e7cffea96508260e67815f6b5
author: EEva <eeva@samae>
date: Tue Jul 20 20:03:14 EDT 2021

Nix dev environment and package

Adding two files:

- `shell.nix` provides a shell environment for development. In the project
  directory, entering the development shell by invoking `nix-shell` will pull
  all required dependencies to build the project (based on the latest stable
  release).
- `default.nix` provides a package description of the latest stable release of
  the project. This allows people to quickly install m8c on their machine, by
  referencing the github project.

Added some documentation on how to use nix to automatically pull
dependencies, or quickly install m8c locally.

--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@
 build/
 compile_commands.json
 .clangd
+result*
--- a/README.md
+++ b/README.md
@@ -38,6 +38,14 @@
 ```
 brew update && brew install -y git gcc make sdl2 libserialport
 ```
+### Install required packages dependencies with nix (OSX, Linux)
+
+If you have the nix package manager installed (https://nixos.org/download.html),
+a nix development shell will all needed dependencies is provided. Simply enter:
+
+``` sh
+nix-shell
+```
 ### Download source code (All)
 
 ```
@@ -103,3 +111,9 @@
 Please note that with some configurations (for example, composite video) this can lead to not getting video output at all. If that happens, you can delete the row ```dtoverlay=vc4-kms-v3d``` in bottom of /boot/config.txt.
 
 Further performance improvement can be achieved by not using X11 and running the program directly in framebuffer console, but this might require doing a custom build of SDL.
+
+### Bonus: quickly install m8c locally with nix
+
+``` sh
+nix-env -iA m8c-stable -f https://github.com/laamaa/m8c/archive/refs/heads/main.tar.gz
+```
--- /dev/null
+++ b/default.nix
@@ -1,0 +1,34 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+with pkgs;
+
+let m8c-package =
+  { stdenv
+  , gnumake
+  , SDL2
+  , libserialport
+  , fetchFromGitHub
+  }:
+
+  let
+    pname = "m8c";
+    version = "1.0.3";
+  in
+    stdenv.mkDerivation {
+      inherit pname version;
+
+      src = fetchFromGitHub {
+        owner = "laamaa";
+        repo = pname;
+        rev = "v${version}";
+        hash = "sha256:0yrd6lnb2chgafhw1cz4awx2s1sws6mch5irvgyddgnsa8ishcr5";
+      };
+
+      installFlags = [ "PREFIX=$(out)" ];
+      nativeBuildInputs = [ gnumake ];
+      buildInputs = [ SDL2 libserialport ];
+    };
+in {
+  m8c-stable = pkgs.callPackage m8c-package {};
+  m8c-dev = (pkgs.callPackage m8c-package {}).overrideAttrs (oldAttrs: {src = ./.;});
+}
--- /dev/null
+++ b/shell.nix
@@ -1,0 +1,7 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+with pkgs;
+
+mkShell {
+  inputsFrom = [ (import ./default.nix {}).m8c-dev ];
+}
--