docs: add colmena eval

This commit is contained in:
Daniel Langbein 2024-08-24 13:01:26 +02:00
parent 2a1f54b5d8
commit 9bc89a6dc4
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002

View File

@ -28,6 +28,7 @@ This document contains general notes about NixOS that are independent of my NixO
* [NixOS configuration debugging](#nixos-configuration-debugging)
* [Show Nix configuration](#show-nix-configuration)
* [Evaluate NixOS configuration to JSON](#evaluate-nixos-configuration-to-json)
* [Evaluate expressions in the context of a NixOS configuration managed with Colmena](#evaluate-expressions-in-the-context-of-a-nixos-configuration-managed-with-colmena)
* [Evaluate expressions](#evaluate-expressions)
* [Escape strings](#escape-strings)
* [Run AppImages](#run-appimages)
@ -674,6 +675,30 @@ import ./hosts/yodaTab/configuration.nix {
Then open `evaluated-config.json`.
## Evaluate expressions in the context of a NixOS configuration managed with Colmena
https://colmena.cli.rs/unstable/reference/cli.html#colmena-eval
Either specify a file containing the expression or add it as argument with `-E`.
```shell
colmena eval -E '{ nodes, lib, pkgs, ... }: nodes.yodaTux.config.networking.hostName'
```
```shell
nix-shell -p jq
colmena eval -E '{ nodes, lib, pkgs, ... }: nodes.yodaTux.config.environment.systemPackages' | jq
```
```shell
colmena eval -E '{ nodes, lib, pkgs, ... }: pkgs.linux'
#=> "/nix/store/6l9b3dly45iv2rp17hk5c3wvawaq0viy-linux-6.6.46"
```
```shell
colmena eval -E '{ nodes, lib, pkgs, ... }: { imports = [ ./modules/nur-and-unstable.nix ]; pkgs.linux }'
```
## Evaluate expressions
* https://discourse.nixos.org/t/eval-nix-expression-from-the-command-line/8993/6