Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

morph evaluates nixpkgs.overlays twice #71

Closed
delroth opened this issue Sep 9, 2019 · 0 comments · Fixed by #72
Closed

morph evaluates nixpkgs.overlays twice #71

delroth opened this issue Sep 9, 2019 · 0 comments · Fixed by #72
Milestone

Comments

@delroth
Copy link
Contributor

delroth commented Sep 9, 2019

Example repro:

let
  # Pin the deployment package-set to a specific version of nixpkgs
  pkgs = import (builtins.fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/98d9589819218971a95fd64c172fe5996a9734f5.tar.gz";
    sha256 = "0blscxj13qbcnlxkzwjsyqa80ssnx9wm0wz0bg6gkc1fa412w4f9";
  }) {};
in
{
  network =  {
    inherit pkgs;
    description = "simple hosts";
  };

  "web01.example.com" = { config, pkgs, ... }: {
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;

    nixpkgs.overlays = [(self: super: {
      my_hello = (if super?my_hello then throw "fail" else super.hello);
    })];

    environment.systemPackages = with pkgs; [ my_hello ];

    fileSystems = {
        "/" = { label = "nixos"; fsType = "ext4"; };
        "/boot" = { label = "boot"; fsType = "vfat"; };
    };
  };
}

morph build fails to build this derivation because the throw is triggered. This means that the overlay is applied twice.

This causes real world issues when for example you use an overlay to apply a patch to a package: patches = old.patches ++ [ ./mypatch ]; will end up appending the patch twice, causing build failures.

Both nixops and the normal nixos-config handle this case correctly and apply the overlay only once.

cc @Shados (again, sorry :P I'm working through the issues trying to migrate my small network from nixops to morph)

johanot pushed a commit that referenced this issue Sep 9, 2019
@johanot johanot added this to the 1.3.1 milestone Sep 9, 2019
adamtulinius pushed a commit that referenced this issue Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants