Skip to content

Commit

Permalink
Builtins: add unsafeDiscardOutputDependency
Browse files Browse the repository at this point in the history
Courtesy of `layus`, ported from implementation in
haskell-nix#755.
  • Loading branch information
Anton-Latukha committed Jan 17, 2022
1 parent 4ca4b94 commit 49bce28
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Nix/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import Data.Char ( isDigit )
import Data.Foldable ( foldrM )
import Data.Fix ( foldFix )
import Data.List ( partition )
import qualified Data.HashSet as HS
import qualified Data.HashMap.Lazy as M
import Data.Scientific
import qualified Data.Set as S
Expand Down Expand Up @@ -471,6 +472,20 @@ getAttrNix x y =

attrsetGet key aset

unsafeDiscardOutputDependencyNix
:: forall e t f m
. MonadNix e t f m
=> NValue t f m
-> m (NValue t f m)
unsafeDiscardOutputDependencyNix nv =
do
(nc, ns) <- (getStringContext &&& ignoreContext) <$> fromValue nv
toValue $ mkNixString (HS.map discard nc) ns
where
discard :: StringContext -> StringContext
discard (StringContext AllOutputs a) = StringContext DirectPath a
discard x = x

unsafeGetAttrPosNix
:: forall e t f m
. MonadNix e t f m
Expand Down Expand Up @@ -1906,7 +1921,7 @@ builtinsList =
, add0 Normal "true" (pure $ mkNVBool True)
, add Normal "tryEval" tryEvalNix
, add Normal "typeOf" typeOfNix
--, add0 Normal "unsafeDiscardOutputDependency" unsafeDiscardOutputDependency
, add Normal "unsafeDiscardOutputDependency" unsafeDiscardOutputDependencyNix
, add Normal "unsafeDiscardStringContext" unsafeDiscardStringContextNix
, add2 Normal "unsafeGetAttrPos" unsafeGetAttrPosNix
, add Normal "valueSize" getRecursiveSizeNix
Expand Down

0 comments on commit 49bce28

Please sign in to comment.