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

Filtering src recursively when creating a derivation #59928

Closed
lippirk opened this issue Apr 20, 2019 · 2 comments
Closed

Filtering src recursively when creating a derivation #59928

lippirk opened this issue Apr 20, 2019 · 2 comments
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@lippirk
Copy link

lippirk commented Apr 20, 2019

I'm creating a derivation using items in a big folder, but I only actually want to use a few files to create the derivation. These files are nested in various directories. So I thought I could use sourceByRegex to select those files. But unfortunately sourceByRegex only seems to search through the top level of a folder.

For example:

$ tree
.
├── 1
├── 2
├── 3
├── default.nix
├── folder
│   ├── 1
│   └── 2
└── result -> /nix/store/951h922h1cx55703yk5fqj1l059d7kvg-my-drv

2 directories, 6 files

$ cat default.nix
{pkgs ? import <nixpkgs> {}}:
pkgs.stdenv.mkDerivation {
  name = "my-drv";
  src = pkgs.lib.sources.sourceByRegex ./. ["2" "folder\/.*"];
  installPhase = ''
    set -e
    mkdir -p $out/bin
    cp -r $src/* $out/bin/
    '';
}

$ ls /nix/store/951h922h1cx55703yk5fqj1l059d7kvg-my-drv/bin
2

I hoped to see the both the file 2 and also folder in that last output, but only 2 was copied.

Is there another way to achieve this?

@infinisil
Copy link
Member

Check out #56985, which adds a function to make this pretty easy

@stale
Copy link

stale bot commented Jun 3, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2020
@lippirk lippirk closed this as completed Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

No branches or pull requests

2 participants