I’m trying to use some Nix package manager variables inside the .nix configuration files. I’m learning NixOS and Nix package manager about 2 months now and I know that if I want to get information about NixOS package configuration, I can go to nixpkgs repository on GitHub(https://github.com/NixOS/nixpkgs/tree/master) and open folder /nixos/modules
There I can find .nix config files, related to different packages, with configuration options described.
So I want to know, how to get list and description of different Nix package manager variables in a similar way(or if there’s no way to do so, if there’s alternative way to get info about NixPkgs variables)
For example, in one of my NixOS configs, I use variable ${config.system.build.nixos-rebuild}
What should I do, if I want to get all available variables inside submodule config.system.build
?
Can the nix read-event-print-loop help you?
nix repl
try
nix repl
:l <nixpkgs>
:l <nixpkgs/nixos>
config.services.nginx.enable
nix repl support tab completion. like the shell, so config. can really help.
does this help at all?
For me personally, I’m not sure how nix repl is evalating /etc/nixos/configration.nix … but it is.
I presume nix repl just looks in NIX_PATH and NIXPKGS_CONFIG, and evaluates those from there…
NIX_PATH=/root/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
NIXPKGS_CONFIG=/etc/nix/nixpkgs-config.nix
if you on nixos you can use the handy
nixos-option services.nginx.enable
again it supports tab smashing completion…
is this the ‘proper’ way of doing? I’m not sure, but seeing as nix and nixos has many ways of doing things, i don’t think there is any ‘standard’ or ‘proper way of doing things’. That’s what makes nix/nixos so brilliant and so terrifying at the same time.