From cd066313ca7c7ff293281162d0bbcaa5e15a0d01 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Wed, 12 Jun 2019 15:39:43 +0200 Subject: [PATCH] Drop null elements in sources.json --- app/Niv.hs | 14 +++++++++++++- tests/expected/niv-init.json | 1 - 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Niv.hs b/app/Niv.hs index 6dbed3e..7ea9d1e 100644 --- a/app/Niv.hs +++ b/app/Niv.hs @@ -91,7 +91,19 @@ newtype PackageSpec = PackageSpec { unPackageSpec :: Aeson.Object } -- | Simply discards the 'Freedom' attrsToSpec :: Attrs -> PackageSpec -attrsToSpec = PackageSpec . fmap snd +attrsToSpec = PackageSpec . dropNulls . fmap snd + where + dropNulls + :: HMS.HashMap T.Text Aeson.Value + -> HMS.HashMap T.Text Aeson.Value + dropNulls = HMS.mapMaybe $ \case + x@Aeson.Object{} -> Just x + x@Aeson.Array{} -> Just x + x@Aeson.String{} -> Just x + x@Aeson.Number{} -> Just x + x@Aeson.Bool{} -> Just x + Aeson.Null -> Nothing + parsePackageSpec :: Opts.Parser PackageSpec parsePackageSpec = diff --git a/tests/expected/niv-init.json b/tests/expected/niv-init.json index 13c149d..9bed571 100644 --- a/tests/expected/niv-init.json +++ b/tests/expected/niv-init.json @@ -1,6 +1,5 @@ { "nixpkgs": { - "homepage": null, "url": "http://localhost:3333/NixOS/nixpkgs-channels/archive/571b40d3f50466d3e91c1e609d372de96d782793.tar.gz", "owner": "NixOS", "branch": "nixos-18.09",