Updating inputs without `nix flake update`

I have a home-manager flake that I use that exposes a NixOS module for consumption:

# home-manager flake
  outputs =
    {
      .
      .
      .
      nixosModules.home-manager = {
        imports = [ home-manager.nixosModules.home-manager ];
        home-manager.users.refaelsh = import ./home.nix;
      };
      .
      .
      .
    };

I consume it in my NixOS flake like this:

modules = [
  ./nixos/configuration.  
  inputs.home-manager.nixosModules.home-manager
];

The question is: when ever I change my home-manager config and rebuild NixOS, the changes are not taking effect. I need to do nix flake update and then rebuild NixOS, and only then the changes will take effect.
I want to avoid running nix flake update because it will update the lock files of all the flakes and I might wait a while for the NixOS rebuilding to finish if there were many changes in various flakes. Also, I want to run nix flake update as less frequently as possible.

I think this should be inputs.self.nixosModules.home-manager

If I do that, I get the following error: error: attribute 'nixosModules' missing.

This should be a function too, can you show us the entire flake.nix?

Sure.

{
  description = "Standalone Home Manager configuration";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    wezterm.url = "github:wez/wezterm?dir=nix";
  };

  outputs =
    {
      self,
      nixpkgs,
      home-manager,
      ...
    }@inputs:
    {
      nixosModules.home-manager = {
        imports = [ home-manager.nixosModules.home-manager ];
        home-manager.users.refaelsh = import ./home.nix;
      };

      homeConfigurations = {
        specialArgs = {
          inherit inputs;
        };

        standalone = home-manager.lib.homeManagerConfiguration {
          pkgs = nixpkgs.legacyPackages.x86_64-linux;
          extraSpecialArgs = {
            inherit inputs;
          };
          modules = [
            ./home.nix
          ];
        };
      };

      packages.x86_64-linux.default = self.homeConfigurations.standalone.activationPackage;
    };
}

Afaik, what. You request is not how flake inputs work. It’s one of the base idea that they go to the lock file, if I understand them correctly.

Tho there is a command to not update every input but specific ones. Maybe that is an acceptable solution.

When you run nix flake lock --update-input <input name> l (typed from smartphone and I am not 100% sure if it is correct, so give it a short cross check in the man or help pages)

On nix 2.19+ it’s now nix flake update <input name> but you’re correct for 2.18 and below.
Though, if they’re trying to use an output from the same flake, then updating the lockfile shouldn’t be necessary :thinking:

@refaelsh where exactly are you consuming the module? is it in the same flake or somewhere else?

Its a home-manager flake that is on my hard drive. I am consuming it in my NixOS flake.

The dotfiles are here: GitHub - refaelsh/dotfiles.

Ok, so separate flakes.
In that case, you can simply update the single input by follow shawn’s answer (or mine, depending on which version of nix you use.)
Alternatively you can use -- --override-input home-manager /path/to/home-manager if you want a quick-and-dirty way to test out changes without having to update the lockfile each time.

This local home-manager flake is not the only input to my NixOS flake.
What you are suggesting is, that every time I make a change in one of the inputs I need to think what input to update before rebuilding NixOS. This is very clunky.

It’s not in the same flake, how else will nix know what new code you want to pull in or not unless you update the input?

That’s how lockfiles work in any language…

1 Like

That’s how lockfiles work in any language…

Ok, when you put it like this, I get it :slight_smile: