How to mine Ethereum with Nix

Alexej Bondarenko
2 min readFeb 20, 2021

With the recent upmelting values of crypto currencies it can now be again very profitable to mine with your own GPU. One of the best options is mining of ETH, the cryptocurrency of the Ethereum network.

Back in 2017 I was using my own Linux machines which were at this time running Manjaro or Ubuntu to mine XMR or ETH. Meanwhile I migrated all my machines/servers to NixOS and was curious if it is easily possible to mine on Nix (or in a Nix Shell, to be precise). Good news, it is!

ETH is usually mined with the ethminer. If we search the packages on nixos.org we will see that there is a package called ethminer, which is exactly what we need. So, let’s get started! Create a new (project) folder and add a shell.nix file with the following content:

mkdir miningnano mining/shell.nix

As you can see, we use the default nixpkgs of the current system. We add the ethminer package and a custom ethMinerScript. The script gives us the opportunity to easily start the mining process by just typing start after our shell is created (nix-shell command). In this example I am using the European location of the ethermine.org pool. You need to replace ETH_ADDRESS and ETH_MINER_TAG for your use case. The address is the wallet and the tag is just a string to identify your machine (let’s say my-mining-worker1).

Basically that’s it! We can now enter the mining folder and execute:

nix-shell --run start

This will create a shell with all needed dependencies (and build the ethminer). Finally the mining process will kick in. Happy mining!

I have written some other articles if you are interested in learning Nix or NixOS, have a look:

--

--