[Nix-dev] removing null attrs in nix

Domen Kožar domen at dev.si
Tue Sep 13 10:18:07 CEST 2016


Sounds like you need
https://github.com/NixOS/nixpkgs/blob/master/lib/attrsets.nix#L108-L116

On Tue, Sep 13, 2016 at 10:04 AM, Matthew O'Gorman <mog at rldn.net> wrote:

> Hi I am working on a package and wanted to know the bet way to achieve
> this. i have an env variable like this
>
>   huginnEnv = {
>     GEM_HOME = gemHome;
>     BUNDLE_GEMFILE = "${cfg.packages.huginn}/share/huginn/Gemfile";
>     UNICORN_PATH = "${cfg.statePath}/";
>     HUGINN_PATH = "${cfg.packages.huginn}/share/huginn/";
>     HUGINN_STATE_PATH = "${cfg.statePath}";
>     HUGINN_UPLOADS_PATH = "${cfg.statePath}/uploads";
>     HUGINN_LOG_PATH = "${cfg.statePath}/log/huginn.log";
>     RAILS_ENV = "production";
>     LD_LIBRARY_PATH = "${pkgs.curl.out}/lib:${pkgs.postgresql}/lib";
>     DATABASE_ADAPTER = "postgresql";
>     RAILS_SERVE_STATIC_FILES = (if serve_static_files then "true" else "");
>     # I set this by hand because I wanted to maintain sessions between
> restarts.
>     #I totally know what I am doing security wise.
>     APP_SECRET_TOKEN=(if cfg.app_secret_token != "random" then
> cfg.app_secert_token else "");
>     DOMAIN=(if !cfg.enableUnicorn then cfg.host else "");
>     PORT=(if !cfg.enableUnicorn then toString cfg.port else "");
>   };
>
> I would like to take huginnEnv but prune out any of the Null results,
> "", so that I only set real variables no blank ones.  is there a way to
> filter on this? or mapttrs to list filter and then list to attrs is the
> simplest way?
>
> thanks
>
> --
> Matthew O'Gorman
> BM-NBUmia4p88Jny5bZbRGcMt64SWWp5WVv
> TorChat: 5w3dtk7nhkkijcpc
> Site: https://b.rldn.net
> Xim/Email: mog at rldn.net
> mog at rldn:~$ fortune wisdom -s|cowsay -f /dev/null
>  _______________________________________
> / You will always find something in the \
> \ last place you look.                  /
>  ---------------------------------------
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160913/646f45ef/attachment.html>


More information about the nix-dev mailing list