2017-04-04 89 views
1

我在使用this模板來配置我的自定義vim和Nix。我vim-config/default.nix如下:在vim_configurable.customize中使用python3覆蓋python3

{ pkgs }: 

let 
    my_plugins = import ./plugins.nix { inherit (pkgs) vimUtils fetchFromGitHub; }; 
in with (pkgs // { python = pkgs.python3; }); vim_configurable.customize { 
    name = "vim"; 
    vimrcConfig = { 
    customRC = '' 
     syntax on 
     filetype on 
     " ... 
    ''; 

    vam.knownPlugins = vimPlugins // my_plugins; 
    vam.pluginDictionaries = [ 
     { names = [ 
     "ctrlp" 
     # ... 
     ]; } 
    ]; 
    }; 
} 

雖然有(pkgs // { python = pkgs.python3; })覆蓋在第5行,仍沒有使用python3(當我運行vim --version它顯示+python -python3)。我錯過了什麼?

回答

1

事實證明,with (pkgs // { python = pkgs.python3; });只修改pythonwith語句後面的範圍內。 vim_configurable中使用的python不受影響。我落得這樣做是讓使用vimUtils.makeCustomizablevim_configurable一個python3版本:

vim-config/default.nix

{ pkgs }: 

let 
  my_plugins = import ./plugins.nix { inherit (pkgs) vimUtils fetchFromGitHub; }; 
  configurable_nix_path = <nixpkgs/pkgs/applications/editors/vim/configurable.nix>; 
  my_vim_configurable = with pkgs; vimUtils.makeCustomizable (callPackage configurable_nix_path { 
    inherit (darwin.apple_sdk.frameworks) CoreServices Cocoa Foundation CoreData; 
    inherit (darwin) libobjc cf-private; 

    features = "huge"; # one of  tiny, small, normal, big or huge 
    lua = pkgs.lua5_1; 
    gui = config.vim.gui or "auto"; 
    python = python3; 

    # optional features by flags 
    flags = [ "python" "X11" ]; 
  }); 

in with pkgs; my_vim_configurable.customize { 
  name = "vim"; 
  vimrcConfig = { 
    customRC = '' 
      syntax on 
      「... 
    ''; 

    vam.knownPlugins = vimPlugins // my_plugins; 
    vam.pluginDictionaries = [ 
      { names = [ 
        "ctrlp" 
        # ... 
      ]; } 
    ]; 
  }; 
} 
+0

謝謝,非常有用。刪除configurable_nix_path中的雙引號會導致更高效(無需警報)的評估;請參閱https://groups.google.com/forum/#!topic/nix-devel/mPyaxyRShFE –

+0

謝謝@KlaasvanSchelven,我沒有看到自己的警告,但看起來它是一個更有效的解決方案。我已經更新了答案以反映這一變化。 – Ben