implement builtin for git fetcher
fixes #229
My biggest trouble with this is to make the gitUpdate function only update/write the hash attribute if builtin = false.
To realize this I'd require something like an IfThenElse :: Update a b -> Update a b -> Update (Bool, a) b.
I tried implementing this in multiple ways but always failed because of the limited abilities that runUpdate' exposes, which don't seem to enable (lazy) control flows.
I'm at the point where I'm beginning to doubt this can be fixed without overhauling the whole Update Arrow.
@nmattia maybe you have some idea to fix this?
@flandweber to clarify, the hash is only needed in the pkgs version because it's a fixed output derivation, though not needed in the builtin = true case, right?
I don't 100% remember how arrows work and to be honest I haven't written Haskell in years! But I seem to recall that while you can't change the structure (for some definition of structure) you should be able to update the value. This means you'd always write a hash value, but it may be null:
getHash :: IO T.Text
foo :: Update (Box Bool) (Box Aeson.Value)
foo = arr $ \builtin ->
Box
{ boxNew = boxNew builtin,
boxOp = do
useBuiltin <- boxOp builtin
if useBuiltin then pure Aeson.Null else Aeson.String <$> getHash
}
This somewhat typechecks, maybe that's something to investigate?
@flandweber to clarify, the hash is only needed in the
pkgsversion because it's a fixed output derivation, though not needed in thebuiltin = truecase, right?
yes, correct
I don't 100% remember how arrows work and to be honest I haven't written Haskell in years! But I seem to recall that while you can't change the structure (for some definition of structure) you should be able to update the value. This means you'd always write a hash value, but it may be
null:getHash :: IO T.Text foo :: Update (Box Bool) (Box Aeson.Value) foo = arr $ \builtin -> Box { boxNew = boxNew builtin, boxOp = do useBuiltin <- boxOp builtin if useBuiltin then pure Aeson.Null else Aeson.String <$> getHash }
You're right, I forgot there were null values.
However, from my understanding this would result in a hash attribute being added to sources.json even if buitlin = true.
I think it'd be much cleaner not to add any attributes that aren't needed.