Comments (13)
Did you use it from direnv
? shellHook
is specifically only called from nix-shell
, lorri direnv
does not source it.
For your example, you can easily add FOO
this way:
with import <nixpkgs> {};
mkShell {
FOO="BAR"
}
(because everything you pass to mkShell
is passed to mkDerivation
(is passed to derivation
), which convert each field in their argument attrset (like shellHook
or buildPhase
or in this case FOO
) to an environment variable.
In general we might have to think about how to integrate shellHook
in a way that is backwards-compatible to nix-shell
. cc @grahamc
from lorri.
I have non-trivial scripts in my shellHook
that expose bash functions that do things like setup test environments. It would be nice if everything in shellHook
ran, so that echo "instructions on how to use this shell"
get printed along without whatever else is going on.
from lorri.
yeah, sourcing shellHook would be great. Maybe even allow variable IS_IN_LORRI
from lorri.
Thanks for the quick reply. Yes, I was using it with direnv
. We are prepending a local directory containing some utility scripts to PATH
in the shellHook
. When switching over from direnv
+ nix-shell
to direnv
+ lorri
those weren't available anymore.
from lorri.
Note that we have the same problem in lorri itself, so a good solution would be class.
As in: we add the paths both in .envrc
and in shell.nix
.
from lorri.
It looks like some packages set up implicit shell hooks as well: #23 (comment)
So this becomes more pressing to implement.
from lorri.
It’s a bit more complicated than that actually, we can’t just re-use existing shellHook
s that packages provide, because they rely on the exact environment provided by the nix builder, which lorri cannot guarantee.
@grahamc gave an example of a problematic shellHook
:
rm -rf $(find-the-thing)/*
andfind-the-thing
is defined in another hook which we don’t load.
so lorri/direnv would effectively execute rm -rf /*
in that case.
We need to provide a good mechanism to achieve something similar with lorri.
from lorri.
maybe add an arg --shell-hook
to make it opt-in?
from lorri.
maybe add an arg
--shell-hook
to make it opt-in?
We could do something like lorriHook
which users can explicitely alias to shellHook
if they want to use it with lorri as well. Then we can define a strict environments we provide.
But we can’t really allow shellHook
s from transitive packages, for the reason I’ve outlined above. It’s just impossible to handle in the general case. But most of those hooks are pretty easy to adapt for the user I think (e.g. just manually write GOPATH=…
into your hook).
from lorri.
I have no trivial scripts in my
shellHook
that expose bash functions that do things like setup test environments.
Does this mean you do have bash functions in your shellHook
? Or the opposite?
from lorri.
As a stop-gap solution we could display a warning to the user that a shellHook
was not executed (and maybe the contents of the shellHook
).
from lorri.
I have a partial workaround for people who live in Emacs
https://gist.github.com/Drainful/a3cd702dc590480cf4897a9859fc499f
from lorri.
Addressed in #75
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.