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

Pass system explicitly to allow pure evaluation #74

Merged
merged 1 commit into from
May 21, 2022

Conversation

akirak
Copy link
Collaborator

@akirak akirak commented May 11, 2022

Hello,

Since adoption of niv for tracking sources in nix-emacs-ci (16c43b7), I cannot use the overlay in a Nix flake.

The error message is as follows:

error: attribute 'currentSystem' missing
at /nix/store/2iz88y66ln6yfhr4k2nlr50535g64fz2-source/nix/sources.nix:165:16:
164| , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
165| , system ? builtins.currentSystem
| ^
166| , pkgs ? mkPkgs sources system
(use '--show-trace' to show detailed location information)

This is because builtins.currentSystem is not allowed in pure evaluation mode, which is the default in flakes.

To prevent this error, you can pass the system explicitly, as in this PR. This API seems to be safe to use (see nmattia/niv#134 (comment)), and even it it is not, you can easily rollback the change.

To reproduce the error, you can create the following flake.nix in a Git repository:

{
  description = "Minimal flake project";

  inputs.emacs-ci = {
    url = "github:purcell/nix-emacs-ci";
    flake = false;
  };

  outputs = {
    self,
    nixpkgs,
    flake-utils,
    emacs-ci,
  }:
    flake-utils.lib.eachDefaultSystem
    (system: let
      pkgs = import nixpkgs {
        inherit system;
        overlays = [
          (import (emacs-ci + "/overlay.nix"))
        ];
      };
    in {
      packages = flake-utils.lib.flattenTree {
        default = pkgs.emacs-snapshot;
      };
    });
}

When you run nix build, it throws the error.

When you run the following command, it successfully builds:

nix build --override-input emacs-ci github:akirak/nix-emacs-ci/pure-eval

When the overlay is used inside a flake in pure evaluation mode,
it currently fails due to builtins.currentSystem.
@purcell
Copy link
Owner

purcell commented May 21, 2022

Makes sense, thanks! Sorry it broke things for you. I'd like to find time to play with Flakes more soon (I have lots of colleagues at Tweag who can help me).

@akirak akirak deleted the pure-eval branch May 21, 2022 18:13
@akirak
Copy link
Collaborator Author

akirak commented May 24, 2022

Thank you for merging this PR.

I have lots of colleagues at Tweag who can help me

That's fantastic. I read several blog posts from Tweag. I may possibly apply for one of those FP-embracing companies in the future, but not now.

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 this pull request may close these issues.

2 participants