-- Leo's gemini proxy

-- Connecting to perso.pw:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;

Using nix download bandwidth limit feature


Author: Solène

Date: 23 August 2022

Tags: bandwidth nix linux


Comment on Mastodon


Introduction


I submitted a change to the nix package manager last week, and it got merged! It's now possible to define a bandwidth speed limit in the nix.conf configuration file.


Link to the GitHub pull request


This kind of limit setting is very important for users who don't have a fast Internet access, this allows the service to download packages while keep the network usable meanwhile.


Unfortunately, we need to wait for the next Nix version to be available to use it, fortunately it's easy to override a package settings to use the merge commit as a new version for nix.


Let's see how to configure NixOS to use a newer Nix version from git.


Setup


On NixOS, we will override the nix package attributes to change its version and the according checksum.


We want the new option "download-speed" that takes a value for the kilobytes per second speed limit.


  nix.extraOptions = ''
    download-speed = 800
  '';
  nixpkgs.overlays = [
      (self: super:
      {
          nix = super.nix.overrideDerivation (oldAttrs: {
              name = "nix-unstable";
              src = super.fetchFromGitHub {
                  owner = "NixOS";
                  repo = "nix";
                  rev = "8d84634e26d6a09f9ca3fe71fcf9cba6e4a95107";
                  sha256 = "sha256-Z6weLCmdPZR044PIAA4GRlkQRoyAc0s5ASeLr+eK1N0=";
              };
          });
      })
  ];

Run "nixos-rebuild switch" as root, and voilà!


For non-NixOS, you can clone the git repository, checkout the according commit, build nix and install it on your system.


Going further


Don't forget to remove that override setting once a new nix release will be published, or you will keep an older version of nix.

-- Response ended

-- Page fetched on Mon May 6 09:22:11 2024