Program a Modular Control Center for Your Config Using Special Args in NixOS Flakes

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ค. 2024
  • Join as a Channel Member:
    / @librephoenix
    Join Liberapay: liberapay.com/LibrePhoenix/do...
    Join Patreon: / librephoenix
    Hello everyone! It's been a while! I've been getting over being sick, but finally finished this one.
    This discussion is about how you can make a "control center" of sorts for your system using NixOS flakes and something called "specialArgs." Thanks for watching! Please subscribe for more NixOS/Linux/FOSS content!
    Associated Blog Post: librephoenix.com/2024-01-28-p...
    Previous Tutorial: • Custom Options and If-...
    Videos Referenced:
    Intro to Flakes: • You Should Use Flakes ...
    Intro to Home Manager: • Manage Your Dotfiles w...
    My configuration (if you're curious):
    GitHub: github.com/librephoenix/nixos...
    GitLab: gitlab.com/librephoenix/nixos...
    Codeberg: codeberg.org/librephoenix/nix...
    Wallpaper backgrounds were found on freepik.com.
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 40

  • @billwall267
    @billwall267 5 หลายเดือนก่อน +23

    Your NixOS series is the most accessible I've seen for people already familiar with Linux. Perfect pacing and level of detail. Each new lesson builds on concepts already covered. Thank you.

  • @svenum4742
    @svenum4742 5 หลายเดือนก่อน +27

    I even went one step further and moved all the variables from flake.nix to the folder ./hosts/HOSTNAME/settings.nix and imported them into this specialArgs with "settings = import ./hosts/HOSTNAME/settings.nix;". This means I can make settings per host and manage multiple hosts at the same time in one flake.

    • @Ben-zo3qb
      @Ben-zo3qb 5 หลายเดือนก่อน +3

      that sounds like a solution to a problem that I'm trying to solve... any chance you can share a link to your repo? I currently have ansible implementing this functionality because I couldn't figure it out in nix

    • @notcorrect
      @notcorrect 2 หลายเดือนก่อน +1

      I was thinking that but then I decided add my users as toggle-able modules instead.

  • @chewbakartik
    @chewbakartik 3 หลายเดือนก่อน +4

    This is an amazing video. Thanks for explaining it so clearly. I am very new in my nix journey, and have been trying to figure out how to pass variables/args around like this.

  • @droydi
    @droydi 4 หลายเดือนก่อน +9

    You have done a great job, you and @vimjoyer are the ones getting me through this steep learning curve. Long time Debian user who has fallen in love with Nix because of you two. Thank you.

    • @StillConfusing
      @StillConfusing 4 หลายเดือนก่อน +2

      i'm jumping in nix from arch this stuff is awesome, keeping my laptop and desktop at all similar has been the impossible task

    • @librephoenix
      @librephoenix  4 หลายเดือนก่อน +5

      I too used Arch btw, until I learned NixOS :)

  • @griffinb2008
    @griffinb2008 หลายเดือนก่อน +1

    Your videos are so helpful man. I'm learning Nix for stuff I'm doing at work and it can feel overwhelming at times. I like to watch your videos at night with a nice glass of bourbon. Currently enjoying a fine glass of Bardstown Origin Series Bottled in Bond as I watch this. Thanks so much for your work. Much appreciated.

  • @JuanEsquitin
    @JuanEsquitin 5 หลายเดือนก่อน +11

    To me you are the leader when it comes to NixOS. Ty! for your great content. I am learning a lot through your videos.

    • @librephoenix
      @librephoenix  5 หลายเดือนก่อน +1

      Thanks! I'm glad you've been finding the NixOS stuff useful :)

  • @roku1
    @roku1 5 หลายเดือนก่อน +2

    This is probably the best intro to Nix series I've seen. I especially love the fact that you explain everything in terms of the underlying nix language which unifies everything together. p.s. I was going to suggest moving all your variables to an attribute set called e.g. params. That way you only have to pass params as an argument, and not each of the individual variables which quickly becomes tedious. Then access variables with e.g. params.hostname instead of hostname. Can also combine with someone else's suggestion to move all variables to a file.

    • @roku1
      @roku1 5 หลายเดือนก่อน

      Ooops I see you've already done that since the video was recorded.

  • @jgoehr
    @jgoehr 5 หลายเดือนก่อน +1

    I really like your nixos videos. I think you are doing a great job. Keep up the great work!

  • @nekorug
    @nekorug 3 หลายเดือนก่อน +1

    i'll second some of the other comments here saying that this would probably be better served using the module system with your own options. you can even make a freeformtype option so you can set whatever variables you want in there if you don't care about type safety or any of the fancier things like type merging... i sometimes use a options.opts freeformtype that i can then just access using config.opts.whatever wherever i want in any nixos module.
    you can even go a step further and use flake-parts to use the module system for the entire flake and define them there, then pass them along to nixos' and home-manager's own module systems using specialArgs. personally i have flake-parts > nixos > h-m set up like this in a chain, each layer above it passing along the specialArgs from the system above it (though you need to prune lib, config, and options before passing on the attributes!). it's wild what you can get away with if you understand a little bit of how evalModules works lol

  • @Mseller1
    @Mseller1 หลายเดือนก่อน

    This was super helpful! Thanks for this!

  • @NicolasBPierron
    @NicolasBPierron 5 หลายเดือนก่อน +2

    For the first half of the video I was about to comment that you could introduce attribute sets to avoid the long list of `inherit`.
    But now, I will help you at being lazy and only suggest `with userSettings;` as a mean to avoid prefixing everything with the name of the attribute set.

  • @shifteleven
    @shifteleven 5 หลายเดือนก่อน +2

    That's a cool take. I was using module options to control many of those variables. But often I'm not really changing those values - so maybe this is cleaner in that then it's obvious when things are options, and what are global non-changing configs. thanks

  • @rishi2504
    @rishi2504 5 หลายเดือนก่อน +1

    Excellent stuff!
    Could you please cover your setup for this IDE/WM you are using to edit these files.

  • @jmoell1
    @jmoell1 4 หลายเดือนก่อน

    Tak!

  • @karthikeyanbalasubramanian7305
    @karthikeyanbalasubramanian7305 3 หลายเดือนก่อน +1

    need doomemacs installation video please

  • @phanirithvij
    @phanirithvij 5 หลายเดือนก่อน

    I'm gonna jump in into the world of nixos and hyperland. It's very tempting 😢

  • @hikingpete
    @hikingpete 4 หลายเดือนก่อน

    What I found effective is to mkOption for my various settings and attach them to the config attrSet.

  • @karthikeyanbalasubramanian7305
    @karthikeyanbalasubramanian7305 2 หลายเดือนก่อน

    What commands have you used after making these changes to take effect ?

  • @unLinuxeroMas
    @unLinuxeroMas 5 หลายเดือนก่อน

    tuto para hacer un blog como el tuyo is dope ? also great video

  • @zperk13
    @zperk13 หลายเดือนก่อน

    Is it possible to pass the variables to home manager if you're using home manager in the standalone way instead of the module way?

  • @Dark_Lobster
    @Dark_Lobster 5 หลายเดือนก่อน

    I see most configurations make several profiles in the config file, then the rebuild automatically build the correct configuration based on username and host. Whats the benefit of doing it manually this way?

  • @jonasbirner2231
    @jonasbirner2231 4 หลายเดือนก่อน

    When you were talking about using attribute sets instead of individual variables but then have to add userSettings in front of each other, couldnt you just use a with userSettings at the beginning of the file to solve that?

  • @marcuswest4572
    @marcuswest4572 3 หลายเดือนก่อน

    So is there a way you stick all your variables in a separate file and reference it?

  • @eobardthawnemcoc
    @eobardthawnemcoc 5 หลายเดือนก่อน

    Hey what font r u using

  • @me5ng3
    @me5ng3 5 หลายเดือนก่อน +1

    Where are the nixos flakes tutorials linked?

    • @Redyf
      @Redyf 5 หลายเดือนก่อน

      Check his channel

  • @amansetia8655
    @amansetia8655 4 หลายเดือนก่อน +1

    why not make your own options? You can add type safety, descriptions, default values and more

  • @alaaelsamouly8944
    @alaaelsamouly8944 5 หลายเดือนก่อน

    i want to install your hyprland config

  • @abbcc555
    @abbcc555 3 หลายเดือนก่อน

    why do you reference the username sometimes just like that and sometimes {username}

    • @davids1378
      @davids1378 2 หลายเดือนก่อน +1

      If username is a variable of type string, then ${username} evaluates to its value (e.g. "emmet") instead of the literal "username".

  • @FranciscoMarcosMilhomemAbreu
    @FranciscoMarcosMilhomemAbreu 5 หลายเดือนก่อน

    Third!

  • @everywan
    @everywan 5 หลายเดือนก่อน

    Sixth!