Failed assertions: Conflicting managed target files

Hi - long time lurker, first time poster :slight_smile:

Been on a grind to declaratively configure my machines with Nix. It’s been an interesting experience with its ups and downs. But otherwise seems worthwhile if I want to keep similar development environments across my machines without having to reference old notes and pollute my development environment.

Anyways, I am using nix flakes with these other modules/flakes/dependencies/inputs:

# flake.nix
...
    nixpkgs = {
      url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    };
    nix-darwin = {
      url = "github:nix-darwin/nix-darwin/master";
      inputs = {
        nixpkgs = {
          follows = "nixpkgs";
        };
      };
    };
    nix-homebrew = {
      url = "github:zhaofengli/nix-homebrew";
    };
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs = {
        nixpkgs = {
          follows = "nixpkgs";
        };
      };
    };
    nix4nvchad = {
      url = "github:nix-community/nix4nvchad";
      inputs = {
        nixpkgs = {
          follows = "nixpkgs";
        };
      };
    };
    homebrew-core = {
      url = "github:homebrew/homebrew-core";
      flake = false;
    };
    homebrew-cask = {
      url = "github:homebrew/homebrew-cask";
      flake = false;
    };
    catppuccin = {
      url = "github:catppuccin/nix";
    };
...
     darwinConfigurations."machine" = nix-darwin.lib.darwinSystem {
        modules = [
          configuration
          ./machines/machine
          nix-homebrew.darwinModules.nix-homebrew
          {
            nix-homebrew = {
              enable = true;
              enableRosetta = true;
              user = "me";
              taps = {
                "homebrew/homebrew-core" = homebrew-core;
                "homebrew/homebrew-cask" = homebrew-cask;
              };
              mutableTaps = false;
            };
          }
          home-manager.darwinModules.home-manager
          {
            home-manager = {
              inherit extraSpecialArgs;
              useUserPackages = true;
              users = {
                "me" = {
                  imports = [
                    ./modules
                    nix4nvchad.homeManagerModule
                    catppuccin.homeModules.catppuccin
                  ];
                };
              };
            };
          }
        ];
      };
    };

Then in a home manager module …

# spotify-player.nix

{ config, ... }:
{
  home = {
    file = {
      ".config/spotify-player/app.toml" = {
        enable = true;
        text = ''
          client_id = "..."
        '';
      };
    };
  };

  programs = {
    spotify-player = {
      enable = true;
    };
  };
  catppuccin = {
    spotify-player = {
      enable = true;
      flavor = "mocha";
    };
  };

}

This ends up throwing a failed assertion error on darwin-rebuild switch --flake ...

       error:
       Failed assertions:
       - me profile: Conflicting managed target files: .config/spotify-player/app.toml

       This may happen, for example, if you have a configuration similar to

           home.file = {
             conflict1 = { source = ./foo.nix; target = "baz"; };
             conflict2 = { source = ./bar.nix; target = "baz"; };
           }
error: Recipe `rebuild` failed on line 16 with exit code 1

It’s resolved by setting home.file.".config/spotify-player/app.toml".enable to false which allows the catppuccin home manager module to take over management of this file.

What I want to know:

  • Is it possible to “merge” or concatenate my changes to this file using nix?

at least for this program, spotify-player, it exposes programs.spotify-player.settings [1] which then plays nicely with catppuccin configuration updates of that same file

[1] Home Manager - Option Search

1 Like