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