From 9bc89a6dc4e173bb7b9a313e2a3853d900e539ac Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Sat, 24 Aug 2024 13:01:26 +0200 Subject: [PATCH] docs: add colmena eval --- NixOS.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/NixOS.md b/NixOS.md index 2319a65..d873f9a 100644 --- a/NixOS.md +++ b/NixOS.md @@ -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