title: how to add NixOS unstable channel declaratively in configuration.nix
body: <p>The NixOS cheatsheet describes how to install packages from <code>unstable</code> in <code>configuration.nix</code>.</p>
  
  <p>It starts off by saying to add the unstable channel like so:</p>
  
  <pre><code>$ sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable
  $ sudo nix-channel --update
  </code></pre>
  
  <p>Then, it is easy to use this channel in <code>configuration.nix</code> (since it should now be on <code>NIX_PATH</code>):</p>
  
  <pre><code>nixpkgs.config = {
    allowUnfree = true;
    packageOverrides = pkgs: {
      unstable = import &lt;nixos-unstable&gt; {
        config = config.nixpkgs.config;
      };
    };
  };
  
  environment = {
    systemPackages = with pkgs; [
      unstable.google-chrome
    ];
  };
  </code></pre>
  
  <hr>
  
  <p>I would like to not have to do the manual <code>nix-channel --add</code> and <code>nix-channel --update</code> steps.  </p>
  
  <p>I would like to be able to install my system from <code>configuration.nix</code> without first having to run the <code>nix-channel --add</code> and <code>nix-channel --update</code> steps.</p>
  
  <p>Is there a way to automate this from <code>configuration.nix</code>?</p>