this post was submitted on 10 Nov 2025
12 points (87.5% liked)

Nix / NixOS

2524 readers
3 users here now

Main links

Videos

founded 2 years ago
MODERATORS
 

Almost every NixOS tutorial I encounter, be that blog or video, says to use Flakes and Home Manager. While that definitely speaks to the value of these tools, I find myself, instinctually, wanting to avoid them. I’ve attempted to get them working multiple time, and encountered more issues than they solved, for me. I interpret this to mean my knowledge and/or use case of NixOS is not ready for me to use these tools effectively. On top of that, something about a set of files that could all be put into a single unified config appeals to me (which flakes/hm can probably do too, but hopefully to get my vibe).

My reasoning aside, this has made me curious if there is some way for me to “backport” all these configs I encounter into my set of more default style configs. The primary goal I have that lead me to this is rootless Podman and declaring my containers in the config. If anyone has any guidance or resources you could point me to it would be much appreciated.

top 17 comments
sorted by: hot top controversial new old
[–] rozodru@pie.andmc.ca 5 points 1 week ago (1 children)

when I first started using NixOS I was like you. I refused to use flakes and the home manager cause it just didn't make sense to me. Then I borked my system royally and had to reinstall. just going off the configuration.nix alone was...it was rough. possible but rough. So I decided to use flake, home manager, along with my configuration and then suddenly NixOS just clicked for me, I finally made sense.

using all 3 just makes your system easier to manage. For example say you use a WM and you want to keep your WM (like niri or hyprland or sway or i3 or whatever) config reproducible just like the rest of your system. Sure you can throw your entire config into the home manager OR you can simply have the home manager literally manage said config. Keep your config files in your "nixos-configs" directory along with your home, flake, and configuration.nix and repo all that, boom it's backed up and easy to reproduce if something goes wrong or you want to move your ENTIRE system to another computer. I do this for Niri, KDE, Yazi, Aerc, DOOM Emacs, Nvim, whatever I have a config for. So say I royally mess up a config for one of those programs or WMs just like my NixOS I can go back to a previous generation of one of them very easily thanks to my home manager.

Flakes are also good in case you want to use something that hasn't been packaged on NixOS. Say like some awesome TUI or application someone recently made you can input the git repo into your flake and then "install" it via your home manager. makes things easy.

It also helps to understand and manage if you sort what each thing does. For me I use my home.nix to list packages that I directly interact with. So stuff like Qutebrowser, floorp, steam, OBS, Krita, etc, etc are all in my home manager. stuff that's more backend/system dependent like git, libnotify, fzf, etc are in my configuration.nix i.e. the config of my OS while the home.nix is just like a package list and config files of things I'm more likely to interact with on a daily basis. It's easier to manage when things are separate like that.

I keep all of this stuff in its own directory that is a git repo. so before I rebuild I stage it all. then rebuild. if it's good commit it all, push it to my forgejo, boom instantly backed up. something goes wrong then I can either roll back a generation or clone the repo and rebuild from that.

[–] Arkhive@piefed.blahaj.zone 2 points 1 week ago

Lots of good suggestions from people, and replying individually was going to be a mess. Please see the comment I added.

[–] onlinepersona@programming.dev 5 points 1 week ago (1 children)

I'm not sure what you want to achieve... do you want NixOS running in podman containers as a service? Do you want to have some kind of package that starts up podman with nix packages in it?

Could you provide your usecase(s)? "As a X I want to Y". "As a X when I do Y I expect Z to happen".

It's just confusing to see flakes and home manager mentioned and some "backported" podman output to be desired. Individually those words make sense but together I'm lost.

[–] Oinks@lemmy.blahaj.zone 4 points 1 week ago* (last edited 1 week ago)

I think they might have read this thread, where the Discourse OP is using Home Manager to declare podman containers because the NixOS module just doesn't support doing that. And flakes ended up in the question because a lot of other examples online just assume the reader is using flakes.

I'm not a podman user so I'm not sure how much work it would be to not use Home Manager here, it feels like it shouldn't be much more annoying than what the discourse OP is already doing, but I haven't tried.

[–] Arkhive@piefed.blahaj.zone 4 points 1 week ago* (last edited 1 week ago) (1 children)

God, I wish I could just do like a live coding session with a group to explain what I know and like and how to translate that into flakes and hm. Lots of good info and suggestions from everyone, but I feel I could explain myself better with my system in front of me. I get the flakes concept of locking a program to a particular version. I like that idea, but I also think I’m still in a stage of building out my system, discovering which packages I want. And I understand home manager is for handling my home folder and config within nix.

I can’t place it, but for some reason I don’t mind my config files living in .config, and keeping my system (for now) up to date and running the latest version of most software. That being said I of course see the value in both of these in the long term, especially as I work to build out a config I can install on all my systems and automatically toggles the correct modules based on device and user. I want that, but my repeat failure to get the flakes I want working, working, tells me I need to learn more base nix before I tackle that.

In fact I could tell I learned a lot when I had to figure out how to remove flakes and hm when I kind of got them working. While I had moved my config into home manager, I also broke a bunch of other things, rendering enough of my desktop environment non-functional (audio mostly lol), that I needed to do something. The solution I knew I could pull off was completely rewriting my config as a sort of in between of my single file Hyprland based config, to a directory of files and niri. Learning to properly import other files, learning about needing to include default.nix and how I can toggle which files are imported very easily with comments. The broader nix ecosystem started to make more sense.

I finally got good about using git, I made a folder structure that makes a lot of sense to me as far as parts of my config that are interoperable or machine specific. It’s clicking. I know the next step from that is probably flakes and hm, but again, the last time I tried to add those to my config, I broke way more than I fixed.

I feel just dumb enough with this that I’m not sure I’m comfortable sharing my config publicly yet. For example I haven’t implemented a secrets setup, so things like my syncthing IDs are in my config still.

As far as clearer goals. I’d like a config I can distribute across 3 machines (for now).

  • A desktop running niri, and kind of for fun as much other rust based software as possible (iron bar, helix, etc.). I know there will have to be exceptions, but it’s been fun engaging with a lot of recent work using rust.
  • A home server/nas/router using Podman for containers like Tailscale/wireguard, Jellyfin, audiobookshelf and such. If this can also handle my pihole/local dns and firewall that would be awesome, but I also have a RespberryPi I can dedicate to those.
  • A living room PC that boots straight to steam big picture, and has all the emulator platforms I could ask for.

There’s many more thoughts prancing around in my head, but I don’t know how to prompt them.

[–] Oinks@lemmy.blahaj.zone 3 points 1 week ago* (last edited 1 week ago) (1 children)

I don't see anything in your goals that would really require flakes or home manager. Maybe the podman containers, there seem to be some sharp edges around NixOS support for podman from what I can tell.

You might not want to share your entire config but you could share snippets of what you're trying to do and isn't working.

Moving on to more concrete suggestions:

If you aren't already doing so, you should be using the option search liberally. And you should also read the code of the modules and packages, at least sometimes. Sorry, I know nixpkgs Nix can be quite obtuse, but honestly without it I don't think it's possible to really grok how NixOS works.

Secondly, a lot of people seem to think you need flakes to configure multiple systems in one repo, but you can actually also do that just fine with stable nix using the -I flag. It's even possible to build an arbitrary Nix expression using the (unfortunately undocumented) -f and -A flags like flakes would.

Edit: For secrets, I would recommend using agenix, mostly just because it uses SSH instead of GPG. Instead you can also put them in a separate Nix file and gitignore that, but your secrets will end up in /nix/store that way which is a vulnerability if they're important (also Flakes also break this completely).

[–] Arkhive@piefed.blahaj.zone 3 points 1 week ago* (last edited 1 week ago) (1 children)

I already use Unix pass as my password manager and have a private git server for it. Is there a nice way to get that working with secrets in my config? I know that directly goes against the suggestion of SSH vs GPG, but I’ve already got lots of data saved within that system.

[–] Oinks@lemmy.blahaj.zone 3 points 1 week ago* (last edited 1 week ago)

Unfortunately I don't think there's a nice way to do that. You can retrieve secrets from pass (albeit with quite a bit of working around the intended evaluation model) but I don't see a good way to actually deploy the secrets without just putting the plain text into the Nix store (unless you also use a big server management thing like NixOps, as the author of that blog is, but in the time since blog was written NixOps has decided people shouldn't be using it anymore... so it's a bit of a mess). You'd really want something like sops-nix or agenix for that.

You can of course decide you don't care about the secrets being in the Nix store. It "just" means that every local user on the system can read them, as can anyone booting a live USB if the disk isn't encrypted. And, while this almost certainly isn't relevant to you right now, if you use the system as a binary cache for other systems those can get the plaintext secrets too. But you might not actually actually care about any of these.

[–] mat@linux.community 3 points 1 week ago (2 children)

What makes a flake config a flake config is simply the flake.nix entry point. So, technically if you read that file to see what file it loads for the nixosConfiguration you want to "port", you should be able to just go directly from that file and bypass the flake.nix. For the longest time, my own flake simply forwarded to my configuration.nix.

However, depending on your needs of course, but using flakes even at a basic level can be very useful and I'd 100% encourage doing a basic setup for someone starting out. The main feature here is being able to lock your dependencies (including nixpkgs) to a specific commit, which means you will always get the same resulting setup (not depending on when you installed it, like it does without flakes). But, you know better than me the requirements of your own setup :)

[–] Arkhive@piefed.blahaj.zone 3 points 1 week ago

Lots of good suggestions from people, and replying individually was going to be a mess. Please see the comment I added.

[–] Oinks@lemmy.blahaj.zone 3 points 1 week ago* (last edited 1 week ago)

If you just want pinning you can also use npins, and it doesn't do any of the annoying other things Flakes do like copying the entire repository to the Nix store or failing to import unstaged or gitignored files.

[–] Paulemeister@feddit.org 3 points 1 week ago* (last edited 1 week ago) (1 children)

I would do them one after another as the two both solve different problems. If you want to use both, first start with using flakes.

Flakes are basically sets defining inputs and outputs. Then with a flake lock and exact version of the inputs can be pinned as to make it reproducible. Just add a basic flake.nix { inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; }; outputs = { self, nixpkgs }: { # replace 'joes-desktop' with your hostname here. nixosConfigurations.joes-desktop = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./configuration.nix ]; }; }; }

Also you should add nix.settings.experimental-features = ["nix-command" "flakes"]; to you configuration.nix

Make sure you track everything by git if your config lives in a git repo and you should be done. Of course you can have more inputs, propagate them to your modules and so on, but this should be fine for the start.

Now you have to add the' --flake' option to 'nixos-rebuild switch --flake' (please double check, as I use nh as a wrapper) and it will probably complain that you haven't enabled flakes and that they are experimental, but you can run the command again with an environment variable set and get around that. You could also have added the flakes feature in your configuration nix first, do a normal, non flake rebuild switch and then one with flakes, as then you are running on a system generation with enabled flake features.

Home manager, as the name implies tries to manage your home directory, so instead of adding packages and configs in your configuration.nix systemwide, you can add them only to your user directory. Basically you can add home manager and just not use it a t first and slowly migrate everything to it. You'll have to look up a tutorial for it. But basically everything you put in environment.systemPackages configuration.nix can go into home packages in your home manager config file. The module options are often similar, but some are just not possible to configure on a per user basis (like adding desktopManagers, though configuration them in the user directory is better done through Homemanager)

But that's what any tutorial would show you. I'm assuming as you already use NixOS you're somewhat technically inclined, so I'm not sure how to help you here. If you have any problems just comment here, I'll help you debug / convert your config with you

[–] Arkhive@piefed.blahaj.zone 2 points 1 week ago

Lots of good suggestions from people, and replying individually was going to be a mess. Please see the comment I added.

[–] Nibodhika@lemmy.world 2 points 1 week ago (1 children)

They have their reason for being, flakes help with reproducibility by pinning the versions, whereas home manager helps with running stuff as non-root and in non-NixOS systems.

Your flake.nix can just have a default output that points to your configuration.nix and you're done. That's how my flake started.

[–] Arkhive@piefed.blahaj.zone 1 points 1 week ago

Lots of good suggestions from people, and replying individually was going to be a mess. Please see the comment I added.

[–] Oinks@lemmy.blahaj.zone 1 points 1 week ago* (last edited 1 week ago) (1 children)

The NixOS community has a lot of cargo culting going on, probably because it's not super accessible. Using Flakes and Home Manager for absolutely everything is a part of that in my opinion. I ended up going back and forth on both of them, my current opinion is that Home Manager makes sense (if you have a use case for it) but Flakes don't.

If you really need to import a flake-only project from a non-Flake config you can use builtins.getFlake. Personally if a project makes this required by inlining everything in a flake.nix I would consider that a sign of shoddy programming and it makes me reconsider using it, but it is possible.

If you're talking about using snippets of what other people have in their configs, then most of them should work perfectly fine. You may have to replace an inputs.whatever.nixosModules.default with a fetchTarball or an equivalent reference to an npins file but that's a pretty minor change.

For Home Manager such a translation doesn't exist because Home Manager does a lot of different things, and even when HM reimplements something that's already in NixOS (like HM dconf vs NixOS services.dconf) it usually doesn't quite act the same way, if only because most programs treat package, system and user configuration differently.

[–] Arkhive@piefed.blahaj.zone 1 points 1 week ago

Lots of good suggestions from people, and replying individually was going to be a mess. Please see the comment I added.