Best Way To Manage Project Dependencies | Nix Shells

  Рет қаралды 17,529

Vimjoyer

Vimjoyer

Күн бұрын

Пікірлер: 159
@dejangegic
@dejangegic 2 ай бұрын
Why would I write a Dockerfile in a minute or two, when I can spen the afternoon doing the same thing in Nix?
@vimjoyer
@vimjoyer 2 ай бұрын
Exactly
@vojtechralis6075
@vojtechralis6075 2 ай бұрын
chatGPT writes nix files not me
@parsanobahari6089
@parsanobahari6089 2 ай бұрын
​@@vojtechralis6075dear god
@mikemerinoff
@mikemerinoff 2 ай бұрын
@@vojtechralis6075who’s writing gpt prompts for you?
@anonymouscommentator
@anonymouscommentator 2 ай бұрын
​@@vojtechralis6075chatgpt sucks at nix 😂
@gregf3021
@gregf3021 2 ай бұрын
Every time I sit down and think hmm I really want a new vimjoyer video it appears. Thank you for your hard work.
@vimjoyer
@vimjoyer 2 ай бұрын
👍
@ベース-l1f
@ベース-l1f 2 ай бұрын
I like the new visual style you have for your videos
@vimjoyer
@vimjoyer 2 ай бұрын
Didn't quite have enough time to polish it for this one, hope it's going to look even better in the next one
@LuxioTheMan
@LuxioTheMan 22 күн бұрын
@@vimjoyer you're good, great even
@lowgos0606
@lowgos0606 2 ай бұрын
You are the best. I love how you show both the flake and classic ways, this is really helpful. And the building debug technique is great
@Dominik-K
@Dominik-K 2 ай бұрын
Thanks a bunch for this video. This is one of the super powers of nix and those shells are just way easier to use than any container setup I know
@mastermach50
@mastermach50 2 ай бұрын
Note that if you use `nix-shell` (no flakes) only the packages and dependencies specified in shell.nix get added to the /nix/store, but if you use `nix shell` (flakes) the entire folder that contains flake.nix gets added to /nix/store. So if there are many large files in your project (like some AI models) those also get added to /nix/store taking up a lot of space.
@yash1152
@yash1152 2 ай бұрын
thanks a lot for sharing this. the obvious difference between those is default channel, but thanks for sharing this too.... but also, it feels counter intuitive for even the ... umh wait, so, there's "nix shell" and "nix develop"... are these two same? 9:41 but kinda not clear what's the difference in "shell" and "build shell"
@kinzoku-dev
@kinzoku-dev 2 ай бұрын
vimjoyer never fails to make our toes wiggle
@vimjoyer
@vimjoyer 2 ай бұрын
Oh hi kinzoku
@kinzoku-dev
@kinzoku-dev 2 ай бұрын
​@@vimjoyer greetings fellow vim enthusiast
@MrVampify
@MrVampify 2 ай бұрын
This video showed up right on time. I just started learning how to make derivations. This is PERFECT.
@benjaminwagner4597
@benjaminwagner4597 2 ай бұрын
Your videos are always 10/10. Thank you for your contributions to the community!
@WaterGame7777
@WaterGame7777 2 ай бұрын
Wow, I know FOSS developers especially always talk about how prompting people to donate works, but this really made it click with me. Love your videos, it just never appeared in my mind that you take donations. so yay! PS: your videos are absolutely amazing and are how I got into Nix. Without them I might have ended up giving up on it again. Every time someone asks for advice on learning Nix(OS) I always recommend your videos!
@Bvngee
@Bvngee 2 ай бұрын
Note that any nix-shell command _can_ be replaced by nix develop. For example, `nix-shell -E "with import ; …"` can be replaced with `nix develop -expr "with import ; …"`. Also see nix develop -f. Another immensely useful option is nix-shell’s -command (or just -c for nix develop). This lets you, for example, use zsh instead of bash.
@vimjoyer
@vimjoyer 2 ай бұрын
facts
@simquinoa2030
@simquinoa2030 2 ай бұрын
I NEVER KNEW ABOUT -c. That's so useful thank you
@saitheninja
@saitheninja 2 ай бұрын
I like to use `shellHook = ''exec $SHELL''` in my file. Then `nix develop` will open your configured shell automatically, without having to type the extra flag. (Not sure if this works with `nix-shell` because I'm using flakes exclusively.)
@NabekenProG87
@NabekenProG87 2 ай бұрын
Yoooooo, thx for introducing me to build shells. I just got started making derivations, this seems to be a much more efficient way
@computing1
@computing1 10 күн бұрын
love this channel, please keep going!
@XDtaylormagic
@XDtaylormagic 2 ай бұрын
Great video! Always look forward to when you post! Hope you have a great day!
@lieywe3438
@lieywe3438 2 ай бұрын
I really enjoy your videos! I think mentioning lorri (to prevent certain shells' packages from being garbage collected) would've been informational too 🤔
@vimjoyer
@vimjoyer 2 ай бұрын
I think I can make a general video for useful tools from nix-community
@codeman99-dev
@codeman99-dev 2 ай бұрын
2:30 Thank you stating right up front why I won't switch. The isolation is paramount. Not only are devcontainers easy to share, but you are forced to update that configuration. Nothing is worse than a dev configuration that only one person on the team cares about.
@doce3609
@doce3609 2 ай бұрын
you are truly the nix god our world needed
@LucianThorr
@LucianThorr Ай бұрын
I've wanted to have a quick way to run a Jupyter notebook without having to deal with python virtual environments on my home computer. This seems like the perfect way to keep things clean and reproducible without having to worry about my python package manager going breaking itself every few months. Thanks for the pointers.
@Gilded_Seraphim
@Gilded_Seraphim 2 ай бұрын
You terrify me you mind reader, keep your dark magic away from me, CAUSE THERE AINT NO WAY you could know EXACTLY what I am struggling with
@vimjoyer
@vimjoyer 2 ай бұрын
I'm in your walls
@bencarmichael790
@bencarmichael790 2 ай бұрын
​@@vimjoyerIn my shell more like
@jheregreign
@jheregreign 2 ай бұрын
@@bencarmichael790 👻
@Majiy00
@Majiy00 2 ай бұрын
As always amazing video!!!!
@edhyjoxenbyl1409
@edhyjoxenbyl1409 2 ай бұрын
Setting environment variable in the mkShell scope is a legacy behavior. The recommended way is to use `env` sub attribute set. (like `env.MY_VAR = 1;`)
@yash1152
@yash1152 2 ай бұрын
thanks for sharing this. the "every not recognised var is considered env-var" thing is super yucky for me. > _" recommended way is to use `env` sub attribute set "_
@callanambulancebutnotforme5702
@callanambulancebutnotforme5702 2 ай бұрын
Loved the explanation 👏
@coramuirgen2959
@coramuirgen2959 2 ай бұрын
your videos are helpful overviews, thanks
@MonSteh
@MonSteh 2 ай бұрын
First comment, but have to say I like the speed at which you present in this video is the best (I'm a pretty slow guy tho).
@starving207
@starving207 2 ай бұрын
ХФФІХвзхфізвфхівхїфі ЛУчший Продолжай мой любимый ютубер по NIXOS
@vimjoyer
@vimjoyer 2 ай бұрын
thanks
@starving207
@starving207 2 ай бұрын
@@vimjoyer I LOVE U MY CRUSADER BOY
@SebastianLopez-nh1rr
@SebastianLopez-nh1rr Ай бұрын
Awesome work!
@gabrielnuetzi
@gabrielnuetzi 2 ай бұрын
to the point ❤ well done!!
@HiramBarrozo
@HiramBarrozo 2 ай бұрын
Hi! I really enjoy your videos, they're super helpful! I have a question: I'm starting to learn Nix (I love flakes) but sometimes I get stuck. What IDE would you recommend for a beginner like me? Thanks in advance!
@vimjoyer
@vimjoyer 2 ай бұрын
I use neovim, use whatever you feel most comfortable with.
@berkano4617
@berkano4617 2 ай бұрын
Every time i rebuild my NixOS new father appears. Btw, now i have 112 version🥳😝
@s1n7ax
@s1n7ax 2 ай бұрын
Boii waiting for this
@darux268
@darux268 2 ай бұрын
Being able to launch gui applications without having to fuck around with the x server is great, this sounds super useful on nix os but I don't think it'll kill dev containers anytime soon. If you want to share a dev environment with someone else it's much more likely they already have docker and docker knowledge than nix and nix knowledge
@JokingChickenn
@JokingChickenn 2 ай бұрын
Yes! Was literally just researching this. Are u a mindreader? Thx for video
@vimjoyer
@vimjoyer 2 ай бұрын
Nice
@anakin1337
@anakin1337 2 ай бұрын
i see a nix video i instantly press 👍
@CoinedBeatz
@CoinedBeatz 2 ай бұрын
this video some weeks ago would have helped me quite a bit :P. I really like the approach nix shells provide to specify project based dependencies especially with flakes to even lock those versions. I'm trying to switch fully to NixOS but my work environment prevents me from doing so. The main reason being that `schroot` is not available in nixpkgs. I'm currently trying to package that but get quite some resistance along the way. After all I'm not even sure if `schroot` will work as expected. That's why I'm pursuing distrobox for my work environment which I could more or less plug-in-replace the schroot calls. But then again the nix store gets mounted to my container, which creates conflicts... (most likely due to home-manager). So right now I'm trying to get a pure podman command that does the trick for now until I'm done with writing a dozen derivations for all the stuff that's missing. But every new project I'll create will be based on dev shells.
@diego55
@diego55 2 ай бұрын
Nice video! It would be great if you could use a specific version of Node, especially an older one. For example, I have a project running Node v12.22.2. Thank you for your videos, I'm starting to love Nixos thanks to you!
@vimjoyer
@vimjoyer 2 ай бұрын
That's what flakes allow you to do! You can check the nixpkgs package version history, and find nixpkgs that contain the version you need
@anticrisis9006
@anticrisis9006 2 ай бұрын
How can I upvote this twice? I've come back to review it multiple times. Very helpful, thank you!
@enriquecasas4001
@enriquecasas4001 2 ай бұрын
Awesome content!
@cyrus01337
@cyrus01337 2 ай бұрын
Since I already use Docker and Devpods, I don't see much use case for NixOS and it's various Nix* tooling, though it's quite the exotic distro that I'd love to trial in a VM some day.
@guifuentes8
@guifuentes8 2 ай бұрын
Amazing, bro.
@tortilla-dev
@tortilla-dev 2 ай бұрын
Hey! I just wanted to congratulate you on the amazing work you're doing with Nix, your explanations are super clear and helpful. It would be awesome if you could create a tutorial on Prisma since it has some conflicts on NixOS when used as a dependency in Node projects. Thanks for all the great content you share, and keep up the fantastic work! 💪🚀
@BaiDamqn
@BaiDamqn 2 ай бұрын
I love your videos !!!
@ruroruro
@ruroruro 2 ай бұрын
I strongly recommend using the nix3 cli in this case ("nix shell" with a space, it is enabled by the nix-command experimental feature). nix-shell isn't actually equivalent to "nix shell", it's equivalent to "nix develop". The older nix-shell command was originally intended to be used for developing/debugging nix derivations, not for ephemeral shells. If you want ephemeral shells (basically, if you want to temporarily emulate actually "installing" the packages) then "nix shell" is much better compared to nix-shell. For example, "nix shell nixpkgs#gcc" would use YOUR default shell and it would also populate a bunch of environment variables so that stuff like "man gcc" works inside that ephemeral shell. On the other hand "nix-shell" would always use bash and you won't be able to access the man pages.
@alyti
@alyti 2 ай бұрын
actually useful yt comments, wild, thanks for info
@NabekenProG87
@NabekenProG87 2 ай бұрын
Thx for the tip. But I guess now I have to type "nix shell nixpkgs#python312 nixpkgs#python312Packages." instead of "nix shell python312 python312Packages."? Seems kinda verbose
@ruroruro
@ruroruro 2 ай бұрын
@@NabekenProG87 you can significantly reduce the amount of typing required by 1) creating an alias for nix shell 2) creating a shorter name for nixpkgs in the flake registry and 3) using bash brace expansions. Applying all 3 tricks will result in something along the lines of ns pkgs#{hello,gcc,gnumake,python3.12}
@NabekenProG87
@NabekenProG87 2 ай бұрын
@@ruroruro thx for the tip, but fuck me for not using bash lmao
@ruroruro
@ruroruro 2 ай бұрын
@@NabekenProG87 What shell are you using? Brace expansions are also available in zsh and fish. Of the shells I know, only dash doesn't support them. Try running echo x{a,b}y in your shell. You should get "xay xby" if your shell supports brace expansions.
@pupip55
@pupip55 2 ай бұрын
that thumbnail though
@vimjoyer
@vimjoyer 2 ай бұрын
Clickbait 👍👍👍
@pupip55
@pupip55 2 ай бұрын
@@vimjoyer it definitely worked
@yash1152
@yash1152 2 ай бұрын
hi! what's the summary difference in * this current video titled: " Best Way To Manage Project Dependencies | Nix Shells " and * the older one titled: " Nix Dev Environments | Declare Your Coding Projects " i've watched these both, but can't recall the differences in these, and hence, can't decide which one to refer some other person to for which situation
@vimjoyer
@vimjoyer 2 ай бұрын
I like the newer one more, it focuses on the devshells, and leaves the flakes explanation to the flakes video
@Heshamelfakharani
@Heshamelfakharani 2 ай бұрын
i know this kinda goes against the purpose of nix shell but can i use docker insid them? would the docker instance be isolated in that shell? im working with big docker compose setups that i don't have the time to move entirely to nix
@vimjoyer
@vimjoyer 2 ай бұрын
You can use nixos-shell, it's like nix-shell but with docker
@Heshamelfakharani
@Heshamelfakharani 2 ай бұрын
@@vimjoyer thank you!!
@bobmcbob4399
@bobmcbob4399 2 ай бұрын
But you also get isolation of your home data in containers. You don't get that with nix shell.
@vimjoyer
@vimjoyer 2 ай бұрын
But you can still achieve that, I'll make a video about that soon
@bobmcbob4399
@bobmcbob4399 2 ай бұрын
@@vimjoyer ok, that would be interesting. My main motivation for dev containers is to stop the data hoovering from software within the container.
@rodrigof.5956
@rodrigof.5956 2 ай бұрын
I recommend using lorri, it autoloads the nix-shell when opening the directory, and it's also useful for using shells different to bash
@xlustx5591
@xlustx5591 2 ай бұрын
Man but python packages in nix make me cry every time
@RobertFletcherOBE
@RobertFletcherOBE 2 ай бұрын
yeah python packaging was bad enough, using python on nix is a complete pain.
@anonymouscommentator
@anonymouscommentator 2 ай бұрын
when you find out you have to recompile the entire cuda toolchain just because you wanted to use pytorch right after you had to compile the entire cuda toolchain because you wanted to use ollama
@nobody-bt3iwnobod
@nobody-bt3iwnobod 2 ай бұрын
You could use nix shell for installing python interpreter and then create a virtual envrionment for project specific packages. Similar to pyenv + venv
@MWLaboratories
@MWLaboratories 2 ай бұрын
Im stuck on installing npm packages not available in nix pkgs like vuetify.
@alyti
@alyti 2 ай бұрын
shout out to devenv flake and it's pre-commit-hooks and background process stuff, great for bootstrapping more complex envs than a few packages
@rishivora1076
@rishivora1076 2 ай бұрын
i still havent figured out how to work with python and its libraries using nix shell. for now, i just use devenv, but it doesnt protect installed packages from garbage collection.
@madol3728
@madol3728 2 ай бұрын
Man. I was just setting my new project with docker. I really just pushed the changes, closed my terminal and went to youtube. Yeah I'm opening my terminal up again
@Cypekeh
@Cypekeh 2 ай бұрын
What is the easiest way to always run the same shell with nix develop (like zsh), without always specifying the -c flag?
@vimjoyer
@vimjoyer 2 ай бұрын
Make an alias
@dezly-macauley
@dezly-macauley 2 ай бұрын
Any way to ensure that dynamically linked binaries work with this setup? Certain NixOS packages are a headache to use.
@vimjoyer
@vimjoyer 2 ай бұрын
All nixos packages will work just fine, but if you want to run foreign binaries, there are many ways to do it. You can try nix-ld/nix-alien, steam-run, or patch the binaries yourself
@dezly-macauley
@dezly-macauley 2 ай бұрын
@@vimjoyer Thanks!!!
@bulldoser2610
@bulldoser2610 2 ай бұрын
Just one question. If i use the unstable branch in flake is my system really reproducable? if not how do I acheive absolute reproducibility including package with exact versions? Thanks.
@vimjoyer
@vimjoyer 2 ай бұрын
Unstable version is perfectly fine. The name is scary, but it's very much reproducible, and more stable than most distros repos
@bulldoser2610
@bulldoser2610 2 ай бұрын
@@vimjoyer does flake.lock pin every package version from unstable branch?
@panchohorrillo509
@panchohorrillo509 2 ай бұрын
@@bulldoser2610 Yes it does. That's how I live 🙂
@anticrisis9006
@anticrisis9006 2 ай бұрын
Thanks
@yash1152
@yash1152 3 күн бұрын
i am running nix run. it is running the package i build fine, but i think it is not running the checkPhase (aka make check), as i deliberately added a failing test, yet i still see no output regarding that.
@v3rm1n
@v3rm1n 2 ай бұрын
I like devenvs that way I can start services haven’t found a ways to do it in a flake devshell
@yash1152
@yash1152 2 ай бұрын
6:22 > _" pkgs.mkShell.inputsFrom "_ how to specify a local mkDerivation.nix file inside the inputsFrom list?
@vimjoyer
@vimjoyer 2 ай бұрын
Those are just packages, so you can add your local packages there by wrapping callPackage in some parentheses().
@Resursator
@Resursator 2 ай бұрын
> solves "it work for my machine" problem Yeah, instead you will have "it doesn't work for any machine" problem :D
@NabekenProG87
@NabekenProG87 2 ай бұрын
Thats a possibility for all software. I can write a Python program that craps itself in 1min, tremble mortals
@nicholasantidormi6238
@nicholasantidormi6238 2 ай бұрын
How to manage different projects, with different nodejs versions (usually .nvmrc) and different package managers (in the last one usually done by specifying it in the package.json and using corepack)?
@vimjoyer
@vimjoyer 2 ай бұрын
You can get different versions of nodejs/npm/yarn in your shell with flakes. You just need to include additional inputs with correct versions for them
@nasang7478
@nasang7478 2 ай бұрын
What if nixpkgs doesn't have a specific dependency?
@vimjoyer
@vimjoyer 2 ай бұрын
You can package it, it's much easier on nixos. I'll make a better video about it soon
@MWLaboratories
@MWLaboratories 2 ай бұрын
@@vimjoyer sounds like the same problems I'm facing with adding vue/vite/vuetify to my nodejs dev shell. It isn't to be found in nixpkgs.
@Folvin-x1o
@Folvin-x1o 2 ай бұрын
Пон пон пон пон Согл согл согл Баз база Основа основа
@ДашаГолік
@ДашаГолік 2 ай бұрын
Nice
@alexander13094
@alexander13094 2 ай бұрын
And you need to figure out how to run it unprivileged. For docker it is just adding yourself into docker group
@vimjoyer
@vimjoyer 2 ай бұрын
you do not need any privileges to use nix shells
@alexander13094
@alexander13094 2 ай бұрын
Yeah, didn't noticed there is nix-users group. Will test
@alejandrobonilla7759
@alejandrobonilla7759 2 ай бұрын
Hey just one thing the aliases do not go from your shell to the new one (at least with zsh does not happen)
@alejandrobonilla7759
@alejandrobonilla7759 2 ай бұрын
Nice video, I got into nixos thanks to you keep it up
@alejandrobonilla7759
@alejandrobonilla7759 2 ай бұрын
So I tested it and it is because the -p invokes bash but the flakes way opens your default shell (in my case zsh)
@vimjoyer
@vimjoyer 2 ай бұрын
You can use add `--command $SHELL` at the end to get into your favorite shell
@ruroruro
@ruroruro 2 ай бұрын
or just use the nix3 cli (the ones with the spaces, enabled by the nix-command experimental feature) nix-shell isn't actually equivalent to "nix shell", it's equivalent to "nix develop". nix-shell was originally intended to be used for developing/debugging nix derivations. If you want ephemeral shells (basically, if you want to temporarily emulate actually "installing" the packages) then "nix shell" is much better compared to nix-shell. For example, "nix shell nixpkgs#gcc" would use YOUR default shell and it would also populate a bunch of environment variables so that stuff like "man gcc" works inside that ephemeral shell. On the other hand "nix-shell" would always use bash and you won't be able to access the man pages.
@isaacaymerich2741
@isaacaymerich2741 2 ай бұрын
you forget an important thing, what about pining package versions :) ?
@vimjoyer
@vimjoyer 2 ай бұрын
I have a whole 15 minute video about it, it's linked in the description
@3ChunkyPL
@3ChunkyPL 2 ай бұрын
Alright, so now we can talk about nix-direnv
@imnotchinese6235
@imnotchinese6235 2 ай бұрын
do you daily drive nixos?
@vimjoyer
@vimjoyer 2 ай бұрын
Of course
@imnotchinese6235
@imnotchinese6235 2 ай бұрын
@@vimjoyer i tried and failed, but i'll be back
@martianhunter7168
@martianhunter7168 2 ай бұрын
I started my minor programming hobby with nix shells, I don’t know real devs live without them.
@jabahuntercrypto
@jabahuntercrypto 2 ай бұрын
hmmm
@doce3609
@doce3609 2 ай бұрын
0:12 you have a grammatical issue. 2. should be than not then.
@Bvngee
@Bvngee 2 ай бұрын
7 seconds ago wtf
@cbleslie
@cbleslie 2 ай бұрын
Wait until these fools learn about nix-pre-commit-hooks.
@jamesgphillips91
@jamesgphillips91 2 ай бұрын
meh... why do this when you can wasi use shims?
@vimjoyer
@vimjoyer 2 ай бұрын
This is a completely different concept
@justadude8716
@justadude8716 2 ай бұрын
regards, guy who never worked with proprietary systems and assumes usecase for webshitters is best usecase for rest of us. Nice click bait title.
Nix(OS) Ecosystem Explained
11:19
Vimjoyer
Рет қаралды 12 М.
Ultimate Nix Flakes Guide
17:08
Vimjoyer
Рет қаралды 32 М.
Thank you Santa
00:13
Nadir Show
Рет қаралды 39 МЛН
The IMPOSSIBLE Puzzle..
00:55
Stokes Twins
Рет қаралды 186 МЛН
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 153 МЛН
快乐总是短暂的!😂 #搞笑夫妻 #爱美食爱生活 #搞笑达人
00:14
朱大帅and依美姐
Рет қаралды 13 МЛН
Easiest Way To Write Nix | Code Editor Setup
9:40
Vimjoyer
Рет қаралды 10 М.
docker stack is my new favorite way to deploy to a VPS
27:47
Dreams of Code
Рет қаралды 84 М.
Why Nix and NixOS is great (for developers)
9:20
J. J. Bigorra
Рет қаралды 695
Customize Nix Packages | Gentoo Experience on NixOS
10:03
Vimjoyer
Рет қаралды 10 М.
Nix Home Manager Has Forever Changed My Dotfiles
10:08
DevOps Toolbox
Рет қаралды 22 М.
Is Nushell Worth The Hype?
16:00
DevOps Toolbox
Рет қаралды 41 М.
Nix is my favorite package manager to use on macOS
28:08
Dreams of Autonomy
Рет қаралды 130 М.
Go Has Exceptions??
16:58
ThePrimeTime
Рет қаралды 86 М.
Nix explained from the ground up
23:39
Surma
Рет қаралды 63 М.
I'm Never Using Neovim's Terminal The Same Again
8:43
DevOps Toolbox
Рет қаралды 46 М.
Thank you Santa
00:13
Nadir Show
Рет қаралды 39 МЛН