Go to file
jolheiser c1d5ec9d07
fix: allow blank NIXFIG_FMT to disable formatting
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2024-06-19 20:44:25 -05:00
cmd docs: add defaults to --help 2024-04-25 13:15:46 -05:00
testdata feat: nixgen 2024-04-24 19:13:45 -05:00
.gitignore initial commit 2023-11-29 13:08:49 -06:00
LICENSE initial commit 2023-11-29 13:08:49 -06:00
README.md initial commit 2023-11-29 13:08:49 -06:00
flake.lock feat: nix 2024-04-24 20:39:26 -05:00
flake.nix feat: nix 2024-04-24 20:39:26 -05:00
go.mod feat: nixgen 2024-04-24 19:13:45 -05:00
go.mod.sri feat: nix 2024-04-24 20:39:26 -05:00
go.sum feat: nixgen 2024-04-24 19:13:45 -05:00
nixfig.go fix: allow blank NIXFIG_FMT to disable formatting 2024-06-19 20:44:25 -05:00
nixfig_test.go feat: add fmt 2024-06-19 20:31:46 -05:00

README.md

nixfig

Read a nix file as a config.

Essentially just wraps nix eval (--json) --expr.

Allows parsing the following:

let
  user = "jolheiser";
in {
  log = {
    level = "warn";
    # Name the log file after the user....for reasons
    file = "${user}.log";
  };
  http = {
    host = "0.0.0.0";
    port = 1234;
    # Make user an admin, but also make a generic admin user
    admins = [user "admin"];
  };
}

Into a struct like:

type Config struct {
	Log struct {
		Level string // warn
		File  string // jolheiser.log
	}
	HTTP struct {
		Host   string   // 0.0.0.0
		Port   int      // 1234
		Admins []string // [jolheiser admin]
	}
}

It can also marshal a struct into a valid (albeit minified) nix expression.

License

MIT