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

devenv fails to exclude files with nix-filter #331

Open
smunix opened this issue Jan 28, 2023 · 2 comments
Open

devenv fails to exclude files with nix-filter #331

smunix opened this issue Jan 28, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@smunix
Copy link

smunix commented Jan 28, 2023

Describe the bug

devenv doesn't honor instructions to exclude files using nix-filter.

See the complete description of the bug here

To Reproduce

Get the file sources

Clone this small repository devenv-issue-01:

> git clone https://github.com/smunix/devenv-issue-01
Cloning into 'devenv-issue-01'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 15 (delta 1), reused 12 (delta 1), pack-reused 0
Receiving objects: 100% (15/15), 5.48 KiB | 5.48 MiB/s, done.
Resolving deltas: 100% (1/1), done.

cd into devenv-issue-01:

> cd devenv-issue-01 
> ls
README.md	devenv.lock	devenv.yaml	flake.nix
Top.hs		devenv.nix	flake.lock	package.yaml

Our devenv.nix requests excluding the package.yaml file, so to force callCabal2nix to fail:

> cat devenv.nix
{ pkgs, inputs, ... }:
let
  hpkgs = pkgs.haskellPackages;
  Top = with pkgs.haskell.lib;
    with hpkgs;
    with inputs;
    callCabal2nix "Top" (nix-filter.lib.filter {
      root = self;
      exclude = [ "package.yaml" ];
    }) { };
in {
  env.name = "bug.01";
  env.GREET = "bug.01";
  packages = [ Top ];
  scripts.hello.exec = "echo hello from $GREET";
  enterShell = ''
    hello
  '';
}

Building

Build with devenv

Run devenv and see it build successfully (this is bogus):

> devenv shell Top
Building shell ...
warning: Git tree '/Users/smunix/programming/repros/devenv-issue-01' is dirty
warning: applying 'toString' to path '/Users/smunix/programming/repros/devenv-issue-01/package.yaml' and then accessing it is deprecated, at «github:numtide/nix-filter/1a3b735e13e90a8d2fd5629f2f8363bd7ffbbec7»/default.nix:164:7
warning: applying 'toString' to path '/Users/smunix/programming/repros/devenv-issue-01/' and then accessing it is deprecated, at «github:numtide/nix-filter/1a3b735e13e90a8d2fd5629f2f8363bd7ffbbec7»/default.nix:165:8
hello from bug.01
"devenv sits at the Top"

Build with flake

Run the build using flake and see it fail to build (this is expected):

> nix develop -c Top
error: builder for '/nix/store/grydafb37p8qkk575g14b1z0m4gn6w7j-cabal2nix-Top.drv' failed with exit code 1;
       last 1 log lines:
       > cabal2nix: user error (*** Found neither a .cabal file nor package.yaml. Exiting.)
       For full logs, run 'nix log /nix/store/grydafb37p8qkk575g14b1z0m4gn6w7j-cabal2nix-Top.drv'.
(use '--show-trace' to show detailed location information)

The flake.nix also requested to exclude the package.yaml file, so the build failure is expected:

> cat flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
    devenv.url = "github:cachix/devenv";
    nix-filter.url = "github:numtide/nix-filter";
  };

  outputs = { self, nixpkgs, devenv, ... } @ inputs:
    let
      systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
      forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
    in
    {
      devShells = forAllSystems
        (system:
          let
            pkgs = import nixpkgs {
              inherit system;
            };
            hpkgs = pkgs.haskellPackages;
            Top = with pkgs.haskell.lib;
              with hpkgs;
              with inputs;
              callCabal2nix "Top" (nix-filter.lib.filter {
                root = self;
                exclude = [ "package.yaml" ];
              }) { };
          in
          {
            default = devenv.lib.mkShell {
              inherit inputs pkgs;
              modules = [
                {
                  env.name = "bug.01";
                  env.GREET = "bug.01";
                  packages = [ Top ];
                  scripts.hello.exec = "echo hello from $GREET";
                  enterShell = ''
                    hello
                  '';
                }
              ];
            };
          });
    };
}

Version

> devenv version
devenv: 0.5
@smunix smunix added the bug Something isn't working label Jan 28, 2023
@smunix smunix changed the title devenv fails to exlude files with nix-filter devenv fails to exclude files with nix-filter Jan 28, 2023
@domenkozar
Copy link
Member

This seems to be the current limitation of lazy-trees Nix branch that we're using. See NixOS/nix#6530 for updates

@smunix
Copy link
Author

smunix commented Feb 14, 2023

This seems to be the current limitation of lazy-trees Nix branch that we're using. See NixOS/nix#6530 for updates

Correct, @DavHau explains the issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants