shithub: m8c

Download patch

ref: 853671b3abaede912b20edd362bc8061c1ab1675
parent: 1dc58e04a901e911a3a42914944932d33a91c500
author: K. Adam Christensen <pope@shifteleven.com>
date: Sat Sep 6 09:56:07 EDT 2025

Simplify the Nix config and add a workflow for it

Got rid of m8c-stable and made m8c-dev the m8c candidate. If ever a user
wants a specific version, they need only use the git tags to get that
specific version. This reduces the complexity of keeping track of hashes
inside of the flake since it always just builds to what code is checked
out.

In simplifying, updated the flake to use CMake, like the workflows for Mac
and Linux do. This should keep things a bit more consistent that way and
reduce one more case of depdending on the Makefile. In order to use
CMake though, I had to add some install rules for the binary. While I
was there I also put a few extra files into appropriate directories -
like documents and the game controller DB file.

Lastly, to make this feel less of a headache for folks, I added a new
job to the ubuntu workflow to build out the project with Nix.

Signed-off-by: K. Adam Christensen <pope@shifteleven.com>

--- a/.github/workflows/build-ubuntu.yml
+++ b/.github/workflows/build-ubuntu.yml
@@ -12,13 +12,13 @@
 jobs:
  
   build-linux:
-    runs-on: ubuntu-22.04
+    runs-on: ubuntu-latest
     name: linux-x86_64
     steps:
       - name: 'Install dependencies'
         run: |
-          sudo apt-get update
-          sudo apt-get install --fix-missing build-essential libserialport-dev zip git make pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev libpipewire-0.3-dev libwayland-dev libdecor-0-dev
+          sudo apt-get update -y
+          sudo apt-get install -y --fix-missing build-essential libserialport-dev zip git make pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev libpipewire-0.3-dev libwayland-dev libdecor-0-dev
 
       - name: 'Checkout'
         uses: actions/checkout@v4
@@ -80,3 +80,27 @@
           name: m8c-${{ env.NOW }}-linux-x86_64.AppImage
           path: |
             m8c*.AppImage
+
+  build-linux-with-nix:
+    runs-on: ubuntu-latest
+    name: with-nix-linux-x86_64
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Set current date as env variable
+        run: echo "NOW=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
+
+      - name: Set up Nix
+        uses: cachix/install-nix-action@v31
+        with:
+          nix_path: nixpkgs=channel:nixos-unstable
+
+      - name: 'Build binary'
+        run: nix-build
+
+      - name: 'Upload artifact'
+        uses: actions/upload-artifact@v4
+        with:
+          name: m8c-${{ env.NOW }}-with-nix-linux-x86_64
+          path: result
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,7 +66,7 @@
 endif ()
 
 if (WIN32)
-target_link_libraries(${APP_NAME} ${SDL3_LIBRARIES} ${LIBSERIALPORT_LIBRARIES})
+    target_link_libraries(${APP_NAME} ${SDL3_LIBRARIES} ${LIBSERIALPORT_LIBRARIES})
 endif ()
 
 if (APPLE)
@@ -108,4 +108,8 @@
     set(CPACK_PACKAGE_DIRECTORY "package-output")
     set(CPACK_GENERATOR "DragNDrop")
     include(CPack)
-endif ()
\ No newline at end of file
+elseif (UNIX)
+    install(TARGETS ${APP_NAME})
+    install(FILES AUDIOGUIDE.md README.md LICENSE DESTINATION share/doc/${APP_NAME})
+    install(FILES gamecontrollerdb.txt DESTINATION bin/)
+endif ()
--- a/default.nix
+++ b/default.nix
@@ -14,5 +14,5 @@
     }).defaultNix.packages.${builtins.currentSystem};
 in
 {
-  inherit (pkgs) m8c-stable m8c-dev;
+  inherit (pkgs) m8c;
 }
--- a/flake.nix
+++ b/flake.nix
@@ -14,40 +14,38 @@
 
   outputs = { self, nixpkgs, systems, treefmt-nix, ... }:
     let
-      # 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
       pname = "m8c";
-      version = "2.1.0";
+      version = "2.1.0-dev";
       m8c-package =
         { stdenv
-        , gnumake
+        , cmake
+        , copyDesktopItems
+        , makeDesktopItem
         , pkg-config
         , sdl3
         , libserialport
-        , fetchFromGitHub
         }:
         stdenv.mkDerivation {
           inherit pname version;
+          src = ./.;
 
-          src = fetchFromGitHub {
-            owner = "laamaa";
-            repo = pname;
-            rev = "v${version}";
-            hash = "sha256-grShHkCkBqgPHTLYwqQUnvIRzUxW1ENU0dYO4TOpYO8=";
-          };
-
-          installFlags = [ "PREFIX=$(out)" ];
-          nativeBuildInputs = [ gnumake pkg-config ];
+          nativeBuildInputs = [ cmake copyDesktopItems pkg-config ];
           buildInputs = [ sdl3 libserialport ];
+
+          postInstall = ''
+            install -Dm 644 $src/package/appimage/icon.svg \
+                $out/share/icons/hicolor/scalable/apps/${pname}.svg
+          '';
+
+          desktopItems = [
+            (makeDesktopItem {
+              name = pname;
+              exec = pname;
+              icon = pname;
+              desktopName = pname;
+              categories = [ "Audio" "AudioVideo" ];
+            })
+          ];
         };
       eachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f
         (import nixpkgs { inherit system; })
@@ -64,21 +62,18 @@
     in
     {
       packages = eachSystem (pkgs: rec {
-        m8c-stable = pkgs.callPackage m8c-package { };
-        m8c-dev = (pkgs.callPackage m8c-package { }).overrideAttrs (_oldAttrs: {
-          src = ./.;
-        });
-        default = m8c-stable;
+        m8c = pkgs.callPackage m8c-package { };
+        default = m8c;
       });
 
       overlays.default = final: _prev: {
-        inherit (self.packages.${final.system}) m8c-stable m8c-dev;
+        inherit (self.packages.${final.system}) m8c;
       };
 
       apps = eachSystem (pkgs: rec {
         m8c = {
           type = "app";
-          program = "${self.packages.${pkgs.system}.m8c-stable}/bin/m8c";
+          program = "${self.packages.${pkgs.system}.m8c}/bin/m8c";
         };
         default = m8c;
       });
@@ -91,7 +86,7 @@
             nix-prefetch-github
             treefmtEval.${system}.config.build.wrapper
           ];
-          inputsFrom = [ self.packages.${system}.m8c-dev ];
+          inputsFrom = [ self.packages.${system}.m8c ];
         };
       });
 
--