3

I am new to nix expression. I found two configuration files that I want to use in nix-shell.

Unfortunately I failed to merge them due to my lack of nix expression knowledge. Always end-up with syntax error.

a.nix is for setting custom shellHook. Here simplified for just setting $PS1

{ pkgs ? import <nixpkgs> {}  }:

with pkgs;

stdenv.mkDerivation {
  name = "python3-shell";
  buildInputs = [ ];

  shellHook = ''
    export PS1="\[\033[1;32m\][nix-shell:\w]\n$ \[\033[0m\]"
  '';
}

b.nix is for python override. I need this to make jedi-vim work.

with import <nixpkgs> {};

( pkgs.python3.buildEnv.override  {
  extraLibs = with pkgs.python3Packages; [ jedi pyyaml ];
}).env

I do understand a.nix structures but the syntax in b.nix is different.

How should I do it?

Is there any simpler resource to study beside nixos manual?

1 Answer 1

2

Solved with following configuration.

{ pkgs ? import <nixpkgs> {} }:

with pkgs;

let py3s = pkgs.python3.buildEnv.override {
  extraLibs = with pkgs.python3Packages; [ jedi pyyaml ];
};
in stdenv.mkDerivation {
  name = "python3-shell";
  buildInputs = [ py3s ];

  shellHook = ''
    export PS1="\[\033[1;32m\][nix-shell:\w]\n$ \[\033[0m\]"
  '';
}

Still have not fully understand the code but somehow got desire prompt and jedi-vim can now see yaml

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .