NixOS Introduction - Home manager

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome to my channel my name is Lee in today's video I would like to continue talking about NYX OS and today's topic is how to use home manager let's go started first of all let me open my terminal and then I will open my browser go to my blog this page before we start I wanted to talk about why we want to use home manager in my previous video when I was trying to install micro Editor to my system I need to put micro under environmental system package in this configuration.nix files and then I will review the system then I will have access to micro editor right but that is only about installing the software so if I need to change my application settings I still need to configure that myself by using home manager I can use NYX to manage all the application configurations for me so after the rebuild I'm not only getting a micro editor but also all the configurations I need like the cover theme different tab size that will all be configured by NYX for me so it's very convenient I will show in the example later on next OS you have two methods for installing home manager the first one is called install as Nix modular which means you will just put the home manager inside your configuration and you will manage all the installation by only one command which is NYX OS review switch and the other way of using a home manager is by installing it as a standalone mode so essentially after installation home manager will be a separate package and then you will have access to home manager CRI to manage all the configurations for that so you will use NYX OS review for building the configuration of your system and then use home manager switch to build the home manager configurations I would like to show you how to install home manager as the next module first so let's go back to my terminal I will copy this command first so all the command or configurations I put on this blog post uh I'm very similar to Future documentations because I believe that will be easier for you to reference in the future so the first step is to add the home manager channels to the system okay that's done and then I will need to add the home manager to our configuration file essentially I need to do three things first I need to add this under Imports then I need to set the user user username is normal user to true this should be set as true by default then I will need to add a home manager sections so let's go to micro EDC NYX OS configuration right so the first thing copy here put it down here go to user user which is here as you can see is normal use as true by default then I need to have this home manager section I'll put it here so this is quite simple and I need to change the name to my username now let's just do review before we start I would like to talk a little bit about this file first so what this means is home manager will be used for this user and then I'm going to install the package A2 and HTTP Pi then the state version is 22.11 which is the same as my OS so let's just do a rebuild all right so once that's done we can have a look if HTTP pi is installed it is installed and we can see it is installed under the user dot next profile in the pin folder right so that means home manager is working but we probably want to separate our home manager configurations outside of our system configuration right so to do that it's quite simple so what we need is to create a new file called home.nix inside the same folder so let me just copy that okay so I'm need an X and also I need to change the username to my username that's it and then let's go back to let me remove the incorrect file first and then let's edit the configuration file so what we need here is to remove the whole manager section from the previous day into this one so let me just copy this paste it here and all right so let's compare it let's see what we what we are doing here basically I'm adding two um configs here one is to use Global packages and the other one is to use user packages and also if you see here home manager user my username so basically adding this part on the dot home.nix file right so that we can delete this one now so if you see that I previously have these two packages installed so if I remove that these two ones will not be available later on so if we do a rebuild we can see http is not available right hd5 is more available to add it back it's quite simple we can copy this one go to our home.nix file put it here of course I don't want a tool and then do the review again let's try again we can see we've got it again you can see this is a different folder so that is the um uh use uh you user packages through settings to do that okay okay so this is how you can install home manager as the next module and then to use that right so next I'm going to show you how to install home manager SDS Standalone application so we are going to remove the home.nix file first right and then we are going to remove whatever we have on the configuration file so this one first and then this section right so home manager is gone let's review alright so we can see HTTP is gone again let's follow our blog post install it so the first step is also to add the channel which we already did so we just need one simple command all right that's done so let's have a look so now we've got this um home manager CRI that means we are good to go home manager is installed as the application Standalone application on the system okay so the next part I would like to show you how you can use home manager if you use home manager as the modular we already know that the configuration will be under Etc next OS folder right when you install it as the Standalone mode the configurations will be under your home folder dot config and then next packages so the home.nix will be inside this folder and if you need to make the changes previously I will just do next OS review because it's part of Nick OS right and if it's in the Standalone mode you use home manager switch to install or make a changes of your configuration let's use this one as an example to show you how you can install the next packages so now I can go to config NYX packages home.x you can see it's got a lot of stuff already for us so we just put this here for installing H top right and then we can do home manager switch I want to show you a h top is not available right now so we just do home manager switch and then we have H top right very simple and if we want to install the sh we can also do that by putting this on our home.nix try that right so put here delete let's have a look what it does for us so this will install zsh and enable auto completion Auto suggestion syntax highlighting installing all my that sh for me and then enabling Docker compose and Docker plugin use the DSD theme and then bind Ctrl f as the auto suggest accept and I'm also installing after F and integrate that with the sh right it's quite straightforward and you can see this is part of the configurations of that sh let's do the rebuild sorry let's do a home manager switch all right it's done so if we do the sh we can see we've got the sh and this is apparently um doing what we want the dstfame so we can have a look the this file and we can see the theme is DST right and we can we also has FCF integration with the sh but if we log out and login back as you can see here that sh is not the default shell when we log into this server how do we make that sh as the default shout we can find the answer on the OS wiki page here I'm just copying here so basically we need to add these two lines to our configuration system configuration okay so let's just do that all right so one part is to add user user username shell so just need this part and the next is the environment shell with pkg.sh so that's once that's done let's review Nick OS because this is our system configurations we will need to use this one for the review okay once that's done we connect again now we are using the shr default shell so the next thing I want to show you is how you can break the home manager configurations to different files as you can imagine right as your application goes up you probably need to manage a lot of lines of code if you only use the home.nix file to have everything on there so in this particular example I would like to break the the sh related configurations to one single file called thesh.nix and then import it back to our home.nix so the first thing I would I will do is to make a folder under the next packages called apps then I will create a file call zsh.nix and put this back once that's done we can delete this part of the configuration from the home.nics right let's delete that and we need to import this um that has H NYX file back to the home folder so let's just copy paste so this means the folder will be in the same folder as our home.nix and then the file we want to import is called the sh.nics saved it to home manager switch and nothing should happen right because I'm literally just moving the configuration out from the home.nix to a different location so I will also change the micro editor as I said from the system configuration and I want to manage that with home manager so let's just copy the configurations I will create a another file which is called micro.nix so we can see this one means I'm enabling the micro editor I put some settings different color themes I want to have a tab size S2 and Etc Center let's save this uh the next I will just put this back to this line and pull it home sorry micro.nix right and the last thing we need to do is to remove micro editor from the system packages right so let's just do that right so um it's here commented how save do a NYX OS review okay so it doesn't have memory for that that's okay this will make sure the micro editor is removed from the system right now we can do home manager's reach okay we are going getting the warnings that means because I previously installed the micro editor already uh you know home manager want to make sure I don't need the settings there so which I don't let me just remove that Microsoft all right so now we view again very cool so you can see micro is available now and also the color theme you know the tab size is two now which is exactly what the settings I gave them if we take a look at the um config file this is exactly what I set on the next sorry micro.nix file right okay so that's all I want to show you today uh I will plan to do another video for using flakes so if you like these videos please subscribe to the channel and if you have any questions please leave your comments down below and I will try my best to get back to you thank you for watching and see you next time goodbye
Info
Channel: Li Yang
Views: 1,905
Rating: undefined out of 5
Keywords: nix, nixos, linux
Id: C5eAecVeO_c
Channel Id: undefined
Length: 16min 14sec (974 seconds)
Published: Mon Apr 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.