Skip to content

Commit

Permalink
Update nixpkgs & macos (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmattia authored Nov 25, 2023
1 parent 723f0ee commit 7b76374
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
tests:
strategy:
matrix:
os: [ubuntu-20.04, macos-11]
os: [ubuntu-20.04, macos-12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"homepage": null,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5d6d90c3bf3d95902427c64dae883715de1fae19",
"sha256": "027l7f1533wb8cb55dq11dfvkpi48s5m15cq3aj0f84m715682vn",
"rev": "41e7ce9a0a29b26e5ca97fd0a4bd85765ed8f9ac",
"sha256": "1gp9qwyqwfv8x8k8rj11w7ajlb96a9njxsb5vg14dzadhn97slrc",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5d6d90c3bf3d95902427c64dae883715de1fae19.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/41e7ce9a0a29b26e5ca97fd0a4bd85765ed8f9ac.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"termtosvg": {
Expand Down
4 changes: 2 additions & 2 deletions src/Data/Text/Extended.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import Niv.Logger
import System.Exit (exitFailure)
import UnliftIO

tshow :: Show a => a -> T.Text
tshow :: (Show a) => a -> T.Text
tshow = T.pack . show

-- not quite the perfect place for this
abort :: MonadIO io => T.Text -> io a
abort :: (MonadIO io) => T.Text -> io a
abort msg = do
tsay $ T.unwords [tbold $ tred "FATAL:", msg]
liftIO exitFailure
7 changes: 4 additions & 3 deletions src/Niv/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ instance MonadUnliftIO NIO where
getFindSourcesJson :: NIO FindSourcesJson
getFindSourcesJson = ask

li :: MonadIO io => IO a -> io a
li :: (MonadIO io) => IO a -> io a
li = liftIO

cli :: IO ()
Expand All @@ -72,7 +72,8 @@ cli = do
Just $
"niv - dependency manager for Nix projects"
Opts.<$$> ""
Opts.<$$> "version:" Opts.<+> Opts.text (showVersion version)
Opts.<$$> "version:"
Opts.<+> Opts.text (showVersion version)
]
parseFindSourcesJson =
AtPath
Expand Down Expand Up @@ -394,7 +395,7 @@ cmdShow = \case
sources <- unSources <$> li (getSources fsj)
forWithKeyM_ sources $ showPackage

showPackage :: MonadIO io => PackageName -> PackageSpec -> io ()
showPackage :: (MonadIO io) => PackageName -> PackageSpec -> io ()
showPackage (PackageName pname) (PackageSpec spec) = do
tsay $ tbold pname
forM_ (KM.toList spec) $ \(attrName, attrValValue) -> do
Expand Down
4 changes: 2 additions & 2 deletions src/Niv/Git/Cmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ parseGitShortcut txt'@(T.dropWhileEnd (== '/') -> txt) =
".git"
`T.isSuffixOf` txt
|| "git@"
`T.isPrefixOf` txt
`T.isPrefixOf` txt
|| "ssh://"
`T.isPrefixOf` txt
`T.isPrefixOf` txt

parseGitPackageSpec :: Opts.Parser PackageSpec
parseGitPackageSpec =
Expand Down
8 changes: 4 additions & 4 deletions src/Niv/Logger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,18 @@ job str act = do
indent = void $ atomicModifyIORef jobStack (\x -> (x + 1, undefined))
deindent = void $ atomicModifyIORef jobStack (\x -> (x - 1, undefined))

jobStackSize :: MonadIO io => io Int
jobStackSize :: (MonadIO io) => io Int
jobStackSize = readIORef jobStack

jobStack :: IORef Int
jobStack = unsafePerformIO $ newIORef 0

{-# NOINLINE jobStackSize #-}

tsay :: MonadIO io => T.Text -> io ()
tsay :: (MonadIO io) => T.Text -> io ()
tsay = say . T.unpack

say :: MonadIO io => String -> io ()
say :: (MonadIO io) => String -> io ()
say msg = do
stackSize <- jobStackSize
let indent = replicate (stackSize * 2) ' '
Expand All @@ -102,7 +102,7 @@ say msg = do
mkWarn :: T.Text -> T.Text
mkWarn w = tbold (tyellow "WARNING") <> ": " <> w

twarn :: MonadIO io => T.Text -> io ()
twarn :: (MonadIO io) => T.Text -> io ()
twarn = tsay . mkWarn

mkNote :: T.Text -> T.Text
Expand Down
12 changes: 6 additions & 6 deletions src/Niv/Update.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ instance Applicative Box where
boxOp = boxOp f <*> boxOp v
}

instance Semigroup a => Semigroup (Box a) where
instance (Semigroup a) => Semigroup (Box a) where
(<>) = liftA2 (<>)

instance IsString (Box T.Text) where
Expand Down Expand Up @@ -283,10 +283,10 @@ runUpdate' attrs = \case
Nothing -> pure $ UpdateFailed $ FailTemplate v' (HMS.keys attrs)
Just v'' -> pure $ UpdateSuccess attrs (v'' <* v) -- carries over v's newness

decodeBox :: FromJSON a => T.Text -> Box Value -> Box a
decodeBox :: (FromJSON a) => T.Text -> Box Value -> Box a
decodeBox msg v = v {boxOp = boxOp v >>= decodeValue msg}

decodeValue :: FromJSON a => T.Text -> Value -> IO a
decodeValue :: (FromJSON a) => T.Text -> Value -> IO a
decodeValue msg v = case Aeson.fromJSON v of
Aeson.Success x -> pure x
Aeson.Error str ->
Expand All @@ -313,17 +313,17 @@ template = Template
check :: (a -> Bool) -> Update (Box a) ()
check = Check

load :: FromJSON a => T.Text -> Update () (Box a)
load :: (FromJSON a) => T.Text -> Update () (Box a)
load k = Load k >>> arr (decodeBox $ "When loading key " <> k)

-- TODO: should input really be Box?
useOrSet :: JSON a => T.Text -> Update (Box a) (Box a)
useOrSet :: (JSON a) => T.Text -> Update (Box a) (Box a)
useOrSet k =
arr (fmap Aeson.toJSON)
>>> UseOrSet k
>>> arr (decodeBox $ "When trying to use or set key " <> k)

update :: JSON a => T.Text -> Update (Box a) (Box a)
update :: (JSON a) => T.Text -> Update (Box a) (Box a)
update k =
arr (fmap Aeson.toJSON)
>>> Update k
Expand Down

0 comments on commit 7b76374

Please sign in to comment.