Nix flakes explained

Sdílet
Vložit
  • čas přidán 3. 07. 2023
  • Enabling flakes:
    nixos.wiki/wiki/Flakes - commands are here
    Creating a flake:
    $ nix flake init
    Updating a flake:
    $ nix flake update
    Flake:
    ```
    {
    description = "my epic vims collection";
    inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    };
    outputs = { self, nixpkgs }:
    let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
    in
    {
    bob =
    pkgs.mkShell
    {
    buildInputs = [
    pkgs.neovim
    pkgs.vim
    ];
    shellHook = ''
    echo "hello mom"
    '';
    };
    };
    }
    ```
    (yes, I know I could push it to github, but I'm extra lazy today)

Komentáře • 80

  • @Becoming-Human
    @Becoming-Human Před 10 měsíci +128

    If my arithmetic is correct, you said nix twenty-seven (27) times. You said flake twenty-four (24) times, although technically thirteen (13) of the twenty-four (24) times was in the plural form as flakes. Nix, flakes, and cookies... yummy. :-) Keep up the excellent work with Nix and NixOS, as some of us are learning along with your videos and they help a lot. Thank you.

    • @vimjoyer
      @vimjoyer  Před 10 měsíci +17

      Holy cow! I'm going to have to count tomorrow morning, because It's late where I live, and also I've improvised in some parts of the video. 🍪

    • @Becoming-Human
      @Becoming-Human Před 10 měsíci +4

      Also, if you have run out of cookies to send me, no problem. As a cookie substitution, I would really appreciate trying to understand how I could get dGPU passthrough to a VM figured out on a laptop, which has an AMD iGPU, and an AMD dGPU. I would like to be able to use NixOS for the base operating system, which would use the AMD iGPU, and then passthrough the AMD dGPU to a Windows VM so that the kids can use the laptop for school, Roblox programming, and gaming. Let me know if you think that this would make a great video, and if not, no worries. Thank you.

    • @vimjoyer
      @vimjoyer  Před 10 měsíci +4

      ​@@Becoming-HumanI've actually managed to setup GPU pass through on NixOS on my Lenovo legion 5 amd + nvidia dgpu about 3 months ago. It was kind of easy on NixOS, because I didn't worry about blacklisting something important. Maybe I'll do a video about it later.

    • @affieuk
      @affieuk Před 10 měsíci

      @@vimjoyer Yes please to this, although I have intel igpu and nvidia dgpu (optimus). I've installed kvm and also quickemu, but haven't had time to troubleshoot why quickget seems to be downloading the windows iso, but then I don't find it in my home directory... Yes I know I can get it manually.

    • @stefanml90
      @stefanml90 Před 10 měsíci

      🤣🤣🤣🤣

  • @dasdadasdasd4917
    @dasdadasdasd4917 Před 10 měsíci +73

    Just last night I was complaining to my friend how I couldn't find a simple explanation how to use flakes, and you posted a video a few hours later. Thank you!

    • @vimjoyer
      @vimjoyer  Před 10 měsíci +20

      I'm making these videos because I'm also frustrated by the lack of documentation.

  • @raunakchhatwal5350
    @raunakchhatwal5350 Před 10 měsíci +10

    I had just recently decided that since my Nixos was already working, it probably wasn’t worth it to figure out the motivation behind nix flakes (which I really couldn’t grasp until I watched this video). Thanks, this really explained it.

  • @BartekBroniszewski
    @BartekBroniszewski Před 10 měsíci +20

    That is the most useful flakes introduction I have ever seen, good job mate

  • @auntiecarol
    @auntiecarol Před 3 měsíci +11

    This comment for the YT engagement algorithm: my Emacs bros would be mad at me watching content from someone called Vimjoyer, but I don't care. After having just gone though a painful Debian reinstall, I wondered if there was a better way. Nix might be it. Or it might be Guix (who knows?).
    For the time being, I am grateful for these videos. You have a new subscriber!

    • @Anonymous4045
      @Anonymous4045 Před 2 měsíci

      Did you end up going with nixos?

    • @auntiecarol
      @auntiecarol Před 2 měsíci +2

      @@Anonymous4045Yeah, there are many more examples to work from in comparison to Guix, and the community is larger.

  • @marcuswest8085
    @marcuswest8085 Před 10 měsíci +1

    I really appreciate your work VJ. The presentation is excellent - visually clear and painstaking. Seems like I'm not the only person who appreciates this.

  • @th3mon
    @th3mon Před 8 měsíci +7

    Your microphone is not terrible! You sound clear AF!

  • @mumk
    @mumk Před 24 dny +2

    Thanks, I've always thought that Nix is some witchcraft that is difficult for plebeians to practice, but turns out that it was a huge fallacy. Nix is so simple. Wouldn't have cleared out my doubt without you, many thanks for this splendid video, cheers.

  • @TheRationalLifter
    @TheRationalLifter Před 5 měsíci +3

    Clearest explanation/example of nix flakes I've seen so far. Thanks, really useful!

  • @ChrisMcDonough
    @ChrisMcDonough Před 10 měsíci +2

    Great series so far! You have a knack for explaining this stuff.

  • @CTWilliams89
    @CTWilliams89 Před 10 měsíci +1

    Loving the content, subbed and looking forward to more as I just discovered nix!

  • @mawfyy7001
    @mawfyy7001 Před 10 měsíci +3

    your channel is gold, i understand about flakes and nixOS more deeply, i hope that you can more videos talking NixOS and its environment.

  • @luckyspiff
    @luckyspiff Před 10 měsíci +1

    Good work, thank you! Please continue this series!

  • @Aditya-ny8ur
    @Aditya-ny8ur Před 10 měsíci +9

    KEEP THEM COMING!
    I'd appreciate it if you made a video explaining nix profile, home-manager and how wrapping configuration.nix in nix flake eliminates the need of updating nix-channel

    • @jdecicco91
      @jdecicco91 Před 10 měsíci

      Yes please, +1 for this^

  • @AminD0
    @AminD0 Před 8 měsíci +2

    Dude! Very nicely explained. Thanks

  • @benarcher372
    @benarcher372 Před měsícem +1

    Finally, a good nix flake description! Thx

  • @CarlosVixil
    @CarlosVixil Před 9 měsíci +2

    Fine! I'll subscribe. I think adding "- what are nix flakes?" to the title or description might help with SEO. Which Nix seems to be avoiding.

  • @pmmeurcatpics
    @pmmeurcatpics Před 2 měsíci +2

    I see that the playlist already has a lot of videos, but im still going to comment to make CZcams recommend this playlist to other users just it did to me:)

  • @jaydelux2086
    @jaydelux2086 Před 9 měsíci +2

    this was a very good explanation thank you

  • @gungun974
    @gungun974 Před 10 měsíci +3

    I finally started to understand what’s Flake are with your video.
    Now it’s time for some practice ❤

    • @vimjoyer
      @vimjoyer  Před 10 měsíci

      Practice makes perfect

  • @gbember3470
    @gbember3470 Před 10 měsíci +2

    Thank you for the video! I hope your channel gets more known

    • @vimjoyer
      @vimjoyer  Před 10 měsíci

      Thanks for kind words!

  • @user-db4dd4ze3n
    @user-db4dd4ze3n Před 10 měsíci +2

    The best explanation of flakes I have seem

    • @vimjoyer
      @vimjoyer  Před 10 měsíci +1

      Glad you liked it!

  • @johanvandermerwe7687
    @johanvandermerwe7687 Před 10 měsíci +1

    This was excellent!!

  • @zacharyquinn3676
    @zacharyquinn3676 Před 10 měsíci +1

    Keep the nix videos coming!

  • @mr2octavio
    @mr2octavio Před 10 měsíci +3

    Thank you for the video!
    Consider uploading it to the wiki or docs

    • @vimjoyer
      @vimjoyer  Před 10 měsíci

      I'm not satisfied with the quality enough for wiki or docs 😅

    • @sabergo1
      @sabergo1 Před 10 měsíci +4

      @@vimjoyer I'd say its better than what exists now. Thanks for the tutorial.

    • @mr2octavio
      @mr2octavio Před 10 měsíci +1

      ​@@sabergo1I agree, better fall forward

  • @wyfyj
    @wyfyj Před 10 měsíci +1

    Thank you so much for the video

  • @wyfyj
    @wyfyj Před 10 měsíci +1

    Thank you for the video

  • @bepobepobepo
    @bepobepobepo Před 10 měsíci +1

    Please keep making nix videos!

  • @pablo_alonso_ramos_henao3341
    @pablo_alonso_ramos_henao3341 Před 9 měsíci +2

    Thx dude.

  • @florianthesnow
    @florianthesnow Před 7 měsíci +1

    By far the best explanation of flakes out there! And I have been looking for a long time!

  • @cleteblackwell1706
    @cleteblackwell1706 Před 3 měsíci +2

    My major concern with flakes is that in today’s age keeping your system up to date with security fixes is paramount. I would want to run updates on all my flakes weekly in an automated fashion. I wish the cli had an easy option for that.

    • @vimjoyer
      @vimjoyer  Před 3 měsíci +1

      I think `system.autoUgrade` can work with flakes. Relevant discourse thread - discourse.nixos.org/t/best-practices-for-auto-upgrades-of-flake-enabled-nixos-systems/31255

    • @cleteblackwell1706
      @cleteblackwell1706 Před 3 měsíci

      Thank you!

  • @rochecompaan
    @rochecompaan Před 9 dny

    Thanks for a great intro to flakes! I'm not following what you mean with "if you named your dev shell bob ... you will have to use bob as key when running nix develop". What is a dev shell and how do you name it?

  • @schendelenterprises2955
    @schendelenterprises2955 Před 9 měsíci +3

    I want a cookie too ;-)

  • @alexandersafiullin9820
    @alexandersafiullin9820 Před 7 měsíci +1

    02:57 We can see that no nixpkgs input specified for the flake. But it somehow got used later in the outputs. Also flake.lock got those nixpkgs pinned to some revision. Tell me, guru, what revision is gonna be used in this case?

    • @vimjoyer
      @vimjoyer  Před 7 měsíci +1

      If inputs field is not specified, nix just assumes you want a single nixpkgs input. IIRC it uses "github:nixos/nixpkgs/nixpkgs-unstable" by default.

  • @RainyNacht
    @RainyNacht Před 10 měsíci +1

    Very good video! What fonts you use at 0:40 and 1:25 to show the command?

  • @diagram_sock
    @diagram_sock Před 10 měsíci +1

    I'm about to hop on Nix

  • @user-yz1kx8zp2r
    @user-yz1kx8zp2r Před 6 měsíci +1

    🎉

  • @luigitech3169
    @luigitech3169 Před 10 měsíci +1

    Thanks for the video, what i don't understand is (coming from Docker) where to store or mount persistent data. I'd like to mount an "host" directory where to keep important data outside the flake, is possible to do it?
    I mean the equivalent of docker volumes

    • @vimjoyer
      @vimjoyer  Před 10 měsíci +1

      These development environments are not actually containers, they just modify some environment variables such as $PATH and $LD_LIBRARY_PATH to achieve what you see. They don't have their own storage, and you can access all your data. Flakes are just a way to declare those environments.
      That being said, you can build your docker images with nix: nixos.wiki/wiki/Docker
      You could use flakes to declare those as well.

    • @luigitech3169
      @luigitech3169 Před 10 měsíci

      @@vimjoyer thanks now i understand

  • @rijandhakal9228
    @rijandhakal9228 Před měsícem +1

    Could you do a video on making a proper FHS file-system inside of nix? Something that can help bridge the gap when the packages of another ecosystem are not fully supported on Nix, it seems like a FHS system is necessary.

    • @vimjoyer
      @vimjoyer  Před měsícem

      You can use buildFHSEnv (I'll make a video about it sooner or later)

  • @Eddio0141
    @Eddio0141 Před 10 měsíci +1

    funny i start looking into nixos and this video just got uploaded recently

  • @Sankaritarina89
    @Sankaritarina89 Před 7 měsíci +1

    why one repo per flake? can i not have one repo for all flakes or is that a bad thing? (i have not yet started using nixos, I will first watch all your videos :)

    • @vimjoyer
      @vimjoyer  Před 7 měsíci +2

      I mean one flake for one separate project, you probably don't want your python project update break your rust development environment. Having 1 flake for both home-manager and NixOS on the other hand is a good idea.

    • @Sankaritarina89
      @Sankaritarina89 Před 7 měsíci +1

      @@vimjoyerok I understand! that makes sense

  • @hobbyfor
    @hobbyfor Před 10 měsíci +1

    sorry, i didn't get know what the power in flake ,and i was try to put My H-M in it ,it is not working ,btw nice video

  • @fire17102
    @fire17102 Před 10 měsíci +1

    Thanks for the inspiration, just started on a new clean refurbished laptop and installed nixos on wsl. Trying to get ohmyzsh to work declaratively with plugins. Trying to get home manager to work... What a rabbit hole.. hope to make it to the other side with and get reproducible pretty zsh env.
    Anyone has a flake for that?? Thanks and all the best

    • @looptime9525
      @looptime9525 Před 10 měsíci

      Don't you call --zsh flag when running the command?

  • @user-qr3vm9up3e
    @user-qr3vm9up3e Před 29 dny

    Why is the volume so low?

  • @lor3keeper
    @lor3keeper Před 8 měsíci +1

    the video is pretty confusing and very hard to watch, this video is not zoomer friendly