Open thomastjeffery opened 6 years ago
Copy an example config to the right place
~$ cp yi-editor/yi/example-configs/yi-config-that-you-want/* ~/.config/yi/
This is not needed by the static configs (which are recommended). They can be placed anywhere you want.
I think the overrides wouldn't have to be added if we would specify version bounds in the cabal files of the example-configs (which is probably a good idea anyway). What errors do you get when you don't specify these overrides in your ~/.config/nixpkgs/config.nix
?
Finally, I have seen somewhere that stack is also capable of using nix, so you should be able to run stack --nix build
instead of nix-shell -p cabal2nix
to build yi.
This is not needed by the static configs (which are recommended).
This is true, but it works for both. I wanted to be succinct. That is explained in the yi-editor/yi/README.md
.
What errors do you get when you don't specify these overrides in your
~/.config/nixpkgs/config.nix
?
Nix will try to build the package, and ghc will complain that it can't find the dependencies.
This is explained in more detail here
Finally, I have seen somewhere that stack is also capable of using nix
This is explicitly what I do not want to do.
I don't know what files stack
is going to put where. The advantage of Nix is that I am guaranteed a clean functional system. If I want to use Nix, I want to use Nix. Stack is a perfectly fine option, just not the one I am choosing. I don't even have stack
installed. I also want to rely on the prebuilt packages that Nix provides.
I've changed my own config so that it now build with nix:
$ git clone https://github.com/noughtmare/yi-config.git
$ cabal2nix . --shell > shell.nix
$ nix-build shell.nix
This should work without any overrides.
That works for me, even using 17.09
instead of master.
I think the explicit bounds on the versions of the dependencies helped in this case, so I will also try to fix the example-configs when I have the time.
I found another terrible problem, yi-dynamic-configuration is version 0.16.0 on nixpkgs, and the rest of the yi related packages are still on 0.14 so that causes major breakage, because yi-dynamic-configuration-0.16.0 requires yi-core-0.16.0 which is not included in the nixpkgs. So every dynamic configuration is broken on nix.
Using the example configs from https://github.com/yi-editor/yi/pull/1043 should also work now (except for the dynamic configs).
My first comment was just how to get an example config to build using Nix. Here is how to start hacking on yi
with Nix.
Here are the steps to set up a build environment using Nix for hacking Yi:
Get yi
source
mkdir yi-source
cd yi-source
git clone https://github.com/yi-editor/yi
git clone https://github.com/yi-rope
Make a default.nix
for every yi
library
cd yi
for f in yi-* do cd $f nix-shell -p cabal2nix --command "cabal2nix . > default.nix" cd .. done
cd ../yi-rope
nix-shell -p cabal2nix --command "cabal2nix . > default.nix"
3. Override Nix packages
There are a few ways to do this. I like to put the following in my `~/.config/nixpkgs/config.nix
Note that I have both `yi-editor/yi` and `yi-editor/yi-rope` checked out to `~/yi-source/`. Change those two paths accordingly:
```nix
let yi-source-root = ~/yi-source/yi;
yi-rope-source = ~/yi-source/yi-rope;
in
{
packageOverrides = pkgs: {
haskellPackages = pkgs.haskellPackages.override {
overrides = self: super: {
yi-core = self.callPackage (yi-source-root + /yi-core/default.nix) {};
yi-frontend-vty = self.callPackage (yi-source-root + /yi-frontend-vty/default.nix) {};
yi-frontend-pango = self.callPackage (yi-source-root + /yi-frontend-pango/default.nix) {};
yi-fuzzy-open = self.callPackage (yi-source-root + /yi-fuzzy-open/default.nix) {};
yi-ireader = self.callPackage (yi-source-root + /yi-ireader/default.nix) {};
yi-keymap-cua = self.callPackage (yi-source-root + /yi-keymap-cua/default.nix) {};
yi-keymap-emacs = self.callPackage (yi-source-root + /yi-keymap-emacs/default.nix) {};
yi-keymap-vim = self.callPackage (yi-source-root + /yi-keymap-vim/default.nix) {};
yi-language = self.callPackage (yi-source-root + /yi-language/default.nix) {};
yi-misc-modes = self.callPackage (yi-source-root + /yi-misc-modes/default.nix) {};
yi-mode-haskell = self.callPackage (yi-source-root + /yi-mode-haskell/default.nix) {};
yi-mode-javascript = self.callPackage (yi-source-root + /yi-mode-javascript/default.nix) {};
yi-snippet = self.callPackage (yi-source-root + /yi-snippet/default.nix) {};
yi-rope = self.callPackage (yi-rope-source + /default.nix) {};
};
};
};
}
Now you should be able to build yi
like usual.
To test this, you can type
nix-shell -p yi
and Nix will build the default configuration from your newly overridden packages, resulting in a shell with your new yi
in its path.
You can also build your config just like before, but now Nix will use your overridden packages.
It should probably also be mentioned that the *.cabal files need to be generated with hpack.
Also you could probably override the packages in the .nix file of your own config instead of in the global config.nix file.
The information here is confusing, convoluted, and doesn't seem to work.
The real way to build
yi
with NixTo build
yi
in Nix, here is what you currently can do:Set up package overrides in Nix, so
yi
will build at all Put the following in your~/.config/nixpkgs/config.nix
:If you don't do this, nix will complain that it has missing dependencies.
Copy an example config to the right place
Go to
~/.config/yi/
, and buildyi
. You can leave out the-I nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz
if you are already using themaster
channel. This will not work on another channel likeNixOS-17.09
.Run
yi
You need to use nix-shell, soyi
can rebuild the configuration you made.