commit 68bea2c7e8827d87a2270e042c88c7a86e84fa19 Author: Sebastian Date: Tue Nov 5 21:30:44 2024 +0100 Initial commit diff --git a/0001-patch-install-path.patch b/0001-patch-install-path.patch new file mode 100644 index 0000000..6a302a1 --- /dev/null +++ b/0001-patch-install-path.patch @@ -0,0 +1,16 @@ +diff --git a/Makefile b/Makefile +index bac0711..0e17fc4 100644 +--- a/Makefile ++++ b/Makefile +@@ -30,8 +30,9 @@ RemoteCommand: Log.o RemoteCommand.o UDPSocket.o + + .PHONY install: + install: all +- install -m 755 MMDVMHost /usr/local/bin/ +- install -m 755 RemoteCommand /usr/local/bin/ ++ mkdir -p ${out}/bin ++ install -m 755 MMDVMHost ${out}/bin/ ++ install -m 755 RemoteCommand ${out}/bin/ + + .PHONY install-service: + install-service: install /etc/MMDVM.ini diff --git a/0002-fix-missing-include.patch b/0002-fix-missing-include.patch new file mode 100644 index 0000000..256d498 --- /dev/null +++ b/0002-fix-missing-include.patch @@ -0,0 +1,12 @@ +diff --git a/M17Utils.cpp b/M17Utils.cpp +index 4462c9b..a65ca13 100644 +--- a/M17Utils.cpp ++++ b/M17Utils.cpp +@@ -20,6 +20,7 @@ + #include "M17Defines.h" + + #include ++#include + + const std::string M17_CHARS = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/."; + diff --git a/0003-fix-null-controller.patch b/0003-fix-null-controller.patch new file mode 100644 index 0000000..ed35789 --- /dev/null +++ b/0003-fix-null-controller.patch @@ -0,0 +1,22 @@ +diff --git a/NullController.cpp b/NullController.cpp +index edfeffe..598b783 100644 +--- a/NullController.cpp ++++ b/NullController.cpp +@@ -20,6 +20,7 @@ + + #include + #include ++#include + + const unsigned char MMDVM_FRAME_START = 0xE0U; + +@@ -120,7 +121,8 @@ void CNullController::writeVersion() + ::memset(reply + 7U, 0x00U, 16U); + + uint8_t count = 23U; +- for (uint8_t i = 0U; HARDWARE[i] != 0x00U; i++, count++) ++ uint8_t i = 0; ++ for (i = 0U; HARDWARE[i] != 0x00U; i++, count++) + reply[count] = HARDWARE[i]; + + reply[1U] = count; diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..8c7338d --- /dev/null +++ b/default.nix @@ -0,0 +1,20 @@ +{ stdenv, fetchFromGitHub, ... }: + +stdenv.mkDerivation { + pname = "MMDVMHost"; + version = "yolo"; + + src = fetchFromGitHub { + owner = "g4klx"; + repo = "MMDVMHost"; + rev = "b02560ccbc02bdb076b77aaef3e70655a714cd36"; + sha256 = "sha256-y9mreTIsQuKr1HlUGuSZIdry9f1yFXkbEKKzAaK79v0="; + }; + + patches = [ + ./0001-patch-install-path.patch + ./0002-fix-missing-include.patch + ./0003-fix-null-controller.patch + ]; + +} \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..98f71cb --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1717179513, + "narHash": "sha256-vboIEwIQojofItm2xGCdZCzW96U85l9nDW3ifMuAIdM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63dacb46bf939521bdc93981b4cbb7ecb58427a0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7104a40 --- /dev/null +++ b/flake.nix @@ -0,0 +1,26 @@ +{ + description = "A flake for mmdvm DL0XK patches."; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/24.05"; + }; + + + outputs = inputs@{ self, nixpkgs, ... }: + let + lib = nixpkgs.lib; + in + { + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt; + + packages = { + x86_64-linux = { + default = nixpkgs.legacyPackages.x86_64-linux.callPackage ./default.nix { }; + }; + }; + + nixosModules.default = { config, pkgs, ... }: { + imports = [ ./module.nix ]; + _module.args.mmdvm_host = self.packages; + }; + }; +} diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..7feb942 --- /dev/null +++ b/module.nix @@ -0,0 +1,50 @@ +{ lib, config, pkgs, mmdvm_host, ... }: +with lib; +let + # Shorter name to access final settings a + # user of hello.nix module HAS ACTUALLY SET. + # cfg is a typical convention. + cfg = config.services.mmdvm_host; +in +{ + + options.services.mmdvm_host = { + enable = mkEnableOption "mmdvm host service"; + package = mkOption { + default = mmdvm_host.x86_64-linux.default; + type = types.package; + }; + user = mkOption { + type = types.str; + default = "afg"; + }; + }; + + + config = mkIf cfg.enable { + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = [ + cfg.package + ]; + + systemd.services.mmdvm_host = { + wantedBy = [ "multi-user.target" ]; + wants = [ "network.target" ]; + after = [ "network.target" ]; + description = "mmdvm_host service"; + serviceConfig = { + Type = "exec"; + User = cfg.user; + Restart = "always"; + RestartSec = "3s"; + StartLimitIntervalSec = "0"; + RuntimeDirectory = "mmdvm_host"; + }; + script = '' + exec ${cfg.package}/bin/mmdvm_host + ''; + }; + }; + +} diff --git a/result b/result new file mode 120000 index 0000000..dcec265 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/qq596qk2sm7jkn7kwpagq38aq4pggmph-MMDVMHost-yolo \ No newline at end of file