Comments (10)
To get around such problems, I'd love to have a lorri reload
for manual (or externally triggered) reloading.
from lorri.
I’ve seen this, too. I think we’ll need some additional setup for properly recognizing IFD paths. I had started a minimal repro somewhere, will push it once it’s ready.
from lorri.
Here’s an old issue I just migrated that talks about this: #31
from lorri.
I tried to get around this issue for developing a cabal-based project, but ran into issues. Documenting this here in the hope it saves someone some time.
Haskell package environment sucks in the source
I ran cabal2nix
by hand but lorri
watched my whole directory. This surprised me, since the environment derived from the shell.nix
produced by cabal2nix --shell . > shell.nix
should not contain the source: it should only contain the dependencies of the package under development. This turns out to be a known issue: NixOS/nixpkgs#51079.
Haskell package environment not directly overridable
Since cabal2nix
produces src = ./.
, I thought my issue might be due to #58. To get around it, I overrode the source with the following default.nix
:
with import <nixpkgs> {};
let
drv = haskellPackages.callPackage (import ./package.nix) { };
drv' = drv.overrideAttrs (attrs: rec {
src = nix-gitignore.gitignoreSource [".gitignore" "*.nix" "*.cabal" ".envrc"] ./.;
})
in
drv'.env
created the simple shell.nix
:
import ./default.nix
and generated package.nix
with cabal2nix . > package.nix
. But this did not solve my problem. lorri
was still watching the whole directory. Digging in the code, I think the issue is with the use of shellFor
to generate the haskell package derivations env
attribute introduced in NixOS/nixpkgs@5067773e39a. To be able to use shellFor
, the fix
operator is used which prevents the derivation from being truly overridable: overriding the source takes effect in the derivation but not in its env
. The following default.nix
is not ideal but fixes the issue:
with import <nixpkgs> {};
let
drv = haskellPackages.callPackage (import ./package.nix) { };
drv' = drv.overrideAttrs (attrs: rec {
src = nix-gitignore.gitignoreSource [".gitignore" "*.nix" "*.cabal" ".envrc"] ./.;
});
in
haskellPackages.shellFor { packages = _: [drv']; }
from lorri.
You don't even need IFD to reproduce this issue. Just running the imported derivation with a filtered source is sufficient:
let
pkgs = import <nixpkgs> {};
deps = pkgs.stdenv.mkDerivation {
name = "deps";
src = builtins.filterSource (path: type: baseNameOf path == "example") ./.;
installPhase = ''
echo "pkgs: with pkgs; [ $(cat example) ]" > $out
'';
};
in deps
Running the code that lorri uses internally to gather sources to watch shows that no reference to example
is emmitted
$ nix-build -vv --no-out-link --expr "import ./logged-evaluation.nix { src = ./just-filter.nix; }" 2>&1 | grep example
<no output>
I haven't tried this with the latest version on master yet, so the results may have changed.
On a slightly unrelated note, callCabal2nix
is supposed to have a filter already (see source code), but that seems to be kind of broken and the full source is included in the build for the cabal2nix-derivation anyways. :/
from lorri.
@anka-213, in your example, lorri
is not expected to track the file example
. It is a source file that does not have an influence on the shell environment that nix-shell
should set up. @infinisil's example is different because he uses deps
in the nativeBuildInputs
field, which means, the content of the pkg
file will impact the content of the shell environment.
from lorri.
@dudebout Aha, I see. However, the fact that nothing is logged in my example is probably the cause for not being able to track the sources through IFD. No info about what sources are being copied is being logged.
I am also a bit confused why manual filtering makes any difference when using callCabal2nix, since that already does filtering. For example:
pkgs.haskellPackages.callCabal2nix "example" ./. {}
will track the whole directory and nix-shell -vv
will print
copied source '/path/to/example' -> '/nix/store/someHash-example'
while
pkgs.haskellPackages.callCabal2nix "example" (pkgs.lib.cleanSource ./.) {}
will not print such a copy statement and not track anything but the nix-file itself,
despite both commands copying exactly the same subset of the directory (the cabal-file) before generating the nix-derivation with cabal2nix.
Is this caused by NixOS/nixpkgs#51079? If so, adding an empty filter around src seems to be an extremely hacky workaround to that issue.
from lorri.
I think what your are after is point 2. in #6 (comment)
from lorri.
@dudebout Aha, I see. However, the fact that nothing is logged in my example is probably the cause for not being able to track the sources through IFD. No info about what sources are being copied is being logged.
I have also come across this. Looking at Nix' source code, I got as far as follows:
- "copied source" is only logged by
copyPathToStore
copyPathToStore
is only called fromcoerceToString
coerceToString
is called from all over the place
But it looks like the following are true:
src = ./.
or similar lead tocopyPathToStore
being called, so we get "copied source"src = builtins.filterSource (...) ./.
andsrc = builtins.path (...) ./.
use different code paths and no "copied source" is logged by Nix.
As a result, lorri adds the former to the watch list, but not the latter.
We had discussions about changing Nix' output some time ago, I think it is time to revive those discussions.
from lorri.
(Sorry about the spam, I just need a place to record this somewhere ...)
Grepping through the Nix codebase, here's what I've found: the path
and filterSource
primops both instantiate a PathFilter
which is then passed around.
rg -F PathFilter
shows that the argument of typePathFilter
is always calledfilter
.rg '\Wfilter\('
shows that the only time a function calledfilter
is called in the entire codebase is inarchive.cc::dump
.
So in order to capture which files, post-filter
, Nix actually uses, one would need to record those files here (or somewhere downstream, e.g. in the consumer of the sink
into which the filtered files are dumped).
from lorri.
Related Issues (20)
- lorri clobbers nix-shell environment
- Show and update lorri daemon status in shell
- No documentation about runtime garbage collection
- Lorri does not use bashInteractive like nix-shell
- Lorri misbehaves when the shell has `disallowedReferences`
- `lorri direnv` extremely slow with a large number of env vars
- shellHook fails when sourcing bash completions HOT 1
- lorri Crash Report
- lorri Crash Report HOT 1
- Start lorry from Emacs HOT 1
- Bash completions fail because XDG_DATA_DIRS is reset HOT 1
- lorri Crash Report HOT 1
- lorri + direnv reloads environment after every command HOT 1
- Lorri doesn't build on unstable HOT 2
- lorri internal stream-events does nothing
- Lorri fails to setup FHS user environment HOT 3
- Lorri incorrectly prepend NODE_PATH instead of overwriting
- Breaks kde-open5/xdg-open HOT 2
- MAINTENANCE NOTICE HOT 1
- lorri Crash Report
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lorri.