[Nix-dev] coerce a list of strings

Stefan Huchler stefan.huchler at mail.de
Tue Jul 26 22:14:39 CEST 2016


I wanted to shorten my configuration file a bit.
I have a long configuration for flexget with entries like that:


  yt_tech-talk-today:
    rss: http://feedpress.me/t3mob
    template: youtube


I can replace that with such let statement:

  ${let 
      makeFeed = { name, url}:
      { x = "  yt_$name:\n   rss: $url\n    template: youtube";}.x;
    in makeFeed
      { name = "tech-talk-today"; url = "http://feedpress.me/t3mob"; }
  }

but now I wanted to use the map function to map more than one entry like
that:

  ${let 
      makeFeed = { name, url}:
      { x = "  yt_$name:\n   rss: $url\n    template: youtube";}.x;
    in map makeFeed
      [ { name = "tech-talk-today"; url = "http://feedpress.me/t3mob"; }]
  }

which did not work cause it generates a list of strings what it cant
"coerce" to a string:

error: cannot coerce a list to a string

Now I thought there is maybe some sort of concat function or merge
function to build out of this list ONE stirng so it works.

Either this api is very limited or not very well documented, some github
nix packages seem to imply or list a concat function, but it seems to
not work or I dont understand this language very well.

wrapping that in a ${concat { let... } at least seems to not work, any
suggestions?




More information about the nix-dev mailing list