Help me get started - Best practice, nvim, learning the language

Hi,
I am all new to NixOS. Just installed it yesterday. And within an hour or so, I had it pretty much up and running how I like it, i.e. installed my must-have programs, changed WM to I3 etc. I really like TUI and textbased configuration. I obviously love VI and NixOS just seems to be a natural extension of this. So <3 <3 <3

  1. Actually I love it so much that I have planned to spend time learning the language at least somewhat. I have worked as a software developer, so learning a new computer language shouldn’t be TOO hard. But I have never done anything functional programming. So perhaps? Also I have been working with as a teacher for the last 13 years. So my CS might be slightly rusty.
    What are your recommendation to get too learn the language?

  2. As said I really like VI, or rather neovim. How do I set it up properly. I would like:

  • vimtex
  • ultisnips
  • A language server / IDE for the Nix-language
  • A language server / IDE for Bash and Python
  1. What is best-practice for making configuration?
  • Is it prefered, acceptable or not recommended to split up the configuration, so I have e.g. a special file for everything with my WM, a special file for everything with VI, a special file for everything with my hard drives, luks, etc. etc. etc.
  • Is it recommended to move as much as possible from the .config to the Nix-file? E.g. should I have all my I3 configuration which is currently in .config/i3/config in my Nix-file? Some of it? Or should I just leave it in my .config-folder?

Just to clarify. I am using the full OS on bare metal. So I am talking about the OS, nut ‘just’ the package-manager.

Thanks!
And thanks for NixOS. I really love it. Right now my favorite things about my computer-setup is: VI, I3, TUI-software and GNU tools like piping and grep etc., Git, BTRFS with snapshots and CoW (I love cp --reflink) and Nixos (not necessarily in that order though). I really do not understand how I could live with Windows, Notepad++ etc.

As one of the main authors and maintainers of the official Nix language tutorial, I obviously recommend Nix language basics — nix.dev documentation. It is deliberately designed to be gentle with people not familiar with functional programming. Any feedback in the form of pull requests to further ease onboarding is highly appreciated.

3 Likes

There’s a basic tutorial here: Nix language basics — nix.dev documentation

nix.dev generally has some good guides nowadays.

Beyond that, figure out how packaging packages work, how writing modules works, and make use of the nix repl to try things out

Functional languages definitely feel different, if you’ve used python before, think list comprehensions and generators in general.

I’ve worked with engineers much more senior than me who hated them because they felt they were “thinking backwards”. But if you come to them with an open mind I think you might find them fun. Nix is only rarely used for hardcore programming anyway, so you may never have to really learn programming in these languages.

I have to admit, I’ve not used vim on NixOS. There is programs.neovim.enable and its sister options, which you can use to do most configuration.

Lot of language servers are also just packaged for nix, and you only need to install them.

Maybe home-manager’s options are better/more idiomatic though: Appendix A. Configuration Options

Depends. Generally, yes, splitting files into conceptual units is good software engineering practice, but you don’t want dozens of three-line files.

Vi/WM definitely sound complex enough to be nice “units”.

For hard drives/luks I’d recommend disko by the way.

If you want the full reproducible OS experience, this is indeed necessary. If you use home-manager this can be done relatively transparently, often just need to set up a home.file.

It’s not mandatory to use NixOS, however, and trying to do so can be time consuming. It’s a good way to learn nix though!

2 Likes

@lytjedk Welcome to the dark side. :slight_smile:

You already got good advise in this thread, so I’ll just add a few remarks:

Don’t try to cramp everything in your main config. It just bloats your system and increases rebuild times. If you launch Gimp only once in a few months, just run in on demand using nix-shell/nix run. Keep stuff like compiler-toolchains in project specific setups. These usually have a different cadence of updates and again, keeps your main system lean and clean.

Use Home-Manager for your system configuration. Home-Manager has very elaborate options for many programs (e.g. VIM) and is much better suited to manage/create your dotfiles.

Keep the search and manual pages at hand.

Split your config, but don’t overdo it. Having a separate config file e.g. for VIM or i3 can be quite useful when you want to share it with configurations for other machines later on, while keeping system-specific stuff (e.g. GPU settings, monitor layout,…) in one file avoids cluttering of your config folder.
Don’t worry too much about that in the beginning, you can always refactor as your config grows and you get more proficient with Nix. Nixpkgs brings also a good library of helper functions: Nixpkgs 23.05 manual | Nix & NixOS

3 Likes

Those things can grow out of hand though, especially with nvidia. You also already have a hardware-configuration.nix. Personally I recommend host-specific folders so the mess is contained, just don’t be too hesitant about splitting these configs either (and later you can also factor out e.g. nvidia config into a more general module if you have more nvidia machines).

1 Like