Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flakes? #60

Open
nomeata opened this issue Feb 20, 2023 · 4 comments
Open

flakes? #60

nomeata opened this issue Feb 20, 2023 · 4 comments

Comments

@nomeata
Copy link

nomeata commented Feb 20, 2023

I am quite fond of the niv / niv-update-action combination, but it seems that the Nix world is moving to flakes, which replaces niv.

So I wonder if there is a flake-update-action that is on-par with niv-update-action (e.g. the changelog handling etc)?

Opening this issue mostly as a place for me and others to find links to other projects; I’m not actually suggesting that niv-updater-action learns about flakes (although, why not?)

@knl
Copy link
Owner

knl commented Feb 21, 2023

Hi @nomeata that's a good question! I've been thinking of making a copy of this repo and adapting it to work with flakes, but I don't use flakes, so can't dedicate a lot of time to it. I saw that some people tried taking that path, but abandoned the project.

@nomeata
Copy link
Author

nomeata commented Feb 21, 2023

Yes, if you don’t use them yourself, I wouldn’t expect you to create that project. Let’s see how long it takes until you don’t get around flakes anymore either :-D.

Or alternatively niv could become flake-aware and keep it's nice UI, but simply edit the flake.lock instead of the sources.json transparently – WDYT, @nmattia :-)

@nmattia
Copy link
Collaborator

nmattia commented Feb 23, 2023

Or alternatively niv could become flake-aware and keep its nice UI

PRs welcome :) might just be a matter of updating setSources and getSources in this file:

getSourcesEither :: FindSourcesJson -> IO (Either SourcesError Sources)
getSourcesEither fsj = do
  Dir.doesFileExist (pathNixSourcesJson fsj) >>= \case
    False -> pure $ Left SourcesDoesntExist
    True ->
      Aeson.decodeFileStrict (pathNixSourcesJson fsj) >>= \case
        Just value -> case valueToSources value of
          Nothing -> pure $ Left SpecIsntAMap
          Just srcs -> pure $ Right srcs
        Nothing -> pure $ Left SourceIsntJSON
  where
    valueToSources :: Aeson.Value -> Maybe Sources
    valueToSources = \case
      Aeson.Object obj ->
        fmap (Sources . mapKeys PackageName . KM.toHashMapText) $
          traverse
            ( \case
                Aeson.Object obj' -> Just (PackageSpec obj')
                _ -> Nothing
            )
            obj
      _ -> Nothing
    mapKeys :: (Eq k2, Hashable k2) => (k1 -> k2) -> HMS.HashMap k1 v -> HMS.HashMap k2 v
    mapKeys f = HMS.fromList . map (first f) . HMS.toList

if you can decode the flake lock in a way that maps to Sources, that should work seamlessly!

@nomeata
Copy link
Author

nomeata commented Feb 28, 2023

There is also https://github.com/DeterminateSystems/update-flake-lock which might be an alternative. (I’ve opened DeterminateSystems/update-flake-lock#65 to see if they would be interested in adding the changelog listing feature)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants