packages feed

nix-freeze-tree 0.1.0.0 → 0.1.0.1

raw patch · 4 files changed

+88/−79 lines, 4 filesdep +cryptonitedep +path-iodep −binarydep ~hnixdep ~hnix-store-core

Dependencies added: cryptonite, path-io

Dependencies removed: binary

Dependency ranges changed: hnix, hnix-store-core

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for nix-freeze-tree +## 0.1.0.1 -- 2021-11-01++* Support `hnix-store-core ^>=0.14.0.1` and `hnix ^>=0.5`+ ## 0.1.0.0 -- 2020-01-25  * First version. Released on an unsuspecting world.
nix-freeze-tree.cabal view
@@ -1,73 +1,83 @@-cabal-version:       2.2--name:                nix-freeze-tree-version:             0.1.0.0-synopsis:            Convert a tree of files into fixed-output derivations+cabal-version:      2.2+name:               nix-freeze-tree+version:            0.1.0.1+synopsis:           Convert a tree of files into fixed-output derivations description:   @nix-freeze-tree@ walks a directory tree and generates a tree of Nix   expressions that recreate the tree from fixed-output derivations,   one derivation per file in the source tree. See @README.md@ to get   started.-homepage:            https://git.sr.ht/~jack/nix-freeze-tree-bug-reports:         https://todo.sr.ht/~jack/nix-freeze-tree-license:             AGPL-3.0-or-later-license-file:        LICENSE-author:              Jack Kelly-maintainer:          jack@jackkelly.name-copyright:           (c) 2020 Jack Kelly-category:            Application, Nix-build-type:          Simple-extra-source-files:  CHANGELOG.md, README.md-tested-with:         GHC == 8.6.5 +homepage:           https://git.sr.ht/~jack/nix-freeze-tree+bug-reports:        https://todo.sr.ht/~jack/nix-freeze-tree+license:            AGPL-3.0-or-later+license-file:       LICENSE+author:             Jack Kelly+maintainer:         jack@jackkelly.name+copyright:          (c) 2020 Jack Kelly+category:           Application, Nix+build-type:         Simple+extra-source-files:+  CHANGELOG.md+  README.md++tested-with:        GHC ==8.10.2+ executable nix-freeze-tree-  hs-source-dirs:     bin-  main-is:            Main.hs-  default-language:   Haskell2010-  ghc-options:        -Wall -threaded-  build-depends:      base-                    , nix-freeze-tree-internal+  hs-source-dirs:   bin+  main-is:          Main.hs+  default-language: Haskell2010+  ghc-options:      -Wall -threaded+  build-depends:+    , base+    , nix-freeze-tree-internal  library nix-freeze-tree-internal-  hs-source-dirs:     src-  exposed-modules:    BuilderDirs-                    , Config-                    , NixBuilder-                    , NixFreezeTree-                    , NixHash-  other-modules:      Paths_nix_freeze_tree-  autogen-modules:    Paths_nix_freeze_tree-  default-language:   Haskell2010-  ghc-options:        -Wall-  build-depends:      base >= 4.9 && < 4.14-                    , binary >= 0.8.6.0 && < 0.9-                    , bytestring >= 0.10.8.2 && < 0.11-                    , data-fix >= 0.2.0 && < 0.3-                    , directory >= 1.3.3.0 && < 1.4-                    , directory-tree >= 0.12.1 && < 0.13-                    , hnix >= 0.6.1 && < 0.7-                    , hnix-store-core >= 0.1.0.0 && < 0.2-                    , optparse-applicative >= 0.14.3.0 && < 0.15-                    , path >= 0.6.1 && < 0.7-                    , prettyprinter >= 1.2.1.1 && < 1.3-                    , raw-strings-qq >= 1.1 && < 1.2-                    , text >= 1.2.3.1 && < 1.3-                    , transformers >= 0.5.6.2 && < 0.6+  hs-source-dirs:   src+  exposed-modules:+    BuilderDirs+    Config+    NixBuilder+    NixFreezeTree+    NixHash +  other-modules:    Paths_nix_freeze_tree+  autogen-modules:  Paths_nix_freeze_tree+  default-language: Haskell2010+  ghc-options:      -Wall+  build-depends:+    , base                  >=4.9      && <4.17+    , bytestring            >=0.10.8.2 && <0.12+    , cryptonite            >=0.28     && <0.30+    , data-fix              >=0.2.0    && <0.4+    , directory             ^>=1.3.3.0+    , directory-tree        ^>=0.12.1+    , hnix                  ^>=0.14.0.1+    , hnix-store-core       ^>=0.5+    , optparse-applicative  >=0.14.3.0 && <0.17+    , path                  >=0.6.1    && <0.10+    , path-io               ^>=1.6+    , prettyprinter         >=1.2.1.1  && <1.8+    , raw-strings-qq        ^>=1.1+    , text                  ^>=1.2.3.1+    , transformers          >=0.5.6.2  && <0.7+ test-suite nix-freeze-tree-tests-  type:                exitcode-stdio-1.0-  main-is:             Main.hs-  other-modules:       ConfigTest-  ghc-options:         -Wall -threaded-  build-depends:       base-                     , HUnit >= 1.6.0.0 && < 1.7-                     , nix-freeze-tree-internal-                     , optparse-applicative-                     , tasty >= 1.2.3 && < 1.3-                     , tasty-discover >= 4.2.1 && < 4.3-                     , tasty-hunit >= 0.10.0.2 && < 0.11-  hs-source-dirs:      test-  default-language:    Haskell2010+  type:             exitcode-stdio-1.0+  main-is:          Main.hs+  other-modules:    ConfigTest+  ghc-options:      -Wall -threaded+  build-depends:+    , base+    , HUnit                     ^>=1.6.0.0+    , nix-freeze-tree-internal+    , optparse-applicative+    , tasty                     >=1.2.3    && <1.5+    , tasty-discover            ^>=4.2.1+    , tasty-hunit               ^>=0.10.0.2++  hs-source-dirs:   test+  default-language: Haskell2010  source-repository head   type:     git
src/NixFreezeTree.hs view
@@ -20,7 +20,7 @@ import           Nix.Pretty (prettyNix) import           NixBuilder (mkBuildExpr) import           Options.Applicative (execParser)-import           Path (Abs, Dir, Path, (</>))+import           Path (Abs, Dir, Path, Rel, (</>)) import qualified Path as P import qualified System.Directory as D import           System.Directory.Tree
src/NixHash.hs view
@@ -5,23 +5,18 @@ module NixHash (mkFileAttrs, replaceLeadingDot) where  import           BuilderDirs (BuilderDirs, currentDir)-import           Control.Monad.IO.Class (MonadIO(..))+import           Control.Monad.IO.Class (MonadIO (..)) import           Control.Monad.Trans.Reader-import           Data.Binary.Put (runPut)-import           Data.Bool (bool)-import qualified Data.ByteString.Lazy as BL+import           Crypto.Hash (Digest, SHA256, hash)+import qualified Data.ByteString as B import           Data.Text (Text) import qualified Data.Text as T import           Nix-import           Path (Abs, File, Path, Rel, (</>), toFilePath)-import qualified System.Directory as D-import           System.Nix.Hash (HashAlgorithm(..), encodeBase32, hashLazy)-import           System.Nix.Nar-  ( FileSystemObject(..)-  , IsExecutable(..)-  , Nar(..)-  , putNar-  )+import           Path (Abs, File, Path, Rel, toFilePath, (</>))+import           Path.IO (withSystemTempFile)+import           System.IO+import           System.Nix.Hash (BaseEncoding (..), encodeDigestWith)+import           System.Nix.Nar (buildNarIO, narEffectsIO)  -- | Build a set of @filename -> derivation@ attributes. mkFileAttrs :: [Path Rel File] -> ReaderT BuilderDirs IO [(Text, NExpr)]@@ -70,12 +65,12 @@ -- extract from Figure 5.2 of http://nixos.org/~eelco/pubs/phd-thesis.pdf , -- which is the Nix thesis. recursiveHash :: MonadIO m => Path Abs File -> m Text-recursiveHash absF = do-  b <- liftIO . BL.readFile $ toFilePath absF-  executable <- bool NonExecutable Executable . D.executable-    <$> liftIO (D.getPermissions $ toFilePath absF)-  let nar = runPut . putNar . Nar $ Regular executable (BL.length b) b-  pure . encodeBase32 $ hashLazy @'SHA256 nar+recursiveHash absF =+  liftIO . withSystemTempFile "nix-freeze-tree.nar" $ \_ h -> do+    buildNarIO narEffectsIO (toFilePath absF) h+    hSeek h AbsoluteSeek 0+    contents <- B.hGetContents h+    pure $ encodeDigestWith NixBase32 (hash contents :: Digest SHA256)  -- | A leading dot is illegal in Nix derivation names. Replace it with '_'. replaceLeadingDot :: FilePath -> FilePath