Integrate h-m-m: A Terminal-Based Mind Mapping Tool into Nix Home Manager
h-m-m is a terminal-based tool for managing mind maps. This guide will show you how to integrate it into your Nix environment using home-manager
. We’ll cover fetching the script from GitHub, configuring the PHP environment, and setting up an executable command.
Step 1: Update home.nix
Add the following configuration to your home.nix
file:
{ config, pkgs, ... }:
let
# Fetch the GitHub repository containing h-m-m
phpRepo = pkgs.fetchgit {
url = "https://github.com/nadrad/h-m-m.git";
rev = "f9ce96b719def746e7299d897ce43c9633b42c90"; # Commit hash
sha256 = "sha256-2+oXGYpaCqQG6+yh3/pMwQxIC39M7XTDRIEqWboVo0c="; # Checksum
};
# Path to the h-m-m PHP script
phpScript = "${phpRepo}/h-m-m";
# PHP with mbstring extension
phpWithMbstring = pkgs.php.withExtensions ({ all, ... }: with all; [ mbstring ]);
in
{
home.packages = [
phpWithMbstring
# Create an executable for the h-m-m script
(pkgs.writeScriptBin "h-m-m" ''
#!/usr/bin/env bash
${phpWithMbstring}/bin/php "${phpScript}" "$@"
'')
];
# Additional home-manager configurations can be added here
}
Explanation
Fetching the Repository
fetchgit
: Clones the repository containingh-m-m
.url
,rev
,sha256
: Specifies the repository URL, commit hash, and checksum for verification.
PHP Configuration
phpWithMbstring
: Installs PHP with thembstring
extension required by the script.
Executable Wrapper
writeScriptBin
: Wraps the PHP script into an executable namedh-m-m
, which runs with the specified PHP interpreter and forwards any command-line arguments.
Step 2: Apply Configuration
Apply the changes to your environment by running:
home-manager switch
Result After applying the configuration, you can use h-m-m directly from your terminal to work with mind maps:
h-m-m [arguments]