Problem getting modularity setup

Having the ‘flake.nix’ file:

  description = "My first flake!";

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

  outputs = {self, nixpkgs, home-manager, ... }:
      lib = nixpkgs.lib;
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in  {
    nixosConfigurations = {
      nixbox-stable-01 = lib.nixosSystem {
        inherit system;
        modules = [
          # adding new file here causes problem
    homeConfigurations = {
      chris = home-manager.lib.homeManagerConfiguration {
        inherit pkgs;
        modules = [ ./home.nix ];

Executing the command

sudo nixos-rebuild switch --flake .

works fine, until I add a new file to the modules section in nixosConfigurations. I then get the error

error: getting status of '/nix/store/jwjl7ivjcfiv7jw8rq2hb5nadywgdxi7-source/graphical.nix': No such file or directory

Any suggestions on what I’m doing wrong here?


Hey there and welcome to Nix!

It looks like your file graphical.nix isn’t tracked yet by Git. With Flakes, any untracked files are ignored.

So, try

git add graphical.nix

and rebuild again.

1 Like

Unrelated, but are you sure that it’s with flakes only? AFAIK it’s a general thing with Nix when paired with Git.

Hey, thanks for the welcome and the hint!

You’re right, that was the issue, it works now :slightly_smiling_face: