The hacks law relates the longest stream length with the catchment area of the basin. How can one construct a hack's distribution for a basin and upto what scale the sub basins have to be taken as each stream will have it's own catchment area, using GIS?
Hack's law, for a set of sub-basins, relates the length of the longest stream in each basin to the basin catchment areas. We effectively need to measure the longest upstream channel and the catchment area for all sub-basins.
First, to answer your question about the 'scale' of analysis, the stream network that you use determines the scale, since each confluence in the network corresponds to a basin. You can therefore control the scale of the analysis based on the extent of the modeled stream network. If you'd like to account for smaller basins, extract a more extensive stream network (more on this below).
Now, how do you get information on longest stream length and basin size? In my answer below, I'm going to list several tool names (in bold) that correspond to tools that you can find in the WhiteboxTools library. If you are using QGIS, you may access these same tools using the WhiteboxTools plugin for QGIS. Admittedly, the plugin (which someone else maintains) is not the most up-to-date compared to the functionality currently available in WhiteboxTools; however, I believe that all of the tools you need for the following analysis are available.
First, you will need a DEM for which you have removed all depressions (use the BreachDepressions or FillDepressions tool). Then use the use the D8Pointer tool and the D8FlowAccumulation tool to extract a flow pointer and upslope area rasters from your depressionless DEM. You may threshold (ExtractNetwork) the upslope area (flow accumulation) raster to extract a stream network. Here, you determine the extent of the network, and therefore the number and size of sub-basins, by adjusting this threshold value. I would suggest using the RemoveShortStreams tool to remove the shortest streams, as they may be problematic for your subsequent Hack law analysis.
Now you must extract a stream-link identifier raster for your streams using the StreamLinkIdentifier tool. This will assign a unique ID value for each link in your stream network (see below).
Use the FarthestChannelHead tool, specifying your D8 pointer (flow direction) and stream network rasters as inputs. For each raster cell, the output image will contain the length (in km) of the furthest upstream channel head. The output will look something like this:
Now you have everything you need for the analysis including the 1) basin size (the D8 flow accumulation raster), 2) the furthest upstream channel length, and 3) the basin information contained in the stream link identifier raster. For each stream link in the network, you want to measure the maximum values of the flow accumulation (i.e. the basin area at the outlet) and the longest upstream distance to a channel head (i.e. the longest channel measured from basin outlets). To do this, you will need to run the ExtractRasterStatistics tool, contained in the WhiteboxTools Math and Statistical Analysis toolbox twice, the first time to get the maximum flow accumulation for each stream link and the second time to get the maximum channel length.
For both runs of this tool, the feature definition file is your stream link identifier raster. The input data file will be the flow accumulation (basin area) raster for the first run and is the farthest distance to channel head raster for the second run. In each case, you really only care about the HTML table file output. Each link in the stream network will correspond to one row in the table (row 0 is likely the background non-stream area and can be ignored). Copy the resulting two tables and paste them into an Excel spreadsheet. Then it's fairly easy to graph the relation between basin channel length and area, as below:
Note, WhiteboxTools also provides a HackStreamOrder tool, although I don't think that this does what you are looking to do. It applies Hack's stream ordering system to a raster stream network, which is not the length-area relation defined in Hack's 'Law'.