mirror of
https://github.com/nix-community/nixpkgs-update.git
synced 2024-11-25 09:34:13 +03:00
wip
This commit is contained in:
parent
c78b63b443
commit
90352bd289
34
src/Package.hs
Normal file
34
src/Package.hs
Normal file
@ -0,0 +1,34 @@
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
|
||||
module Package where
|
||||
|
||||
import OurPrelude
|
||||
|
||||
import qualified Database.SQLite.Simple as SQL
|
||||
import qualified Utils
|
||||
|
||||
data Package = Package
|
||||
{ attrPath :: Text
|
||||
, targetVersion :: Utils.Version
|
||||
, tried :: Bool
|
||||
}
|
||||
deriving (Show, Eq, Ord)
|
||||
|
||||
instance SQL.FromRow Package where
|
||||
fromRow = do
|
||||
attrPath <- SQL.field
|
||||
targetVersion <- SQL.field
|
||||
tried <- SQL.field
|
||||
pure Package {..}
|
||||
|
||||
getDBPath :: IO FilePath
|
||||
getDBPath = do
|
||||
cacheDir <- Utils.cacheDir
|
||||
pure $ cacheDir </> "package.sqlite3"
|
||||
|
||||
withDB :: (SQL.Connection -> IO a) -> IO a
|
||||
withDB action = do
|
||||
dbPath <- getDBPath
|
||||
SQL.withConnection dbPath action
|
Loading…
Reference in New Issue
Block a user