Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Mirror nix’s default.nix mechanism in path discovery #58

Closed
Profpatsch opened this issue Apr 10, 2019 · 1 comment
Closed

Mirror nix’s default.nix mechanism in path discovery #58

Profpatsch opened this issue Apr 10, 2019 · 1 comment
Assignees
Labels
bug Something isn't working P1 critical: next release user-facing Improvement that increases user experience

Comments

@Profpatsch
Copy link
Collaborator

Profpatsch commented Apr 10, 2019

I forgot to post my findings, but yes this is true! Nix doesn't emit /path/to/default.nix as the true file, it emits just '/path/to. A possible solution here is to append a /default.nix` when an imported directory is identified.

Originally posted by @grahamc in #21

We currently watch the whole directory if a user does import /path/to/directory. Nix implicitely assumes /path/to/directory/default.nix if used with import. We should mirror that, to prevent watching too many files.

@grahamc
Copy link
Contributor

grahamc commented Aug 30, 2019

I think the solution here is to extend LogDatam to have an EvalSource variant:

lorri/src/builder.rs

Lines 128 to 131 in f93989b

enum LogDatum {
Source(PathBuf),
Text(OsString),
}

and then make use of the LogDatum::EvalSource here:

lorri/src/builder.rs

Lines 155 to 156 in f93989b

if let Some(matches) = EVAL_FILE.captures(&linestr) {
LogDatum::Source(PathBuf::from(&matches["source"]))

then when we're adding the list of paths at:

match result {

match EvalSource, do an is_dir check, and push a default.nix if is_dir returns true.

Profpatsch added a commit that referenced this issue Sep 5, 2019
For a directory import like `import ./foo`, nix imports
`./foo/default.nix` but only prints `./foo` to its log output.
This commit reproduces that behaviour.

We were watching way too many files, e.g. `import <nixpkgs> {}` meant
we’d watch all of nixpkgs recursively. This should be solved now.

Fixes #58
Profpatsch added a commit that referenced this issue Sep 5, 2019
For a directory import like `import ./foo`, nix imports
`./foo/default.nix` but only prints `./foo` to its log output.
This commit reproduces that behaviour.

We were watching way too many files, e.g. `import <nixpkgs> {}` meant
we’d watch all of nixpkgs recursively. This should be solved now.

Fixes #58
Profpatsch added a commit that referenced this issue Oct 4, 2019
For a directory import like `import ./foo`, nix imports
`./foo/default.nix` but only prints `./foo` to its log output.
This commit reproduces that behaviour.

We were watching way too many files, e.g. `import <nixpkgs> {}` meant
we’d watch all of nixpkgs recursively. This should be solved now.

Fixes #58
Profpatsch added a commit that referenced this issue Oct 4, 2019
For a directory import like `import ./foo`, nix imports
`./foo/default.nix` but only prints `./foo` to its log output.
This commit reproduces that behaviour.

We were watching way too many files, e.g. `import <nixpkgs> {}` meant
we’d watch all of nixpkgs recursively. This should be solved now.

Fixes #58
Profpatsch added a commit that referenced this issue Oct 4, 2019
For a directory import like `import ./foo`, nix imports
`./foo/default.nix` but only prints `./foo` to its log output.
This commit reproduces that behaviour.

We were watching way too many files, e.g. `import <nixpkgs> {}` meant
we’d watch all of nixpkgs recursively. This should be solved now.

Fixes #58
Profpatsch added a commit that referenced this issue Oct 4, 2019
We shouldn’t emit any paths to the watcher that are not strictly
necessary; the default.nix logic ensures that we only watch the
special `default.nix` file if a directory is imported.
This test checks that that is actually the case.

In the future it should be extended for other cases of watching too
much, once we discover them.

For a directory import like `import ./foo`, nix imports
`./foo/default.nix` but only prints `./foo` to its log output.
This commit reproduces that behaviour.

We were watching way too many files, e.g. `import <nixpkgs> {}` meant
we’d watch all of nixpkgs recursively. This should be solved now.

Fixes #58
Profpatsch added a commit that referenced this issue Oct 7, 2019
For a directory import like `import ./foo`, nix imports
`./foo/default.nix` but only prints `./foo` to its log output.
This commit reproduces that behaviour.

We were watching way too many files, e.g. `import <nixpkgs> {}` meant
we’d watch all of nixpkgs recursively. This should be solved now.

Fixes #58
@grahamc grahamc closed this as completed in e7acd51 Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working P1 critical: next release user-facing Improvement that increases user experience
Projects
None yet
Development

No branches or pull requests

2 participants