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
:
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
github:notashelf/neovim-flake/897493a65f8a3a84fab7229658a9ffa92fa021bc
├───apps
│ ├───aarch64-darwin
│ │ ├───default: app
│ │ ├───maximal: app
│ │ └───nix: app
[…]
├───devShells
│ ├───aarch64-darwin
│ │ └───default: development environment 'nix-shell'
[…]
├───formatter
│ ├───aarch64-darwin: package 'alejandra-3.0.0'
[…]
├───homeManagerModules: unknown
├───legacyPackages
│ ├───aarch64-darwin omitted (use '--legacy' to show)
[…]
├───lib: unknown
├───overlays
│ └───default: Nixpkgs overlay
└───packages
├───aarch64-darwin
│ ├───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'
├───aarch64-linux
[…]
You can include the flake itself in your flake inputs:
inputs = {
notashelf-vim.url = "github:kamadorueda/alejandra";
notashelf-vim.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
nixpkgs,
nixos-hardware,
home-manager,
alejandra,
notashelf-vim,
...
}: {
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 = [
alejandra.defaultPackage.x86_64-linux
notashelf-vim.packages.x86_64-linux.default
];
}
];
};
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.