Frusterating error when printing a list to file via home.file

I have an error I cant figure out. In my home manager files I have defined:

options = {
    tekslice.home.info.cliApps = lib.mkOption {
      type = lib.types.listOf;
      default = [];
    };
};

Then elsewhere I have:

config = {
    tekslice.home.info.cliApps = [ "yazi" ];
    programs.yazi = {
      enable = lib.mkDefault true;
    };
};

and

config = lib.mkIf config.tekslice.home.shell.fish.enable {
    tekslice.home.info.cliApps = [ "fish" ];
    programs.fish = {
      enable = lib.mkDefault config.tekslice.home.shell.fish.enable;
    };
};

and

home.file = {
      ".config/info/installed_cli_apps.txt".text = ''
        ${config.tekslice.home.info.cliApps};
      '';
 };

However when I try to apply the config I get:

evaluating derivation 'git+file:///home/matthew/Git/nix-files#homeConfigurations."merror:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'home-manager-generation'
         whose name attribute is located at /nix/store/apfqvr9kddcl6fscjvb92p4xdrqzcwk0-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'
         at /nix/store/apfqvr9kddcl6fscjvb92p4xdrqzcwk0-source/pkgs/build-support/trivial-builders/default.nix:59:17:
           58|         enableParallelBuilding = true;
           59|         inherit buildCommand name;
             |                 ^
           60|         passAsFile = [ "buildCommand" ]

       … while evaluating the option `home.file.".config/info/installed_cli_apps.txt".source':

       … while evaluating definitions from `/nix/store/548acnkylzwsxfjd4l5g7yfmli77199b-source/modules/files.nix':

       … while evaluating the option `home.file.".config/info/installed_cli_apps.txt".text':

       … while evaluating definitions from `/nix/store/5izr1fm6cw1c9j1a2rwp3132ycdcnrh9-source/home-manager/common/cli/default.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: expected a set but found a function: «lambda listOf @ /nix/store/apfqvr9kddcl6fscjvb92p4xdrqzcwk0-source/lib/types.nix:564:14»

I have tried assigning “config.tekslice.home.info.cliApps” to a variable in a let binding and putting ${the-variable} in the text block but it gives the same error. Everything I find online says this should work, but im stumped.

The type definition of your tekslice.home.info.cliApps option is incomplete. You have listOf but didn’t specify what type of values the list should contain. So that should probably be lib.types.listOf lib.types.str.

I did overlook that, although now its a new error:

error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:34:12:
           33|
           34|   strict = derivationStrict drvAttrs;
             |            ^
           35|

       … while evaluating derivation 'home-manager-generation'
         whose name attribute is located at /nix/store/apfqvr9kddcl6fscjvb92p4xdrqzcwk0-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'
         at /nix/store/apfqvr9kddcl6fscjvb92p4xdrqzcwk0-source/pkgs/build-support/trivial-builders/default.nix:59:17:
           58|         enableParallelBuilding = true;
           59|         inherit buildCommand name;
             |                 ^
           60|         passAsFile = [ "buildCommand" ]

       … while evaluating the option `home.file.".config/info/installed-cli-apps.txt".source':

       … while evaluating definitions from `/nix/store/548acnkylzwsxfjd4l5g7yfmli77199b-source/modules/files.nix':

       … while evaluating the option `home.file.".config/info/installed-cli-apps.txt".text':

       … while evaluating definitions from `/nix/store/rc2ljjrsjwrnx07bkg1hi55wrqfpnby6-source/home-manager/common/cli/default.nix':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: cannot coerce a list to a string: [ «thunk» «thunk» ]

Im curious if its because “config.tekslice.home.info.cliApps” is a list and I need to convert or transform it from being an actual list to just strings…?

I fixed the error by changing my code to:

home.file = {
  ".config/info/installed-cli-apps.txt".text = ''
    ${lib.concatStrings (lib.intersperse "\n" config.tekslice.home.info.cliApps)};
  '';
};

Which currently yield a file with the contents of:

yazi
fish;

So now I just need to figure out how to drop the trailing semicolon.

home.file = {
  ".config/info/installed-cli-apps.txt".text = ''
    ${lib.concatStrings (lib.intersperse "\n" config.tekslice.home.info.cliApps)};
''; # you're looking for this ---------------------------------------------------^

Lol, yup I just found it and was coming back to post. Ultimately changed that line to:

${lib.concatLines config.tekslice.home.info.cliApps}

Thanks everyone that took the time to offer advice.

Final working block:

    home.file = {
      ".config/info/installed-cli-apps.txt".text = ''
        ${lib.concatLines config.tekslice.home.info.cliApps}
      '';
    };