### Preview changes with --diff flag Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Adds the `--diff` flag to any command to get a preview of the changes. This example shows it with the `follow` command. ```shell flake-edit --diff follow ``` -------------------------------- ### flake-edit add-follow command help Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the help text for the `flake-edit add-follow` command. It explains that the command manually adds a single follows declaration, gives an example invocation, and notes that without arguments it starts an interactive selection. The help also documents the `[INPUT]` and `[TARGET]` arguments and the `--config` option. ```text Manually add a single follows declaration. Example: `flake-edit add-follow rust-overlay.nixpkgs nixpkgs` This creates: `rust-overlay.inputs.nixpkgs.follows = "nixpkgs";` Without arguments, starts an interactive selection. Usage: flake-edit add-follow [OPTIONS] [INPUT] [TARGET] Arguments: [INPUT] The input path in dot notation (e.g., "rust-overlay.nixpkgs" means the nixpkgs input of rust-overlay) [TARGET] The target input to follow (e.g., "nixpkgs") Options: --config Path to a custom configuration file -h, --help Print help (see a summary with '-h') ``` -------------------------------- ### Enter development shell with nix develop Source: https://github.com/a-kenji/flake-edit/blob/main/docs/CONTRIBUTING.md Use this command to enter the development environment provided by the project's Nix flake. This is the primary way to get the necessary tools for contributing. ```bash nix develop ``` -------------------------------- ### Run flake-edit from nixpkgs Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Runs flake-edit from the nixpkgs flake. The `--diff` flag is passed to the command to get a preview of changes. ```shell nix run nixpkgs#flake-edit -- --diff follow ``` -------------------------------- ### Run benchmarks with cargo bench Source: https://github.com/a-kenji/flake-edit/blob/main/docs/CONTRIBUTING.md Executes the project's benchmark suite. Ensure your machine is in a stable state and not under heavy load to get accurate and consistent results. ```bash cargo bench ``` -------------------------------- ### Install flake-edit with cargo install Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Installs flake-edit from crates.io using cargo. Use the `--locked` flag to ensure the exact dependency versions from the lockfile are used. ```shell cargo install flake-edit --locked ``` -------------------------------- ### Run flake-edit from main branch Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Runs flake-edit from the main branch of its GitHub repository. The `--diff` flag is passed to get a preview of changes. ```shell nix run github:a-kenji/flake-edit -- --diff follow ``` -------------------------------- ### Set up direnv with cat .envrc and direnv allow Source: https://github.com/a-kenji/flake-edit/blob/main/docs/CONTRIBUTING.md Alternative to `nix develop` for entering the development environment. First, inspect the `.envrc` file to see what it does, then allow direnv to load the environment automatically. ```bash cat .envrc && direnv allow ``` -------------------------------- ### Auto-follow all inputs with flake-edit follow Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Automatically follows all your inputs through `flake.nix`. This is a convenience command to set up follows for all inputs. ```shell flake-edit follow ``` -------------------------------- ### flake-edit config command help Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the help text for the `flake-edit config` command. It lists the available options: `--print-default` to output the default configuration to stdout, `--path` to show where configuration would be loaded from, and `--config` to specify a custom configuration file. ```text Manage flake-edit configuration Usage: flake-edit config [OPTIONS] Options: --print-default Output the default configuration to stdout --path Show where configuration would be loaded from --config Path to a custom configuration file -h, --help Print help ``` -------------------------------- ### List all current inputs Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Lists all current inputs. ```bash flake-edit list ``` -------------------------------- ### flake-edit main CLI usage Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the command-line interface for flake-edit, including the available subcommands (add, remove, change, list, update, pin, unpin, toggle, follow, add-follow, config, help) and global options (--flake, --lock-file, --diff, --no-lock, --non-interactive, --no-cache, --cache, --config). Note that --flake defaults to `flake.nix` in the current directory, and --lock-file defaults to `flake.lock` in the current directory. ```text Edit your flake inputs with ease Usage: flake-edit [OPTIONS] Commands: add Add a new flake reference remove Remove a specific flake reference based on its id change Change an existing flake reference's URI list List flake inputs update Update inputs to their latest specified release pin Pin inputs to their current or a specified rev unpin Unpin an input so it tracks the upstream default again toggle Toggle an input between its active url and a stored alternate follow Automatically add and remove follows declarations add-follow Manually add a single follows declaration config Manage flake-edit configuration help Print this message or the help of the given subcommand(s) Options: --flake Path to `flake.nix`, or a directory containing `flake.nix`. Defaults to `flake.nix` in the current directory --lock-file Location of the `flake.lock` file. Defaults to `flake.lock` in the current directory --diff Print a diff of the changes instead of writing them to disk --no-lock Skip updating the lockfile after editing flake.nix --non-interactive Disable interactive prompts --no-cache Disable reading from and writing to the completion cache --cache Path to a custom cache file --config Path to a custom configuration file -h, --help Print help (see a summary with '-h') -V, --version Print version ``` -------------------------------- ### Preview changes with --diff Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Previews changes without applying them. ```bash flake-edit --diff add home-manager github:nix-community/home-manager ``` -------------------------------- ### flake-edit follow command help Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the help output for the `flake-edit follow` command, which automatically adds and removes `follows` declarations. It processes multiple flakes in batch, and supports `--transitive`, `--depth`, `--stats`, and `--dry-run` options. ```text Automatically add and remove follows declarations. Analyzes the flake.lock to find nested inputs that match top-level inputs, then adds appropriate follows declarations and removes stale ones. With file paths, processes multiple flakes in batch. For every `flake.nix` file passed in it will assume a `flake.lock` file exists in the same directory. Usage: flake-edit follow [OPTIONS] [PATHS]... Arguments: [PATHS]... `flake.nix` files or directories containing one. If empty, runs on current directory Options: --transitive [] Enable transitive follows deduplication, promoting shared nested inputs to top-level when they appear at least N times. Defaults to 2 if no value is given. Overrides the config file's `follow.transitive_min` --depth Maximum depth of follows declarations to write. Omitting the flag writes follows at every depth the lockfile graph supports. `--depth N` caps emission: 1 writes only `parent.child.follows`, 2 also writes `parent.child.grandchild.follows`, and so on. Overrides the config file's `follow.max_depth` -s, --stats Show size gain estimates that follows deduplication brought --dry-run Preview what `--stats` would show without applying changes --config Path to a custom configuration file -h, --help Print help (see a summary with '-h') ``` -------------------------------- ### Switch input to local checkout Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Switches an input to a local checkout, storing the previous URL as a commented alternate. ```bash flake-edit toggle ../rust-overlay ``` -------------------------------- ### flake-edit add CLI usage Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the command-line interface for `flake-edit add`, which adds a new flake reference. The --ref-or-rev option pins to a specific ref_or_rev; --no-flake indicates the input is not a flake; --shallow uses a shallow clone; --config specifies a custom configuration file. ```text Add a new flake reference Usage: flake-edit add [OPTIONS] [ID] [URI] Arguments: [ID] The name of an input attribute [URI] The uri that should be added to the input Options: --ref-or-rev Pin to a specific ref_or_rev -n, --no-flake The input itself is not a flake -s, --shallow Use shallow clone for the input --config Path to a custom configuration file -h, --help Print help ``` -------------------------------- ### flake-edit list command help Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the help output for the `flake-edit list` command, which lists flake inputs. The format can be `simple`, `toplevel`, `detailed` (default), or `json`. ```text List flake inputs Usage: flake-edit list [OPTIONS] Options: --format [default: detailed] [possible values: simple, toplevel, detailed, json] --config Path to a custom configuration file -h, --help Print help ``` -------------------------------- ### Review snapshot tests with cargo insta review Source: https://github.com/a-kenji/flake-edit/blob/main/docs/CONTRIBUTING.md Use this command to interactively review and accept or reject failing snapshot tests. This is part of the project's snapshot testing workflow using the `insta` crate. ```bash cargo insta review ``` -------------------------------- ### Add flake-edit as a library with cargo add Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Run this command to add flake-edit as a library dependency. The lib interface is currently unstable. ```bash cargo add flake-edit --no-default-features ``` -------------------------------- ### flake-edit unpin command help Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the help output for the `flake-edit unpin` command, which resets an input to track the upstream default. The command accepts an optional input ID and supports a custom configuration file. ```text Unpin an input so it tracks the upstream default again Usage: flake-edit unpin [OPTIONS] [ID] Arguments: [ID] The id of an input attribute Options: --config Path to a custom configuration file -h, --help Print help ``` -------------------------------- ### Update all inputs to latest versions Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Updates all inputs to their latest versions. ```bash flake-edit update ``` -------------------------------- ### flake-edit toggle command help Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the help output for the `flake-edit toggle` command, which toggles an input between its active URL and a stored alternate. The `-r` option removes a URL instead of activating it, and the command supports a custom config file. ```text Toggle an input between its active url and a stored alternate. Alternates live as commented copies of the url line next to the active one. Flipping moves only the comment marker. Usage: flake-edit toggle [OPTIONS] [INPUT] [REF] Arguments: [INPUT] An input id, or a flake reference to activate [REF] The variant to activate, stored as a new alternate when not yet present Options: -r, --remove Remove a url instead of activating it. A bare input id removes the active url and activates the stored alternate in its place. An alternate's ref deletes that alternate and keeps the active url --config Path to a custom configuration file -h, --help Print help (see a summary with '-h') ``` -------------------------------- ### flake-edit change CLI usage Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the command-line interface for `flake-edit change`, which changes an existing flake input's URI. The --ref-or-rev option pins to a specific ref_or_rev; --shallow uses a shallow clone; --config specifies a custom configuration file. ```text Change an existing flake reference's URI Usage: flake-edit change [OPTIONS] [ID] [URI] Arguments: [ID] The name of an existing input attribute [URI] The new URI for the input Options: --ref-or-rev Pin to a specific ref_or_rev -s, --shallow Use shallow clone for the input --config Path to a custom configuration file -h, --help Print help ``` -------------------------------- ### flake-edit update CLI usage Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the command-line interface for `flake-edit update`, which updates inputs to their latest specified release. The optional ID argument selects a single input; omitting it updates all inputs. The --init flag uses the latest semver release even if it isn't yet pinned to a specific release. ```text Update inputs to their latest specified release Usage: flake-edit update [OPTIONS] [ID] Arguments: [ID] The id of an input attribute. If omitted will update all inputs Options: --init Whether the latest semver release of the remote should be used even thought the release itself isn't yet pinned to a specific release --config Path to a custom configuration file -h, --help Print help ``` -------------------------------- ### Add a new input with flake-edit add Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Adds a new input to your flake. The input is specified using the GitHub shorthand `github:numtide/treefmt-nix`. ```shell flake-edit add github:numtide/treefmt-nix ``` -------------------------------- ### flake-edit pin CLI usage Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the command-line interface for `flake-edit pin`, which pins inputs to their current or a specified rev. The ID argument identifies the input, and the optional REV argument specifies the revision to pin to. The --config option allows a custom configuration file. ```text Pin inputs to their current or a specified rev Usage: flake-edit pin [OPTIONS] [ID] [REV] Arguments: [ID] The id of an input attribute [REV] Optionally specify a rev for the inputs attribute Options: --config Path to a custom configuration file -h, --help Print help ``` -------------------------------- ### Pin an input to its current revision Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Pins an input to its current revision. ```bash flake-edit pin nixpkgs ``` -------------------------------- ### Toggle an input between active and alternate Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Toggles an input between its active URL and a stored alternate. ```bash flake-edit toggle rust-overlay ``` -------------------------------- ### Add a flake input Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Adds a new flake input with an explicit name and URL. The command is `flake-edit add `. ```bash flake-edit add nixpkgs github:NixOS/nixpkgs ``` -------------------------------- ### Add input with automatic ID inference Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Adds an input while automatically inferring the input name from the URL. The command is `flake-edit add `. ```bash flake-edit add github:nix-community/home-manager ``` -------------------------------- ### Remove stored variant and flip to alternative Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Removes a stored variant's line and flips to the alternative first. ```bash flake-edit toggle --remove ../rust-overlay ``` -------------------------------- ### flake-edit remove CLI usage Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Shows the command-line interface for `flake-edit remove`, which removes a flake input by its id. It only accepts an optional ID argument and a --config option for a custom configuration file. ```text Remove a specific flake reference based on its id Usage: flake-edit remove [OPTIONS] [ID] Arguments: [ID] Options: --config Path to a custom configuration file -h, --help Print help ``` -------------------------------- ### Default flake-edit TOML configuration Source: https://github.com/a-kenji/flake-edit/blob/main/README.md Default configuration for flake-edit created by running `flake-edit config --print-default`. It contains settings for the follow command, including alias mappings and optional ignore, transitive_min, and max_depth options. ```toml # flake-edit ~ configuration file # https://github.com/a-kenji/flake-edit # Configuration for `flake-edit follow [PATHS]` [follow] # Inputs to ignore. Supports two formats: # - Full path: "crane.nixpkgs" - ignores only that specific nested input # - Simple name: "systems" - ignores all nested inputs with that name # ignore = ["systems", "crane.flake-utils"] # Minimum number of transitive follows required to add a top-level follows input. # Set to 0 to disable transitive follows deduplication. # transitive_min = 2 # Alias mappings. # Key is the canonical name (must exist at top-level), values are alternatives. # If nested input is "nixpkgs-lib" and top-level "nixpkgs" exists, # follow will suggest: poetry2nix.nixpkgs-lib -> nixpkgs. # Set aliases = {} to disable built-in aliases. aliases = { nixpkgs = ["nixpkgs-lib"] } # Maximum depth of follows declarations to write. # Unset (the default) writes follows at every depth the lockfile graph # supports. Set an explicit number to cap the depth: 1 writes only # `parent.nested.follows = "target"`, 2 also writes # `parent.middle.grandchild.follows = "target"`, and so on. # max_depth = 1 ``` -------------------------------- ### Add input without updating lockfile Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Adds an input without updating the lockfile. ```bash flake-edit --no-lock add nixos-hardware github:NixOS/nixos-hardware ``` -------------------------------- ### Remove a flake input Source: https://github.com/a-kenji/flake-edit/blob/main/docs/man/flake-edit.md Removes a flake input by its name. ```bash flake-edit remove nixpkgs ```