Skip to content

Instantly share code, notes, and snippets.

@asheshambasta
Last active May 5, 2020 16:04
Show Gist options
  • Save asheshambasta/64079577017e753f6d1c2d55a8c48b74 to your computer and use it in GitHub Desktop.
Save asheshambasta/64079577017e753f6d1c2d55a8c48b74 to your computer and use it in GitHub Desktop.
self: super:
with super.haskell.lib;
# First fetch a particular commit
let
src = builtins.fetchGit {
url = "ssh://git@github.com/brendanhay/amazonka.git";
ref = "develop";
rev = "ed7630edacc09e627ed0ee59126f4cdca0d73a0c";
};
# takes a name, and builds a package with that subdir.
amzDer = name: super.haskellPackages.callCabal2nix name "${src}/${name}" { };
# we now completely override the previous amazonka derivations.
in {
haskellPackages = super.haskellPackages.override {
overrides = _: _: {
amazonka = amzDer "amazonka";
amazonka-core = super.haskellPackages.callCabal2nix "amazonka-core" "${src}/core" { };
amazonka-s3 = amzDer "amazonka-s3";
amazonka-sns = amzDer "amazonka-sns";
amazonka-sqs = amzDer "amazonka-sqs";
amazonka-test = amzDer "amazonka-test";
};
};
}

The utils.nix file provides me with a simple function to fetch a given nix channel.

I'm using it to fetch nixos-19.09 where amazonka has been marked as broken.

nix-repl> utils = import ./utils.nix 

nix-repl> overlays = [ ((import ./amazonka.nix) ] 

Here, I'm fetching an older nix channel in which amazonka is marked as broken. the point of the overlay above is to "fix" amazonka with a manual override in which I fetch the amazonka src. and replace the broken amazonka packages.

nix-repl> oldPkgs = import (utils.fetchNixChannel "nixos-19.09") { inherit overlays; } 

This works, and the overlays do get applied. For example, amazonka-core is no longer broken, since the following doesn't refuse to evaluate:

nix-repl> oldPkgs.haskellPackages.amazonka-core
«derivation /nix/store/x8gz5is6p5nkgmfv4pgfkvzr7ijw7ril-amazonka-core-1.6.1.drv»

As one might expect, amazonka is now also marked as not-broken, since when trying to evaluate amazonka, the broken warning doesn't get issued because of amazonka but because of amazonka-core:

nix-repl> oldPkgs.haskellPackages.amazonka
error: Package ‘amazonka-core-1.6.1’ in /nix/store/15mm3lzryjh0q0yg4jncr48awpkwhzvy-source/pkgs/development/haskell-modules/hackage-packages.nix:25945 is marked as broken, refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowBroken = true; }
to ~/.config/nixpkgs/config.nix.

The issue here is that I've overriden amazonka-core in my overlay. But amazonka seems to be wired to a version of amazonka-core that has not been overlayed. It somewhat makes sense to me that this is the correct thing to do on nix's part.

However, I find it confusing still: and how can this be overcome?

{
fetchNixChannel = channel:
builtins.fetchTarball ("http://nixos.org/channels/${channel}/nixexprs.tar.xz");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment