···11# Dotfiles
2233-- `flake.nix`: flake inputs and the exported `macos` configuration.
44-- `macos.nix`: main macOS configuration, plus Homebrew settings.
33+- `flake.nix`: flake inputs plus exported `darwinConfigurations` and Linux `homeConfigurations`.
44+- `hosts.nix`: machine inventory keyed by the real hostname of each machine.
55+- `auto-upgrade.nix`: scheduled `darwin-rebuild` runs plus Nix garbage collection.
66+- `macos.nix`: macOS system settings managed by `nix-darwin`.
77+- `home.nix`: shared Home Manager configuration plus small platform-specific conditionals.
58- `packages/shared.nix`: packages you want available everywhere.
66-- `packages/macos.nix`: packages that only belong to this macOS setup.
77-- `justfile`: shortcuts for `darwin-rebuild`.
99+- `packages/macos.nix`: packages that only belong to the macOS setup.
1010+- `justfile`: shortcuts for `darwin-rebuild` and `home-manager`.
1111+1212+`nix-darwin` stays for macOS because this repo manages system-level things there, such as Homebrew and launchd automation. Linux stays on standalone Home Manager.
1313+1414+`hosts.nix` is the machine inventory for the whole flake. Each attribute name must match the real short hostname of that machine:
1515+1616+- macOS: `scutil --get LocalHostName`
1717+- Linux: `hostname -s`
1818+1919+Each host entry usually only needs:
2020+2121+- `system`: Nix platform string such as `aarch64-darwin`, `x86_64-linux`, or `aarch64-linux`.
2222+- `username`: local user that Home Manager should manage.
2323+2424+Optional overrides per host:
2525+2626+- `homeDirectory`: defaults to `/Users/<username>` on macOS and `/home/<username>` on Linux.
2727+- `flakeDirectory`: defaults to `<homeDirectory>/.dot`.
2828+2929+To add a new machine, copy an existing entry in `hosts.nix`, rename the key to the real hostname, set `system` and `username`, then add overrides only if that machine uses a non-standard home path or checkout location.
3030+3131+Useful commands:
3232+3333+- `just build`: detect the current machine and build its config.
3434+- `just switch`: detect the current machine and switch its config.
3535+- `just hm-build <target>`: build a specific Linux Home Manager target by hostname.
3636+- `just hm-switch <target>`: switch a specific Linux Home Manager target by hostname.
3737+3838+Automatic upgrade logs live at `/var/log/darwin-auto-upgrade.log`.
···11+{ lib, pkgs, inputs, ... }:
22+33+{
44+ home.packages =
55+ import ./packages/shared.nix {
66+ inherit pkgs inputs;
77+ }
88+ ++ lib.optionals pkgs.stdenv.isDarwin (import ./packages/macos.nix {
99+ inherit pkgs;
1010+ });
1111+1212+ targets.genericLinux.enable = pkgs.stdenv.isLinux;
1313+1414+ # This value determines the Home Manager release that your
1515+ # configuration is compatible with. This helps avoid breakage
1616+ # when a new Home Manager release introduces backwards
1717+ # incompatible changes.
1818+ #
1919+ # You can update Home Manager without changing this value. See
2020+ # the Home Manager release notes for a list of state version
2121+ # changes in each release.
2222+ home.stateVersion = "25.11";
2323+2424+ # Let Home Manager install and manage itself.
2525+ programs.home-manager.enable = true;
2626+}
+19
hosts.nix
···11+{
22+ # Host entries are keyed by the machine's real short hostname.
33+ # - macOS: `scutil --get LocalHostName`
44+ # - Linux: `hostname -s`
55+ #
66+ # Each host usually only needs:
77+ # - `system`: Nix platform string such as `aarch64-darwin` or `x86_64-linux`
88+ # Get it on the target machine with:
99+ # `nix eval --impure --raw --expr builtins.currentSystem`
1010+ # - `username`: local login user that Home Manager should manage
1111+ #
1212+ # Optional overrides:
1313+ # - `homeDirectory`: defaults to `/Users/<username>` on macOS and `/home/<username>` on Linux
1414+ # - `flakeDirectory`: defaults to `<homeDirectory>/.dot`
1515+ MacBook-Air-de-Daniel = {
1616+ system = "aarch64-darwin";
1717+ username = "vieitesprefapp";
1818+ };
1919+}