I am caught between two stools. I am not competent enough to use Nixos, but I’m trying to give it a go as the alternative, (Fedora), while an exceptional OS, is markedly inferior.
I am really clutching at this idea, a boil-in-the-bag config:
Applying the config that the video refers to verbatim will be challenging. With Nix you will probably want to use the Nix-native way to generate a Neovim config (I use the “oldschool” VimL configs, I am not sure about using Lua) and install plugins.
I will not be able to translate the entire large config for you, but once again, please look at programs.neovim, particularly programs.neovim.configure which has an example of how to add plugins and custom configuration file.
This way is ok but I prefer bundling the configuration with the plugin rather than putting everything in extraConfig although the tradeoff is that you don’t get highlighting. It also allows you to reference binary paths explicitly in the configuration with nix rather than relying on the binary in a global sense.
I put the neovim.nix configuration in .config/nixpkgs/
When I attempt to reference it
13 { config, pkgs, ... }:
12
11 {
10 # Home Manager needs a bit of information about you and the
9 # paths it should manage.
8 home.username = "marcus";
7 home.homeDirectory = "/home/marcus";
6
5 programs.neovim = {
4 enable = true;
3 extraConfig = lib.fileContents ../.config/nixpkgs/neovim.nix;
2 set number relativenumber
1 '';
14 };
It throws an error
[marcus@nixos:~]$ home-manager switch
error: syntax error, unexpected ID, expecting '.' or '='
at /home/marcus/.config/nixpkgs/home.nix:12:9:
11| extraConfig = lib.fileContents ../.config/nixpkgs/neovim.nix;
12| set number relativenumber
| ^
13| '';
(use '--show-trace' to show detailed location information)
So lib.fileContents takes a file as input and produces a string, therefore you need to concatenate the multiline string below it (which is missing the opening '' btw) to produce a resulting string for extraConfig. Try this below and see if it fixes your issue
programs.neovim = {
enable = true;
extraConfig = (lib.fileContents ../.config/nixpkgs/neovim.nix) + ''
set number relativenumber
'';
};
I am just apeing what the Wiki says Collin. Not very well obviously
With Home Manager
The Home Manager module does not expose many configuration options. Therefore, the easiest way to get started is to use the extraConfig option. You can copy your old config or directly load your default Neovim config via:
Syntax and scope issues aside (they’re what are producing the error messages in this comment and subsequent iterations), you’re attempting to append verbatim Nix source to your Neovim configuration file. That won’t work, of course, because Neovim expects Lua or VimL in its configuration files, not Nix code.
What you have in that ~/.config/nixpkgs/neovim.nix file is a Home Manager module. If you want to use Home Manager to configure Neovim, try getting started with Home Manager.
But you’re gonna need to slow down and try to understand more of what you’re piecing together here, I think. Have you ever done the interactive Nix tutorial here?
Hi PXC. I thought I’d post some low level questions and see how I got on. My use cases are fairly minimal, but for now it is not happening. I think Nixos should correctly be described as a spinoff of Linux, rather than Linux per se. F-linux if you like.
I simply have other priorities right now, but in 6 months time I will try and address the deficiencies in my knowledge.
Thank you for the resource - bookmarked for reference.
I really want to do something similar, but the lack of intellisense is a little disappointing. It’s not only the syntax highlighting (which you could get back by putting the config in a different file), but also autocomplete and the like.
Well I can get the syntax highlighting if I use lua files but I couldn’t resolve nix paths if I did that. Or at least, I’m not aware of how to do it. Apparently there is a way to get embedded highlighting with treesitter but I have no idea how to go about implementing that.