shithub: m8c

Download patch

ref: 3c3a30629a027ee82da82fc63ad0f1eaf17e1498
parent: f57f91784aed048e7cffea96508260e67815f6b5
parent: 2552fe2f1efa12436dec93b9ffeee79d1d90bef7
author: Jonne Kokkonen <jonne.kokkonen@gmail.com>
date: Thu Jul 22 15:12:27 EDT 2021

Merge pull request #16 from jpotier/main

Nix development environment and package

--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@
 build/
 compile_commands.json
 .clangd
+result*
--- a/README.md
+++ b/README.md
@@ -103,3 +103,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,46 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+with pkgs;
+
+# HOWTO keep this package definition up-to-date:
+#
+# 1. NEW VERSION:
+# After the new version is tagged and pushed, update the `version` var to the
+# proper value and update the hash. You can use the following command to find
+# out the sha256, for example, with version 1.0.3:
+# `nix-prefetch-github --rev v1.0.3 laamaa m8c`
+#
+# 2. NEW DEPENDENCIES:
+# Make sure new dependencies are added. Runtime deps go to buildInputs and
+# compile-time deps go to nativeBuildInputs. Use the nixpkgs manual for help
+#
+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,8 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+with pkgs;
+
+mkShell {
+  packages = with pkgs; [ nix-prefetch-github ];
+  inputsFrom = [ (import ./default.nix {}).m8c-dev ];
+}
--