title: How to override compile flags for a single package in nixos?
body: <p>How can I override compile flags (as in <code>CFLAGS</code>) for a single package in NixOS/Nix environments?</p>
  
  <p>Here's what I've got by now:</p>
  
  <pre><code>let
     optimizeForThisHost = pkg:
       pkgs.lib.overrideDerivation pkg (old: {
         exportOptimizations = ''
           export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -fPIC -O3 -march=native"
         '';
         phaseNames = ["exportOptimizations"] ++ old.phaseNames;
       });
  in
  muttWithoutThings = pkgs: (pkgs.mutt.override {
      sslSupport  = false;
      saslSupport = false;
      imapSupport = false;
      withSidebar = false;
   };
  });
  
  mutt = pkgs:
      (optimizeForThisHost (muttWithoutThings pkgs));
  </code></pre>
  
  <p>in my <code>configuration.nix</code>, though this fails with</p>
  
  <pre><code>error: attribute ‘phaseNames’ missing
  </code></pre>