Closed andar1an closed 9 months ago
Hi, thanks for dropping by!
I understand my config might be difficult to understand at first.
First, regarding nixosConfig
, this is a special argument that is passed automatically to all home manager modules if you use it as a nixos module (and not standalone). When you are writing a home-manager module, you have access to the config
object that holds all home-manager specific configuration, and if you use home-manager as a nixos module, you also have nixosConfig
, which holds the system-wide configuration. This way you can configure your home-manager modules based on the system configuration.
Second, regarding the symlink, no. Because my config is set up as a flake, I don't need to symlink it anywhere. The same applies to my home manager configuration.
Cool! Thanks so much. I currently use flakes and home-manager, but I didn't understand that nixosConfif was due to home-manager. Really cool! Thank you for explaining.
On Sun, Oct 29, 2023, 4:43 PM Andrés Cabero @.***> wrote:
Hi, thanks for dropping by!
I understand my config might be difficult to understand at first.
First, regarding nixosConfig, this is a special argument that is passed automatically to all home manager modules if you use it as a nixos module (and not standalone). When you are writing a home-manager module, you have access to the config object that holds all home-manager specific configuration, and if you use home-manager as a nixos module, you also have nixosConfig, which holds the system-wide configuration.
Second, regarding the symlink, no. Because my config is set up as a flake, I don't need to symlink it anywhere. The same applies to my home manager configuration.
— Reply to this email directly, view it on GitHub https://github.com/cbr9/dotfiles/issues/2#issuecomment-1784220010, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAZJBRGRBPMPDIK2V6ORO3YB2WX5AVCNFSM6AAAAAA6VCVXTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUGIZDAMBRGA . You are receiving this because you authored the thread.Message ID: @.***>
No problem! Because documentation is quite lacking in the Nix world, once you get comfortable with writing and reading Nix code, the best approach is to simply check the source code.
You can see the home-manager nixos module where nixosConfig
is defined here
Something to keep in mind is that you can always access the home-manager configuration from nixosConfig
. In the case of my user (cabero
) I can retrieve it from nixosConfig.home-manager.users.cabero
, which is equivalent to the simple config
object in a HM module
Feel free to ask any other questions. I'm happy to help
Thanks! I try to read the source, but I still have trouble reading the syntax. It is quite foreign to me as I have not worked with a language like this before, but it will come in time! Baby steps
On Sun, Oct 29, 2023, 4:49 PM Andrés Cabero @.***> wrote:
No problem. Because documentation is quite lacking in the Nix world, once you get comfortable with it the best approach is to simply check the source code.
You can see the home-manager nixos module where nixosConfig is defined here https://github.com/nix-community/home-manager/blob/master/nixos/default.nix
— Reply to this email directly, view it on GitHub https://github.com/cbr9/dotfiles/issues/2#issuecomment-1784221048, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAZJBXY6ADQGXOHNJQQMILYB2XK3AVCNFSM6AAAAAA6VCVXTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUGIZDCMBUHA . You are receiving this because you modified the open/close state.Message ID: @.***>
Thanks! I try to read the source, but I still have trouble reading the syntax. It is quite foreign to me as I have not worked with a language like this before, but it will come in time! Baby steps
On Sun, Oct 29, 2023, 4:49 PM Andrés Cabero @.***> wrote:
No problem. Because documentation is quite lacking in the Nix world, once you get comfortable with it the best approach is to simply check the source code.
You can see the home-manager nixos module where nixosConfig is defined here https://github.com/nix-community/home-manager/blob/master/nixos/default.nix
— Reply to this email directly, view it on GitHub https://github.com/cbr9/dotfiles/issues/2#issuecomment-1784221048, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAZJBXY6ADQGXOHNJQQMILYB2XK3AVCNFSM6AAAAAA6VCVXTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUGIZDCMBUHA . You are receiving this because you modified the open/close state.Message ID: @.***>
It is indeed hard in the beginning. Do let me know if you have any other problems either with Nix or questions about my config
Also, one thing I forgot to mention is that my base configuration.nix
is basically a function defined in lib
(mkHost
). You can combine things around in any way you want, basically :)
That is one of the things I thought was really cool when looking through your repo (also the star wars names ahah). I am starting with my laptop, but then I will try to include my server as well. In the future I want to research how this can work with baremetal orchestration.
What is the purpose of the pkgs directory? Is this for pkgs that you package yourself?
What is the purpose of the pkgs directory? Is this for pkgs that you package yourself?
Yup, that's right. I don't actually use sph2pipe but I kept it for reference. The filen-desktop package, I took from an unmerged nixpkgs PR.
Cool! And thank you for reopening this. I appreciate your willingness to answer questions.
If you are curious my first attempt at config is in the "archive" repo here: https://github.com/stephenandary/dotfiles.
Today I am starting to refactor it to try to make look like yours :tada:
This has been great for learning. Did you ever consider having a YouTube channel?! haha
I am currently too busy to start a YT channel, although a channel regularly making Nix/NixOS tutorials on YT might grow pretty quickly.
Kudos on your first attempt :)
I tried to make a PR on your repo but I ended up creating it on the fork I made of your dotfiles (probably because the names differ since I already have a dotfiles
repo, but it's still kinda funny lol). Anyways, you might want to check it out https://github.com/cbr9/dotfiles-stephen/pull/1
One of the problems I have found with getting into nix was the shear possibilities of doing things, I was glad to have stumbled on the 1password vscode issue, because I truly think your repo structure is an incredible model for understanding and good practice (I have limited experience with nix, but if I can get the gist while learning the details, I believe that is a sign of good practice haha)
Are the system packages defined in lib the same scope as those defined in modules/nixos? Or are they specific to root user? I feel like they are all environment.systemPackages but I am unsure due to the placement. (ergo why the need to define some packages in lib instead of all in modules/nixos dir)? I notice similar for user specific packages.
Are the system packages defined in lib the same scope as those defined in modules/nixos? Or are they specific to root user? I feel like they are all environment.systemPackages but I am unsure due to the placement. (ergo why the need to define some packages in lib instead of all in modules/nixos dir)? I notice similar for user specific packages.
They are the same. I guess I could move the environment packages defined in lib to modules/nixos/default.nix :)
In general there is a distinction between packages and modules. In general I wouldn't create a file just to add one package (but I would for a module), but they can go into modules/nixos/default.nix as I said
That is exactly what I have been thinking of how I want to do with mine. I am playing with keeping the packages defined in user in the same place as modules and leaving user directory for user definition configuration, and maybe just having an if statement to match a specific user. Watched some videos yesterday that helped me start to grasp the language, and things like default.nix, and flakes.
One thing I noticed is that you have hardware configuration in both nixos and hosts, and I think you did that to make it easier to enable common hardware settings for various hosts which I think is cool.
I also currently need to dive into disks, because I saw someone state in the Nix Discord server that one should make sure to explicitly configure disks and partition in config. I am not sure why yet, but I'll get there eventually.
I also wonder if when running the flake, it outputs configuration into /etc/nixos. I'll be able to see when I get something working.
This seemed like a good blurb for pkgs vs modules:
TLDR:
Use a NixOS module when you want to specify the configuration of a piece of software declaratively and immutable,
and if you want to conveniently store the configuration in Git.
Don't use a NixOS module if you want to modify the configuration on-the-fly in a imperative or mutable manner,
and are willing to set up special cases for backing up the configuration in Git.
* Technically this isn't true with environment.systemPackages and home.packages, since they pick up on package systemd services / MacOS .app directories / etc., but it's still true for nix-shell and similar.
One thing I noticed is that you have hardware configuration in both nixos and hosts, and I think you did that to make it easier to enable common hardware settings for various hosts which I think is cool.
Technically, in modules/nixos I have hardware modules to more easily configure hardware options, but it's not really configuration. I took a lot of it from Wil Taylor's dotfiles. I recommend checking his dotfiles too. I took inspiration from them.
You could in theory have one file having the hardware config and the other config parts all combined. There's no need to maintain separation.
I also currently need to dive into disks, because I saw someone state in the Nix Discord server that one should make sure to explicitly configure disks and partition in config. I am not sure why yet, but I'll get there eventually.
You can do disks imperatively without any issues, no need for declarative configuration there. If you do it declaratively, that means that you only really need to run one command to install everything, which is nice. I used disko (a tool for declarative partitioning) for a while but I found it a bit difficult to use at first and I'm currently having some doubts about whether I should use it or how to adapt it, because my laptop now has a dual NixOS-Windows boot.
I also wonder if when running the flake, it outputs configuration into /etc/nixos. I'll be able to see when I get something working.
No, it won't create anything there. If it did, it would need to collapse your entire config into one file, since there is no clearly defined main file. It would also defeat the point of modularizing the config.
I guess you could also symlink your dotfiles into /etc/nixos, though.
I love Wil Taylor's stuff haha! I have his YouTube channel linked in my docs! Thanks for linking that.
My current laptop is just Nix, but my Server is currently dualboot Windows and Ubuntu, was thinking about transitioning to NixOS on a dedicated m2, but I was able to finally grab a CM4 today, so I can test nixos on that with disko, thank you for that recommend.
I have mostly seen people sym-link files into their for git, which is why I am still slightly confused by the flake approach you have. But I like this approach more because it feels cleaner and less to worry about.
I have mostly seen people sym-link files into their for git, which is why I am still slightly confused by the flake approach you have. But I like this approach more because it feels cleaner and less to worry about.
Once your config grows in size it's impossible to manage it if it's just one or two files. I manage virtually everything using Nix, down to my Firefox bookmarks haha (which are much more organized now, btw). And what I can't manage with Nix because there are no modules for it, I sometimes try to figure out how to create it
I get annoyed now when it's not possible to configure things declaratively 😂
I want to be able to define everything declaratively too haha.
Will be interesting to see how luks works with driveo.
I also can't wait to learn about packaging, in case I also need to do that. Would be convenient for Dioxus. I saw someone created a package long ago, I wonder how one can update.
Howdie Andres! Did you ever think of using sops-nix? What made you choose git-crypt?
Howdie Andres! Did you ever think of using sops-nix? What made you choose git-crypt?
Hey, sorry for the late reply.
I'm currently using agenix, which is kind of similar. I used git crypt before to encrypt some nix files so I could back them up on GitHub. As far as I know it's not possible to use sops/agenix to encrypt source files, so they serve different purposes
Cool! I will have to check that out today, thanks!
Howdie @cbr9. Do you enjoy managing all of your firefox config though home-manager? Or do you find it tedious? Mainly I am thinking to do just profiles there and sync the rest through Mozilla, but if not too tedious I may consider doing through config.
Hey, so far I enjoy it. It is much more organized than when I used to use a Mozilla account. This is especially true of my bookmarks. It is more convenient to add a keyword to each bookmark this way. For example, if I want to go on YouTube, I type yt
. I can do that natively in Firefox itself, but doing it through home manager is more inviting.
Very cool. I ran into an issue today where I couldn't use my second profile without firefox crashing, so I had to put a pin in until I figure that out. But hopefully I can try more firefox config soon. I tend to have a tonne of bookmarks though, so that can be problematic. Would be cool to export current settings to home-manager config haha.
I also used to have a ton of bookmarks. But now, since I manage it through Nix, I am more mindful of what I bookmark (before, 95% of my bookmarks were sites I visited once and found interesting but never ever actually went back to).
And, I am also more mindful of how I organize them
That is currently my problem haha. That's one of the reasons I want to try to do this through config. I plan to move any random links to knowledge base instead. Right now just trying to figure out how to do that for repos I starred in github, but there isn't really an easy way to export.
You could use a crawler :)
Ya, I'm just trying to find a lazy way haha. If interested I think I finally settled on a repo structure here. If I need file specific config I may just make an extra directory for program specific config files. But I am likimg this layout so far. If you look let me know what you think plz! Haha
I don't have enough context to give you an opinion, but if it works for you, then great! I haven't touched my dotfiles too much lately, since I'm pretty happy with them. Mostly I just add bookmarks or extensions or I update the lock file. My point is that if something needs to be changed you will realize eventually
Oh ya, im not concerned. I was just happy with the level of visibility in the format because my main goal is to build images/machine config for baremetal hosts. I think I accomplished simplicoty and clarity with this format for those purposes. But will need to see as I build more configs.
Hi Andres! Happy new year!
I was wondering if your firefox config actually applied bookmarks and enables extensions?
My second profile crashes firefox, my extensions get added but are disabled, and my bookmarks don't get added haha.
Still clueless why, so just curious if you experienced similar issues.
Hi Stephen, happy new year! 🎊
Regarding Firefox, yes I've had issues like that. In my experience you should rebuild your system with Firefox closed (if the rebuild changes something about Firefox). That way extensions and bookmarks are added, although you still have to manually enable extensions once they are added
Interesting, I did that. I also disabled and re-enabled firefox and removed the .mozilla directory. I am not sure what else to try. I am considering making an issue because even if I remove everything except multiple profiles, that will cause moz to crash for secondary profile.
I only use one profile, so that might be why it works for me. Did you find a solution?
No, my investigation of NixOS ended. I am on Debian now. There was a lot I liked about Nix (community, learning, etc), but the time input for benefit wasn't there for me. I have just created my own scripts on Deb now. But I think the issue may have been related to installed firefox fields in config that may have been missing, or folders maybe not being populated or existing based on my experience scripting for deb where I bumped into similar.
Sad :(
I'll close the issue then
I still like to follow nix, and thank you for the chats. Mostly watching a few chats in Matrix now. Cool thing is some tools cross over like direnv.
First, I love how you have structured your dotfiles. I want to try to do something similar, but I am a little confused about the nixosConfig argument:
I can't find if this needs to be defined somewhere to pass in. The closest thing I have found so far is this, but I am still new to nixos and quite confused by arguments at the moment.
Also, do you symlink this directory from somewhere in /home to /etc/nixos?
Thank you for the help if you have time!