Allow missing keys in appendContext
This commit is contained in:
parent
a25c01b218
commit
45400aae58
|
@ -1147,15 +1147,17 @@ appendContext x y = x >>= \x' -> y >>= \y' -> case (x', y') of
|
|||
(NVStr ns, NVSet attrs _) -> do
|
||||
let context = toNixLikeContext $ principledGetContext ns
|
||||
newContextValues <- forM attrs $ force' >=> \case
|
||||
NVSet (M.toList -> [("allOutputs", allOutputs), ("outputs", outputs), ("path", path)]) _ -> do
|
||||
outputsV <- force' outputs >>= \case
|
||||
NVList vs -> forM vs $ fmap principledStringIgnoreContext . fromNix
|
||||
x -> throwError $ ErrorCall $
|
||||
"Invalid types for context value outputs in builtins.appendContext: " ++ show x
|
||||
NixLikeContextValue
|
||||
<$> fromValue path
|
||||
<*> fromValue allOutputs
|
||||
<*> pure outputsV
|
||||
NVSet attrs _ -> do
|
||||
-- TODO: Fail for unexpected keys.
|
||||
path <- maybe (return False) fromValue $ M.lookup "path" attrs
|
||||
allOutputs <- maybe (return False) fromValue $ M.lookup "allOutputs" attrs
|
||||
outputs <- case M.lookup "outputs" attrs of
|
||||
Nothing -> return []
|
||||
Just os -> force' os >>= \case
|
||||
NVList vs -> forM vs $ fmap principledStringIgnoreContext . fromNix
|
||||
x -> throwError $ ErrorCall $
|
||||
"Invalid types for context value outputs in builtins.appendContext: " ++ show x
|
||||
return $ NixLikeContextValue path allOutputs outputs
|
||||
x -> throwError $ ErrorCall $
|
||||
"Invalid types for context value in builtins.appendContext: " ++ show x
|
||||
values :: AttrSet (NThunk m) <- traverse (fmap valueThunk . toValue) $
|
||||
|
|
Loading…
Reference in a new issue