Literal Flake Input

4 Likes

that definitely looks like a fancier stop-gap than boolean-option · GitHub for until @edolstra’s GitHub - edolstra/configurable-flake lands upstream :sweat_smile:

1 Like

Version 0.0.5 is released. The tool is extended with commands covering all use cases for handling non-flake input URLs in flake files.

e commands

Init - add a new non-flake input to flake

$ e i -name Bill -age 70

The flake file would look like that after:

  # ...
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    c = {
      url = https://lficom.me/name/%22Bill%22/age/70;
      flake = false;
    };
  };

Pretty-printing URL as a Nix attrset

Checking a literal flake input URL in a flake file is not needed. A
value of literal flake input URL that is isomorphic to a Nix attrset can be
pretty-printed with p command:

$ e p -age 20
{ ... }:
  {
    age = 20;
    name = "Bill";
  }

Merge

Merge updates values only for the specified attributes in a flake file.
Meanwhile init command overrides the whole URL.

$ e m -name Bob && e p
{ ... }:
  {
    age = 70;
    name = "Bob";
  }

Remove an attribute

$ e x age && e p
{ ... }:
  {
    name = "Bob";
  }