I recently added unstable version to my configurations and after that i was facing the same issue in the configuration file.
Now im trying to add git config in a declarative way. and now im facing the same issue
❯ home-manager switch --flake .#system
Home Manager not found at /nix/store/9613fxrf433y10fz18ccixj4zpmdibzq-source.
error: flake 'path:/home/mainuser/.dotfiles' does not provide attribute 'packages.x86_64-linux.homeConfigurations."system".activationPackage', 'legacyPackages.x86_64-linux.homeConfigurations."system".activationPackage' or 'homeConfigurations."system".activationPackage'
Sorry for not being clear. I am using home-manager with NixOS.
Correct me if im wrong please. My understanding was,
when we make system level changes (config.nix), command to accept the changes should be sudo nixos-rebuild switch --flake . (in my case its sudo nixos-rebuild switch --flake .#system, which i recently understood this too)
And when we make changes on user level (home.nix), then command to accept these changes should be home-manager switch --flake . or home-manager switch --flake .
Stand-alone → for one machine, where its dedicated to a single user.
Module/plugin → is for multi user, one a same machine
home-manager → manages the dotfiles for user through home.nix.
And when Flakes is involved → it takes control over both system config (configuration.nix) and user config (home.nix).
And I have messed up my setup by Some how without much knowledge by initially having a stand-alone setup and later i ended up using the plugin way. And now to get back to stand-alone way i need to remove the nixosConfigurations from my flakes.nix and retain the rest like below ? is that what you mean to say ?
Standalone means that it’s not done as part of the NixOS-system but separately, usually managed through the home-manager command. You can modify the home-manager config of a user without rebuilding your whole system. This is also what you use when you want to use home-manager for users on systems that are not NixOS itself.
Module/Plugin means that home-manager is built and deployed as part of the NixOS-system itself. So you are NOT using the home-manager command but home-manager is built and deployed as part of the usual nixos-rebuild build/switch process. So to change the home-manager config of a user will require you to do a full system update with creating a new generation.
Generally, using standalone gives you more freedoms. You can update and rollback the system and user configs individually. However, if you just want to update everything, standalone is a longer process since you need to update the system and your users home configs individually.
On my personal NixOS systems I prefer the Module mode. Once everything is set up the way I like it, I rarely feel the need to update my home-manager config. And with proper modularization it is easy to use the same home-manager config in Module and Standalone mode, e.g., when I want to deploy my home-config to a Non-NixOS system.
Thats way more clear now.Thanks a lot for taking your time to explain me the core of it.
So home-manager, manages or in a way manages all our dotfiles. and it creates/generates symlinks of our dotfiles and keeps them in the nix-store.
using home-manager we can define our system either as a Stand-alone or as a Modular.
If its stand-alone, it manages the dotfiles of the user, and the user level configs have a freedom, and will be controlled through home-manager <switch/rebuild> commands.
If its Modular, still the same, user level configs will be controlled by home-manager, but through the usual nixos-rebuild <switch/rebuild> command. (we as a user would not or wont have the need to use home-manager commands).
Home Manager not found at /nix/store/9613fxrf433y10fz18ccixj4zpmdibzq-source.
error: flake 'path:/home/mainuser/.dotfiles' does not provide attribute 'packages.x86_64-linux.homeConfigurations."system".activationPackage', 'legacyPackages.x86_64-linux.homeConfigurations."system".activationPackage' or 'homeConfigurations."system".activationPackage'
So the above error that im getting, is may or may not be due to this fact(me having configured my home-manager as module and still using the home-manager cmds,) right ?!
Yes, understood.
understood. But can i know what is that “rarely” scenario.
So if i would like to do the same, and to concise the whole discussion, i dont need to make changes to my flake.nix or home/configuration.nix either right. Just changing the home-manager the branch in the flake.nix and going further just nixos-rebuild will be my work/command flow that i need ti follow. correct ?!
I discover a new command line tool and want it absolutely everywhere now (e.g. ripgrep)
Change my zsh config to powerlevel10k
Synchronize a wine-environment so that yabridge-powered virtual instruments are available on all machines that I use to make music (home-manager config needed just for yabridge.toml distribution)
I don’t know, I’m not much of a ricer once things work to a satisfactory level.
Do you have your current configuration somewhere as a git repo? Generally, if you want to go modular, you do three things:
Add the home-manager module to your NixOS config, e.g. (assuming you named the flake-input home-manager),
Note that in ./users/user1.nix you are now in the context of home-manager modules, not NixOS-modules anymore. So the stuff you find on search.nixos.org under the modules search is not going to work there. Instead, you can use stuff from Appendix A. Home Manager Configuration Options now.
You can check out my config, but it’s gotten a bit convoluted over time and is probably more compartmentalized than you will need for a single system. I define a nixosSystem' function here that has all the settings that all my systems shall have in common, and there’s some home-manager stuff in there. A system with two users is then defined here.
This is what i was trying to setup (add my git username declaratively), so was trying to add them under my home.nix. After adding the programs.git to the home.nix i gave the wrong command as home-manager rebuild instead of nixos-rebuild. then this OP.
so to answer you question, No. its not in git and im kind of stuck way before pushing them, So sorry for the inconvenience. I looked at the example what you have given and im unable to correlate with my existing .nix files. So im adding them here for a ref, (as of now this is the current state all the .nix files and i would like to go modular like they way you do)
flake.nix
im extremely sorry if im asking for more. Im still a beginner and unable to understand atleast bare minimal things from your .nix. to me it looks way too complex.
thank you verrrrrry much @polygon. I tested the change by adding some random packages into home and removing them. It worked.
So let me concise my workflow/command flow going further, correct me if im wrong.
Going further (after adding hom-manager.nixosModules. to the nixosConfigurations)
im officially using the module way of using the home-manager.
nixos-rebuild will be taking care of the home-manager changes (dont need to use home-manager cmds until and unless some rarely situations - which i might face in future to figure it out)
right ?
Its really hard to understand from any repo’s .nix files as a beginner. And the documentation make me forget everything. And comparing multiple persons .nix files makes the understanding way worse. Im glad to receive your .nix’s. Will clone yours locally and inspect the way you have built it from the beginning. may be by that way i might get better understanding. Please do share you thoughts if there is a better way to understand the structuring or configuring our own .nix’s.
Glad I could help. Yes, the way I showed is using home-manager as a module, so you will use nixos-rebuild for everything. You also don’t need the whole homeConfigurations-block that you have. However, you can still keep it around in case you want to deploy just home-manager to, e.g., a Non-NixOS machine. You basically did it correctly there already, put all the actual config in a home.nix, nicely divided from the nixosSystem respectively homeManagerConfiguration so you can potentially use both.
If you want to look at my config, there should be a state after I transitioned to Flakes where it’s just a single system and might be a somewhat good blueprint. If you look at any of the later versions where I added my home-server, I just want to add that I started my Flake using the flake-utils-plus library. However, I transitioned away from it to bare flakes (basically what you have now) once I hit a few limitations that I could not overcome. I never bothered to fully remove it from my config, though. So if some parts in the top-level flake.nix don’t make immediate sense, it’s not because of some cleverness from my side, but because I’m too lazy to clean up.
understood.
I was feeling down for not getting a clear picture of the workflow but everyone writing their nix files like a .
thanks a lot for your help, heads-up and advice