cleverca22
3/12/2016 - 2:42 AM

example.nix

[clever@amd-nixos:~]$ nix-repl
Welcome to Nix version 1.11.2. Type :? for help.

nix-repl> :l <nixpkgs>
Added 6072 variables.

nix-repl> configs = { laptop = "foo"; desktop = "bar"; }

nix-repl> configs
{ desktop = "bar"; laptop = "foo"; }

nix-repl> hostname = "laptop"

nix-repl> hostname
"laptop"

nix-repl> lib.attrByPath [hostname] {} configs
"foo"

nix-repl> configs.${hostname}
"foo"
let
  ugly = { laptop = ./laptop.nix; desktop = ./desktop.nix; };
in
{
  imports = [ ugly.${config.network.hostName} ];
}