diff --git a/CHANGELOG.md b/CHANGELOG.md index 54e1359..27d3881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## WIP +## [0.2.7] - 2021-05-23 + +- `hnix-0.13` support + ## [0.2.6] - 2021-05-17 - `git ls-remote` calls are printed in verbose mode diff --git a/app/Main.hs b/app/Main.hs index 954fa89..c39da27 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -127,6 +127,3 @@ instance Read Regex where instance ParseField Regex where metavar _ = "REGEX" readField = eitherReader makeRegexM - -instance (e ~ String) => MonadFail (Either e) where - fail = Left diff --git a/default.nix b/default.nix index 00baa0d..c201ae8 100644 --- a/default.nix +++ b/default.nix @@ -10,7 +10,15 @@ let in hp.developPackage { name = "update-nix-fetchgit"; root = nix-gitignore.gitignoreSource [ ] ./.; - overrides = self: _super: { }; + overrides = self: super: { + hnix = pkgs.haskell.lib.dontCheck (self.callHackageDirect { + pkg = "hnix"; + ver = "0.13.1"; + sha256 = "0v3r33azlv050fv8y5vw0pahdnch7vqq94viwrp9vlw8hpiys8qn"; + } { }); + relude = self.relude_1_0_0_1; + semialign = self.semialign_1_2; + }; modifier = drv: haskell.lib.addBuildTools drv [ git nix nix-prefetch-git ]; returnShellEnv = forShell; } diff --git a/hnix.patch b/hnix.patch new file mode 100644 index 0000000..78ac22c --- /dev/null +++ b/hnix.patch @@ -0,0 +1,82 @@ +diff --git a/src/Nix/Parser.hs b/src/Nix/Parser.hs +index 0a820b8..7e0a4d2 100644 +--- a/src/Nix/Parser.hs ++++ b/src/Nix/Parser.hs +@@ -609,9 +609,10 @@ annotateLocation :: Parser a -> Parser (Ann SrcSpan a) + annotateLocation p = + do + begin <- getSourcePos ++ res <- p + end <- get -- The state set before the last whitespace + +- Ann (SrcSpan begin end) <$> p ++ pure $ Ann (SrcSpan begin end) res + + annotateLocation1 :: Parser (NExprF NExprLoc) -> Parser NExprLoc + annotateLocation1 = fmap annToAnnF . annotateLocation +diff --git a/tests/ParserTests.hs b/tests/ParserTests.hs +index 0b50cf6..5720999 100644 +--- a/tests/ParserTests.hs ++++ b/tests/ParserTests.hs +@@ -357,6 +357,42 @@ in null|] [text|let + in (matcher.case or null).foo (v.case); + in null|] + ++case_simpleLoc = ++ let ++ mkSPos l c = SourcePos "" (mkPos l) (mkPos c) ++ mkSpan l1 c1 l2 c2 = SrcSpan (mkSPos l1 c1) (mkSPos l2 c2) ++ in ++ assertParseTextLoc [text|let ++ foo = bar ++ baz "qux"; ++ in foo ++ |] ++ (Fix ++ (NLet_ ++ (mkSpan 1 1 4 7) ++ [ NamedVar ++ (StaticKey "foo" :| []) ++ (Fix ++ (NBinary_ ++ (mkSpan 2 7 3 15) ++ NApp ++ (Fix ++ (NBinary_ (mkSpan 2 7 3 9) ++ NApp ++ (Fix (NSym_ (mkSpan 2 7 2 10) "bar")) ++ (Fix (NSym_ (mkSpan 3 6 3 9) "baz")) ++ ) ++ ) ++ (Fix (NStr_ (mkSpan 3 10 3 15) (DoubleQuoted [Plain "qux"]))) ++ ) ++ ) ++ (mkSPos 2 1) ++ ] ++ (Fix (NSym_ (mkSpan 4 4 4 7) "foo")) ++ ) ++ ) ++ ++ + tests :: TestTree + tests = $testGroupGenerator + +@@ -375,6 +411,18 @@ assertParseText str expected = + ) + (parseNixText str) + ++assertParseTextLoc :: Text -> NExprLoc -> Assertion ++assertParseTextLoc str expected = ++ either ++ (\ err -> ++ assertFailure $ toString $ "Unexpected fail parsing `" <> str <> "':\n" <> show err ++ ) ++ (assertEqual ++ ("When parsing " <> toString str) ++ expected ++ ) ++ (parseNixTextLoc str) ++ + assertParseFile :: FilePath -> NExpr -> Assertion + assertParseFile file expected = + do diff --git a/nixpkgs.nix b/nixpkgs.nix index bd6a516..7a40eb7 100644 --- a/nixpkgs.nix +++ b/nixpkgs.nix @@ -1,8 +1,8 @@ let nixpkgsSrc = builtins.fetchTarball { url = - "https://github.com/NixOS/nixpkgs/archive/83d907fd760d9ee4f49b4b7e4b1c6682f137b573.tar.gz"; # nixos-unstable - sha256 = "0qc8gfkbga7v5p8r6h2hbdi8bjl3piikdwcbb9fff5cjnxi7v7qa"; + "https://github.com/NixOS/nixpkgs/archive/d42cd445dde587e9a993cd9434cb43da07c4c5de.tar.gz"; # nixos-unstable + sha256 = "0dzrn97srxyw5a3g7hf8chwccxns5z3aij23hc0fch7ygc8w0gq0"; }; in import nixpkgsSrc { } diff --git a/package.yaml b/package.yaml index ef3cb02..545dea0 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: update-nix-fetchgit -version: "0.2.6" +version: "0.2.7" synopsis: A program to update fetchgit values in Nix expressions description: | This command-line utility is meant to be used by people maintaining Nix @@ -46,7 +46,7 @@ library: - bytestring >= 0.10 - data-fix - github-rest - - hnix >= 0.11 && < 0.13 + - hnix >= 0.13.1 - monad-validate - mtl - process >= 1.2 diff --git a/src/Nix/Match/Typed.hs b/src/Nix/Match/Typed.hs index 2836154..4b1f388 100644 --- a/src/Nix/Match/Typed.hs +++ b/src/Nix/Match/Typed.hs @@ -201,8 +201,8 @@ typedMatcherGen -> Q (([T.Text], [T.Text]), Exp) typedMatcherGen parseNix collect add strip s = do expr <- case parseNix (T.pack s) of - Failure err -> fail $ show err - Success e -> pure e + Left err -> fail $ show err + Right e -> pure e let (opt, req) = collect expr optT = symbolList opt reqT = symbolList req diff --git a/src/Update/Nix/FetchGit/Utils.hs b/src/Update/Nix/FetchGit/Utils.hs index 8ff88a7..5f472ff 100644 --- a/src/Update/Nix/FetchGit/Utils.hs +++ b/src/Update/Nix/FetchGit/Utils.hs @@ -38,7 +38,7 @@ import Data.Time ( Day ) import Nix.Atoms ( NAtom(NBool) ) import Nix.Expr hiding ( SourcePos ) -import Nix.Parser ( Result(..) +import Nix.Parser ( Result , parseNixFileLoc , parseNixTextLoc ) @@ -48,13 +48,13 @@ import Update.Span ourParseNixText :: Text -> Either Warning NExprLoc ourParseNixText t = case parseNixTextLoc t of - Failure parseError -> Left (CouldNotParseInput (tShow parseError)) - Success expr -> pure expr + Left parseError -> Left (CouldNotParseInput (tShow parseError)) + Right expr -> pure expr ourParseNixFile :: FilePath -> M NExprLoc ourParseNixFile f = liftIO (parseNixFileLoc f) >>= \case - Failure parseError -> refute1 (CouldNotParseInput (tShow parseError)) - Success expr -> pure expr + Left parseError -> refute1 (CouldNotParseInput (tShow parseError)) + Right expr -> pure expr -- | Get the url from either a nix expression for the url or a repo and owner -- expression. diff --git a/update-nix-fetchgit.cabal b/update-nix-fetchgit.cabal index 60ec018..5069c95 100644 --- a/update-nix-fetchgit.cabal +++ b/update-nix-fetchgit.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: update-nix-fetchgit -version: 0.2.6 +version: 0.2.7 synopsis: A program to update fetchgit values in Nix expressions description: This command-line utility is meant to be used by people maintaining Nix expressions that fetch files from Git repositories. It automates the process @@ -108,7 +108,7 @@ library , bytestring >=0.10 , data-fix , github-rest - , hnix >=0.11 && <0.13 + , hnix >=0.13.1 , monad-validate , mtl , process >=1.2