Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Last active March 12, 2016 02:44
Show Gist options
  • Save cleverca22/612292017df5d24397ac to your computer and use it in GitHub Desktop.
Save cleverca22/612292017df5d24397ac to your computer and use it in GitHub Desktop.
let
ugly = { laptop = ./laptop.nix; desktop = ./desktop.nix; };
in
{
imports = [ ugly.${config.network.hostName} ];
}
[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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment