[Nix-dev] removing null attrs in nix

Matthew O'Gorman mog at rldn.net
Tue Sep 13 10:04:36 CEST 2016


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.                  /
 --------------------------------------- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 800 bytes
Desc: not available
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160913/a07bf007/attachment.sig>


More information about the nix-dev mailing list