Disko-install: how to to pass flake `self` using `specialArgs`?

disko-install example for a NixOS installer has a comment:

self here is referring to the flake self, you may need to pass it using specialArgs or define your NixOS installer configuration in the flake.nix itself to get direct access to the self flake variable.

Could someone clarify how do I do that, please?

I opened an issue but the maintainer doesn’t seem very responsive:


@NobbZ blog post lists all the options, you want the second one: Getting inputs to modules in a nix-flake | NobbZ' Blog


so regarding my sample,
should I insert something like specialArgs = {inherit self;}; to the flake?:

Given that exact example, like so:

  nixosConfigurations.your-machine = inputs.nixpkgs.lib.nixosSystem {
    system = "x86_64-linux";
    specialArgs = {inherit self;};
    modules = [
        # TODO: add your NixOS configuration here, don't forget your hardware-configuration.nix as well!
        boot.loader.systemd-boot.enable = true;
        imports = [ self.inputs.disko.nixosModules.disko ];
        disko.devices = {
          disk = {
            vdb = {
              device = "/dev/disk/by-id/some-disk-id";
              type = "disk";
              content = {
                type = "gpt";
                partitions = {
                  ESP = {
                    type = "EF00";
                    size = "500M";
                    content = {
                      type = "filesystem";
                      format = "vfat";
                      mountpoint = "/boot";
                  root = {
                    size = "100%";
                    content = {
                      type = "filesystem";
                      format = "ext4";
                      mountpoint = "/";

Personally I’d break out the disko configuration into a separate file though. I should do a NixOS book on NixOS configuration architecture at some point.


FWIW, my flake and disko config shows inheriting self actually as one of the outputs

outputs = inputs@{

and then

vps  = nixpkgs-stable.lib.nixosSystem {
        specialArgs = {
          inherit inputs outputs;
        modules = [

The same effect as @TLATER showed, just re-organized a bit.

@TLATER - you should definitely write that book on NixOS configuration! It’s overwhelming as a newcomer how many different ways there are to organize. Especially when your grasp of the Nix language is shaky at best!

1 Like

Seems I got an error: infinite recursion encountered after adding the separated configuration, could you have a look?
I’m not sure if I’m doing everything right:

I’m still struggling with the problem above but think we can close this thread.
Thank you for your help!

It’s sad Nix community doesn’t seem responsive, apparently… (spent few days already without any support)

The issues you linked to indicate that you got responses on the first day by one of the maintainers in each case; considering that’s all volunteer work, I am not sure it’s fair to qualify this as “without any support”.

There was some support, sure, and I appreciate it.
But it’s not enough at all.
I’m spending enormous amount of time without even moving forward a bit, obviously I just misunderstanding some things, I’m trying hard but I need help.

It’s not my fault the documentation is bad and inconsistent.
It’s something I could help with eventually but first I need to get some success with my efforts.

Thank you for your understanding.