Skip to content

Instantly share code, notes, and snippets.

@oscarduignan
Created October 11, 2017 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarduignan/20991f9289403eb3ec81e5f281b2df66 to your computer and use it in GitHub Desktop.
Save oscarduignan/20991f9289403eb3ec81e5f281b2df66 to your computer and use it in GitHub Desktop.
Get the latest version of docker-compose with nixpkgs which requires overriding texttable dependency version
{
packageOverrides = pkgs: with pkgs; rec {
docker_compose = pkgs.docker_compose.override (oldAttrs: {
texttable = python.pkgs.buildPythonPackage rec {
name = "texttable-0.9.1";
src = fetchurl {
url = "mirror://pypi/t/texttable/${name}.tar.gz";
sha256 = "119041773ff03596b56392532f9315cb3a3116e404fd6f36e76a7dc088d95c79";
};
};
});
latest_docker_compose = docker_compose.overrideDerivation (oldAttrs: rec {
name = "docker-compose-1.16.1";
src = fetchurl {
url = "mirror://pypi/d/docker-compose/${name}.tar.gz";
sha256 = "fb46a6a2c4d193a3ff1e4d7208eea920b629c81dc92257c87f3f93095cfb0bdf";
};
});
base = buildEnv {
name = "base";
paths = [
latest_docker_compose
];
};
};
}
@oscarduignan
Copy link
Author

oscarduignan commented Oct 11, 2017

I am setting up my local dev environment on nixos with nixpkgs inside of ~/.config/nixpkgs/config.nix and I wanted the latest version of docker-compose which isn't in nixpkgs yet.

I tried just using overriding the docker-compose src to use 0.16.1 first but it gave me a dependency error for texttable because the texttable dependency in nixpkgs/pkgs/top-level/python-packages.nix is 0.8.4 and docker-compose 0.16.1 requires >= 0.9.0 so then I had to override the docker-compose function first and give it an appropriate version of texttable

I pulled the texttable definition from the nixpkgs/pkgs/top-level/python-packages.nix file and modified it - and I grabbed the sha256 from https://pypi.org/project/texttable/#files (old version of pypi just has the md5 but new one has the sha256 - copy to clipboard link located by filename)

Then to actually run the above you'd use nix-env -i base to install the base collection (buildEnv) defined above.

Is there a better way to do all of this?

@oscarduignan
Copy link
Author

For future reference, I got a recommendation from fearlessKim[m] on #nixos on freenode to look at overlays when I asked for some feedback on my approach and I have attempted to reimplement the above using them at https://gist.github.com/oscarduignan/6ce341dd02061b7cfd295a8ba7b8b826 probably needs some refining as it was mostly trial and error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment