How to include other peoples flakes in your config?

Hi guys, I’m just starting down my nixOS journey. And i think I’m at the point where I see how powerful going down this path can be but not where I’m actually capable of executing everything i want to do.

So i planing to do this bit by bit. I started playing with nixOS in a VM on my main laptop, and after getting the absolute basics in order I installed it on my backup laptop some days ago.

Finding good coherent documentation that does not assume some previous knowledge of how things should be used is my current issue. So I hope I can get some pointers how and where I can learn more to get myself a better understanding of how things work.

I have made a pretty bare bone system mostly following Wil T youtube videos witch was very helpful getting up and running.

link to my config: GitHub - arosl/nixosconf: nixosconf

I have a couple of questions:

  1. Is there some good patterns i should follow, or some anti-patterns i should avoid?

  2. Why does a lot of nix config i find have the pattern /default.nix instead of just packageName.nix?

  3. I have had a bit of an issue configuring neovim the nix way. Just before I discovered nixOS I discovered nvChad and was amazed about how fast this complete IDE experience was feeling, but the installation process is just pulling in sidecars en masse, so probably as far as you can get from a pure nix experience as you can get. So I have been looking for nix ways to get a similar experience up and running that I can customize later. I realized i could run some neovim.flakes like this:

nix run github:jordanisaacs/neovim-flake
nix run github:notashelf/neovim-flake

But if I want to change my nixos config so when run (neo)vim i get the notashelf flake version of neovim. How do I do that? I guess if I want to make changes to this I just need to fork that repo and add my own changes, but I don’t currently understand how I can change my flake.nix output to get this version of neovim.

I have added other input and outputs to my flake myself. But I don’t have a good enough understanding of the process to understand how to get the correct output from random flakes.

First off, you’re already doing something very right by using follows:

    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";

    alejandra.url = "github:kamadorueda/alejandra";
    alejandra.inputs.nixpkgs.follows = "nixpkgs";

You should do this for every flake that includes the same dependencies so that all dependencies are locked by your flake. For nixpkgs this is especially important to avoid duplicate instances.

Apart from that, I don’t have any specific things to remark about your config. If you start to hit issues with scale, you might want to consider using humea to split your flake into modules more flexibly, but many don’t use any tools like that.

default.nix is the file that gets evaluated by the old CLI tools like nix-env or nix-build by default when you don’t explicitly pass a path to them. Flakes-enabled nix doesn’t use it much AFAIK, but many include it and use flake-compat to support the old CLI.

default.nix is also the filename of most packages in nixpkgs. As many of them need supporting files like patches, scripts and sometimes other nix files, so the convention is to have a folder with the package name and default.nix in there. You’re then free to use any other name for any auxiliary files. For example, this is the tree of uniscribe:

├── Gemfile
├── Gemfile.lock
├── default.nix
└── gemset.nix

In nixpkgs specifically, this convention is codified in the callPackage function, which calls Nix file directly, or, if it is a directory, the default.nix in that directory. It is used to pass all the required dependencies to the package. The vast majority of lines in pkgs/top-level/all-packages.nix looks like that:

sigal = callPackage ../applications/misc/sigal { };

The important thing to know here is that nix run github:notashelf/neovim-flake automatically uses the apps.$system.default output (or, if that isn’t available, packages.$system.default. These are all equivalent (if you’re on x86_64-linux and in the case of this specific flake):

nix run github:notashelf/neovim-flake
nix run github:notashelf/neovim-flake#default
nix run github:notashelf/neovim-flake#apps.x86_64-linux.default
nix run github:notashelf/neovim-flake#packages.x86_64-linux.default

If you want to know what outputs are available, use nix flake show (output shortend for readability):

$ nix flake show github:notashelf/neovim-flake
│   ├───aarch64-darwin
│   │   ├───default: app
│   │   ├───maximal: app
│   │   └───nix: app
│   ├───aarch64-darwin
│   │   └───default: development environment 'nix-shell'
│   ├───aarch64-darwin: package 'alejandra-3.0.0'
├───homeManagerModules: unknown
│   ├───aarch64-darwin omitted (use '--legacy' to show)
├───lib: unknown
│   └───default: Nixpkgs overlay
    │   ├───default: package 'neovim-0.9.2'
    │   ├───docs: package 'html-manual'
    │   ├───docs-html: package 'html-manual'
    │   ├───docs-html-wrapped: package 'docs-html-wrapped'
    │   ├───docs-json: package 'options.json'
    │   ├───docs-manpages: package 'man-pages'
    │   ├───maximal: package 'neovim-0.9.2'
    │   └───nix: package 'neovim-0.9.2'

You can include the flake itself in your flake inputs:

  inputs = {
    notashelf-vim.url = "github:kamadorueda/alejandra";
    notashelf-vim.inputs.nixpkgs.follows = "nixpkgs";

  outputs = {
  }: {

And then add it to your configuration where you want. In your case, I’ll just extend the inline module:

      phantom = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
            environment.systemPackages = [

This is how you do it for most flakes. However, this would not allow you to modify the configuration! The neovim-flake has a very extensive set of options, and if you want to know how to use those, I would strongly recommand reading the “Custom Configuration” chapter in the neovim-flake manual.

1 Like

Thank you so much for this thoughtful answer :pray: . I learned a lot here.