# íqán

Helps you sync Nix flake pins, so you don't end up carrying fifty
ever-so-slightly different Nixpkgs in your store.

Has two modes of operation:

* Plan mode.  You give it a JSON file which looks like this:

  ```json
  {
    "source": "/Users/kivikakk/g/vyx",
    "targets": {
      "/Users/kivikakk/g/a1d": ["nixpkgs", "fenix"],
      "/Users/kivikakk/g/chog": {"nixpkgs-erlang": "nixpkgs"},
      "/Users/kivikakk/g/cmark-gfm-hs": ["nixpkgs"],
      "/Users/kivikakk/g/comrak": ["nixpkgs", "fenix"],
      "/Users/kivikakk/g/iqan": ["nixpkgs", "fenix"],
      "/Users/kivikakk/g/kivikakk": ["nixpkgs"],
      "/Users/kivikakk/g/koino": ["nixpkgs"],
      "/Users/kivikakk/g/kv": {"nixpkgs-erlang": "nixpkgs", "fenix": true},
      "/Users/kivikakk/g/nossa": {"nixpkgs-erlang": "nixpkgs", "fenix": true},
      "/Users/kivikakk/g/notes": ["nixpkgs"],
      "/Users/kivikakk/g/tahetriiv": ["nixpkgs", "fenix"]
    }
  }
  ```

  íqán proceeds through each target, and compares the named inputs to those in
  the source.  The inputs can be a list, which means inputs have the same name
  in both source and target, or a map of input names in source to target (or
  `true`, as a shorthand for the same).

  Note that "original mismatches" --- where the input specifications are
  different, not just the locked version --- are detected, and can be resolved
  in `flake.nix` as well as your lock file.

  íqán prompts you before making any change to anything, and only modifies
  `flake.lock` files specified in your `plan.json`'s `targets` section, and
  `flake.nix` files likewise located when an original mismatch occurs.

  `flake.lock` changes are made by parsing and writing out the JSON, and minor
  formatting changes may occur.

  `flake.nix` changes are made by parsing with [rnix](https://github.com/nix-community/rnix-parser),
  locating the syntax node corresponding to the input being changed, and then
  replacing just that text span in the source.  The changes are made conservatively,
  matching the expected existing value (as calculated from `flake.lock`),
  and if íqán cannot be sure of what it's doing, it aborts and lets you handle it.

* One-shot mode.  You run íqán in the target flake's directory, and give the
  directory of the source.  It'll run on all inputs in the target, prompting you
  as above.


## install

`cargo install iqan` will do, or `cargo build --release` from source.
The Nix flake will build it for you, if you like.


## license

Copyright © 2025–2026 Asherah Connor \<ashe@kivikakk.ee\>

This work is free. You can redistribute it and/or modify it under the terms of
the Do What The Fuck You Want To Public License, Version 2, as published by Sam
Hocevar. See the [COPYING](COPYING) file for more details.
