Nix derivations explained | Unleash the full potential of NixOS

Поделиться
HTML-код
  • Опубликовано: 10 янв 2025

Комментарии • 59

  • @unknown-otter
    @unknown-otter Год назад +29

    Another comment just for the yt algorithm! Thank you for your work!

    • @vimjoyer
      @vimjoyer  Год назад +3

      Thanks!

    • @unknown-otter
      @unknown-otter Год назад +3

      Pardon me, I'm just curious, are you from CIS countries? Your accent sounds familiar to me (well, I'm from Russia)

    • @vimjoyer
      @vimjoyer  Год назад +7

      @@unknown-otter I'm from Ukraine

  • @yash1152
    @yash1152 4 месяца назад +8

    0:39 - 1:23 holly molly, just like that he covered ALLL THE THREE/FOUR syntax in a smooth seamless story manner. thanks a lotttt for this.
    1. minimal/direct nix expression
    2. nix function expression
    3. importing [2.] in flake
    4. embedding this inside a standalone flake

  • @Gaivs
    @Gaivs Год назад +10

    I'm so glad I found this channel, great explanations for something I know I've wanted to learn for a long time!

    • @_modiX
      @_modiX Год назад

      I'm so happy for that as well. The documentation is vast, but shallow, with many sources to learn from. It's nice to have someone condense all the necessary information to get learn how to do specific things with very easy examples.

  • @hotdog2c
    @hotdog2c Год назад +7

    Awesome explanation! loving the nix videos!

  • @lamprospitsillou6325
    @lamprospitsillou6325 Год назад +4

    I am running Nixos-install as we speak, keep up the amazing work , thank you!

  • @BartekBroniszewski
    @BartekBroniszewski Год назад +4

    Awesome as always! It is like Nix inception, you wrap your binary in a wrapper of a wrapper...yes and then we have cowsay. I totally got it.

  • @wojciech-kulik
    @wojciech-kulik 3 месяца назад +1

    I think you provide the most valuable and smooth content about Nix! Your videos helped me a lot!

  • @ardwetha
    @ardwetha 3 месяца назад +1

    This is just amazing. It makes building simpler.

  • @AppsTricksByNazakatUmrani
    @AppsTricksByNazakatUmrani 7 месяцев назад +2

    ManI love what you are doing for the community, no one can thank you enough for your work, I don't know what to say

  • @mr.tm-yt
    @mr.tm-yt Год назад +5

    Great video as always

  • @dillon4248
    @dillon4248 Год назад +6

    Awesome! Still working on getting use to nix to switch to it as my daily driver. Really interested in seeing more on how to build projects and push to the nix package manager for my own projects and projects I find that are not in the nix package manager yet

  • @infernocop31
    @infernocop31 Год назад +3

    You are incredible. Keep it up

  • @yash1152
    @yash1152 4 месяца назад

    2:47 > _"to be explicit, we could also like $src/hw"_
    3:10 > _"if u dont specify a build phase, nix will attempt to use a Makefile from src dir"_
    4:26 > _"we can define our own list [phases] containing phase names, for easy learning derovations"_
    ohw, niice. yeah, it makes much more sense in explicit manner while getting started.

    • @yash1152
      @yash1152 4 месяца назад

      3:10 _"if u dont specify a build phase, nix will attempt to use a Makefile from src dir"_
      awesommme. super helpful for those of us beginners who like to use makefiles for easy understanding/overview & also compatibility with IDEs & editors etc.

  • @DooMWhite
    @DooMWhite 6 месяцев назад +1

    Amazing content, just what I wanted to understand.

    • @DooMWhite
      @DooMWhite 6 месяцев назад

      Just a thing, I tried using cp $src/hello-world, but that didn't work, cuz cp needed "" in the source part, how do I fix that? I tried using "$src/hello-world" and "${src}/hello-world", but that wouldn't work.

  • @yash1152
    @yash1152 4 месяца назад

    0:49 hi! what does those curly braces {} between import and semicolon ; convey?
    i had to put "pkgs" at this place while importing my nix-file containing packages array. i.e.
    "let mp = import ./my-pkgs.nix pkgs; in ..."
    but i dont understand what part of syntax this is. or say, what the "pkgs" or curly braces is doing here.

  • @MiaLovesRod
    @MiaLovesRod Год назад +2

    LETS GOOO

  • @yash1152
    @yash1152 4 месяца назад

    1:44 _"there are also buncha optional keys"_
    1:58 it would be awesome if u showed the documentation before showing the demonstration.
    the experience with documentation for nix-pkgs (super frustrating) is exact opposite of xp with nixos-config (very good and smooth).
    so, showing the documentation/reference and _how_ to follow or _to which part_ of documentation's structure to pay attention to, would help new users a lotttt.

    • @yash1152
      @yash1152 4 месяца назад

      before or alongside showing the demonstration

  • @yash1152
    @yash1152 4 месяца назад

    3:37 hi again. when to use the devShells.${system}.default vs packages.${system}.default?
    i mean, the devShell _has_ to be defined
    * for tools like debugger, linter, lang-servers, etc...
    * regardless of whether the package is built with manual make runs, or via nix build.
    so, what's the benefit of defining the "package" when doing iterative rapid development for learning the programming concepts (i.e. not in a hardcore project)?
    i have no problem defining even both, but i want to properly know the rationale behind.
    this may sound dumb, but i kinda can't see clearly.

    • @yash1152
      @yash1152 Месяц назад

      the package is used for nix run. it is like, well yeah, a "package" of the project - so all the info required for its building and distribution. like pyproject is for python projects.
      the devShell is just for setting up the CLI environment. it has no relation to how the project is build via nix.

  • @fulsomenko
    @fulsomenko Год назад +1

    great stuff

  • @johannesCmayer
    @johannesCmayer 9 месяцев назад +1

    You forgot to add this to the nix playlist iirc.

    • @vimjoyer
      @vimjoyer  9 месяцев назад +1

      Done, thanks

  • @sailendragautam3736
    @sailendragautam3736 4 месяца назад

    Is there a way to use sudo inside the nix-shell -pure ? Even after having the package sudo would throw some errors

  • @yash1152
    @yash1152 4 месяца назад

    4:09 > _"we could put it in buildInputs, but better is nativeBuildInputs; to make it available in phases, not in runtime"_
    umh, whatt? isnt the cowsay used in the program itself? so i'd think it would be required at runtime too no?
    i think it is smth like dynamic linking to a system path executable. but can u please expand on it?

    • @yash1152
      @yash1152 4 месяца назад

      3:56 ...

    • @sebischiefer6349
      @sebischiefer6349 11 дней назад

      As far as i understood it(and that is probably what @yash1152 is pointing at) buildInputs means "programs necessary during buildtime" and nativeBuildInputs" means "programs necessary during runtime". This becomes really valuable when you cross-compile, so compile on system a for usage on system b.
      Cowsay is used in the program, but it is not linked to the program, it gets called from a system-call. If cowsay were imported in the .cpp file it had to be linked

  • @MrPielover19
    @MrPielover19 Год назад +1

    hype

  • @MARKHENSTROM
    @MARKHENSTROM Год назад +1

    Is there an algorithm that will make the end-user not spend copious amounts of time clicking cat-related videos on RUclips - thereby ruining my productivity?

    • @vimjoyer
      @vimjoyer  Год назад +1

      If you find one, tell me).

  • @DooMWhite
    @DooMWhite 5 месяцев назад +1

    I tried splitting the default.nix to 3 files, one for each case, but for some reason, I get an error that those files don't exist, only default.nix works, do you know why?

    • @vimjoyer
      @vimjoyer  5 месяцев назад +1

      If you are using git, make sure to git add them. Flakes don't see unstaged files.

    • @DooMWhite
      @DooMWhite 5 месяцев назад

      @@vimjoyer That was the issue, ty!

  • @SantiagoFraire
    @SantiagoFraire Год назад +1

    How does nix know which commands to run from the Makefile?

    • @vimjoyer
      @vimjoyer  Год назад

      you can find all the logic here: github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/make-derivation.nix.

  • @evgen4681
    @evgen4681 Год назад +1

    Спасибо за такие классные видео! Можешь, пожалуйста, рассказать про создание единого окружения разработки (как я понял, для этого используют nix develop или nix shell). Мой самый главный вопрос в том, что там по умолчанию используется bash, но я хотел бы использовать свой конфиг zsh (это уже не nix way?).

    • @vimjoyer
      @vimjoyer  Год назад +2

      Да, я планирую сделать видео про Nix shell & Nix develop, а запускать их с zsh совсем несложно. Там можно указать shell-hook, который запустит нужную программу, включая любые оболочки.
      Так как по умолчанию все переменные из окружения пользователя сохряняются при входе в nix shell, .zshrc тоже будет там работать.

    • @dillon4248
      @dillon4248 Год назад +1

      Also interested in nix develop for my projects (:

  • @zperk13
    @zperk13 8 месяцев назад

    How does it know what g++ is? Why did you not have to define it in the buildInputs or i guess the nativeBuildInputs

    • @matthias2447
      @matthias2447 4 месяца назад +1

      mkDerivation wraps around the derivation function and provides common utilities such as g++. The build is executed in a sandboxed environment, where g++ is enclosed via mkDerivation.

    • @alexanderleschanz9991
      @alexanderleschanz9991 3 месяца назад

      my question too @Vimjoyer

  • @sharperguy
    @sharperguy 9 месяцев назад

    Why do you import default.nix rather than using callPackage?

    • @vimjoyer
      @vimjoyer  9 месяцев назад

      Yeah, callPackage is preferred.

  • @rotteegher39
    @rotteegher39 Год назад +2

    What about you rename your channel to nixjoyer instead of vimjoyer ? xD

    • @vimjoyer
      @vimjoyer  Год назад

      I'd have to change avatar too

    • @rotteegher39
      @rotteegher39 Год назад +1

      why not then @@vimjoyer

    • @vimjoyer
      @vimjoyer  Год назад +1

      @@rotteegher39 I don't care about the name much, but some people like this one, and I wont just be making nix videos here.

    • @rotteegher39
      @rotteegher39 Год назад +1

      respect +++ @@vimjoyer

  • @sachinchaudhary1310
    @sachinchaudhary1310 11 месяцев назад +2

    b;eh comment just for the algorithm baba bleh

  • @_modiX
    @_modiX Год назад +2

    I've seen some packages coming with a flake.nix in their repository. Could you please show in a video how to have a project with a flake.nix instead and how it is properly consumed on my own flake.nix? You are a good teacher btw. :)