Making the move to flake/home-manager

i run nixos on my laptop and desktop. on both they are part of a multi-distro setup.

as it stands, on both computers there are nix files that are on google drive that link to /etc/nixos

on the laptop:

$ ls -lah /etc/nixos/
total 8.0K
drwxr-xr-x 2 root root 4.0K Aug 30 13:08 .
drwxr-xr-x 44 root root 4.0K Sep 18 14:13 ..
lrwxrwxrwx 1 root root 41 Aug 30 13:03 appimage.nix → /mnt/data/GDrive/Linux/nixos/appimage.nix
lrwxrwxrwx 1 root root 46 Aug 30 13:06 configuration.nix → /mnt/data/GDrive/Linux/nixos/config-laptop.nix
lrwxrwxrwx 1 root root 40 Aug 30 13:04 flatpak.nix → /mnt/data/GDrive/Linux/nixos/flatpak.nix
lrwxrwxrwx 1 root root 48 Aug 30 13:08 hardware-configuration.nix → /mnt/data/GDrive/Linux/nixos/hardware-laptop.nix
lrwxrwxrwx 1 root root 41 Aug 30 13:03 packages.nix → /mnt/data/GDrive/Linux/nixos/packages.nix
lrwxrwxrwx 1 root root 39 Aug 30 13:03 python.nix → /mnt/data/GDrive/Linux/nixos/python.nix
lrwxrwxrwx 1 root root 41 Aug 30 13:03 security.nix → /mnt/data/GDrive/Linux/nixos/security.nix

the desktop has configuration.nix and hardware.configuration.nix as seperate files. but it will point to security.nix for instance.

this works because /mnt/data/GDrive/Linux/nixos is already on both because of the other distros. there is also another mountpoint in /mnt/btrfs/ that setups the flatpak environment.

i understand this info may be light but i want to see how a flake/home-manager journey can go from here

You should really (really really) look into git to save and version your nix configs and GitHub/gitlab/gitberg/sourcehut etc for remote storage. You can make the remote repo private if you want. File syncing with Google drive is definitely asking for trouble.

So create a repo (git init), create a flake inside (nix flake init if I remember well) and move all of your nix files inside the repo.

Organise the structure with directories for the hosts, the user(s), your shared modules and grow it from there. Plenty of examples out there, just search the above mentioned git sites for flake.nix.

Hope this helps.

thanks for the direction

i’ve actually run into a small git issue before so this direction will will help

You also don’t need flakes, there’s system.nix which works to pin your nixpkgs in your config, as well as expose multiple possible systems (if you have multiple computers involved):slight_smile: