···3737| Command | Effect |
3838| --- | --- |
3939| `just build` | Build the configuration for the current machine |
4040+| `just check` | Evaluate the flake and build the current machine configuration |
4041| `just switch` | Apply the configuration for the current machine |
4142| `just hm-build <host>` | Build a specific Linux Home Manager target |
4243| `just hm-switch <host>` | Apply a specific Linux Home Manager target |
4444+4545+## Managing App Configs
4646+4747+1. Put the app files under `config/<app>/`.
4848+2. Add the app to `configs.nix`.
4949+3. Omit `paths` to link the whole directory to `~/.config/<app>`.
5050+4. Use `paths` when an app needs file-level links or non-standard destinations such as `.aerospace.toml`.
43514452## Adding A Machine
4553
+50-6
_configs.nix
···11+{ lib }:
12let
22- mkConfig = name: options: {
33- active = options.active or true;
44- configDir = options.configDir or true;
55- dest = options.dest or "";
66- };
33+ checkPaths = name: paths:
44+ let
55+ required = [ "src" "dest" ];
66+ missingFields = lib.unique (lib.concatMap
77+ (path: builtins.filter (field: !(builtins.hasAttr field path)) required)
88+ paths);
99+ sourceLabel = path: if path.src == "" then "<app root>" else path.src;
1010+ sourcePath = path:
1111+ ./config + "/${name}${lib.optionalString (path.src != "") "/${path.src}"}";
1212+ in
1313+ if paths == [] then
1414+ throw "configs.${name}.paths must not be empty"
1515+ else if missingFields != [] then
1616+ throw "configs.${name}.paths entries are missing: ${lib.concatStringsSep ", " missingFields}"
1717+ else
1818+ let
1919+ missingSources = lib.unique (builtins.map sourceLabel (builtins.filter
2020+ (path: !(builtins.pathExists (sourcePath path)))
2121+ paths));
2222+ in
2323+ if missingSources != [] then
2424+ throw "configs.${name} references missing sources under config/${name}: ${lib.concatStringsSep ", " missingSources}"
2525+ else
2626+ true;
2727+2828+ mkConfig = name: opts:
2929+ let
3030+ configDir = opts.configDir or true;
3131+ paths =
3232+ if opts ? paths then
3333+ opts.paths
3434+ else if configDir then
3535+ [
3636+ {
3737+ src = "";
3838+ dest = ".config/${name}";
3939+ }
4040+ ]
4141+ else
4242+ throw "configs.${name} must define paths when configDir = false";
4343+ in
4444+ assert checkPaths name paths;
4545+ {
4646+ active = opts.active or true;
4747+ inherit configDir paths;
4848+ };
4949+ result = lib.mapAttrs mkConfig (import ./configs.nix);
750in
85199-lib.mapAttrs mkConfig (import ./configs.nix)
5252+# Evaluates `result` (1st) recursively and evaluates and returns `result` (2nd).
5353+builtins.deepSeq result result