cachix 0.1.0.0 → 0.1.0.1
raw patch · 8 files changed
+131/−112 lines, 8 files
Files
- ChangeLog.md +10/−0
- cachix.cabal +5/−5
- src/Cachix/Client.hs +1/−1
- src/Cachix/Client/Commands.hs +13/−2
- src/Cachix/Client/InstallationMode.hs +4/−4
- src/Cachix/Client/NixConf.hs +3/−3
- test/InstallationModeSpec.hs +82/−83
- test/NixVersionSpec.hs +13/−14
ChangeLog.md view
@@ -7,7 +7,17 @@ ## [Unreleased] +## [0.1.0.1] - 2018-07-05++### Changed++- #92 Add build-tool-depends where needed @domenkozar+- #90 HLint fixes @domenkozar+- #86 Improve Cabal description and synopsis @domenkozar+- #87 Support fsnotify 0.3.x @domenkozar+ ## [0.1.0.0] - 2018-07-01 ### Added+ - Initial release @domenkozar
cachix.cabal view
@@ -1,12 +1,12 @@--- This file has been generated from package.yaml by hpack version 0.21.2.+-- This file has been generated from package.yaml by hpack version 0.28.2. -- -- see: https://github.com/sol/hpack ----- hash: 4ecd761e07cb906fa23f7c69e728be19cfd4d7d067f5860ff640827b44f5dfaf+-- hash: 5225259f70e6c6df5a7ffab92dc1a70e87f7bd25284107c3f5009f1659d4a466 name: cachix-version: 0.1.0.0-description: Please see the README on Github at <https://github.com/cachix/cachix#readme>+version: 0.1.0.1+synopsis: Command line client for Nix binary cache hosting https://cachix.org homepage: https://github.com/cachix/cachix#readme bug-reports: https://github.com/cachix/cachix/issues author: Domen Kožar@@ -16,7 +16,6 @@ license-file: LICENSE build-type: Simple cabal-version: >= 1.10- extra-source-files: ChangeLog.md README.md@@ -136,6 +135,7 @@ , uri-bytestring , versions default-language: Haskell2010+ build-tool-depends: hspec-discover:hspec-discover test-suite cachix-test type: exitcode-stdio-1.0
src/Cachix/Client.hs view
@@ -34,7 +34,7 @@ customManagerSettings = tlsManagerSettings { managerResponseTimeout = responseTimeoutNone -- managerModifyRequest :: Request -> IO Request- , managerModifyRequest = \request -> return $ setRequestHeader "User-Agent" [toS cachixVersion] request+ , managerModifyRequest = return . setRequestHeader "User-Agent" [toS cachixVersion] } cachixVersion :: Text
src/Cachix/Client/Commands.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeOperators #-} module Cachix.Client.Commands@@ -162,11 +163,21 @@ forever $ threadDelay 1000000 where action :: Action- action (Removed fp _) = pushStorePath env config name $ toS $ dropEnd 5 fp+#if MIN_VERSION_fsnotify(0,3,0)+ action (Removed fp _ _) =+#else+ action (Removed fp _) =+#endif+ pushStorePath env config name $ toS $ dropEnd 5 fp action _ = return () filterF :: ActionPredicate- filterF (Removed fp _) | ".lock" `isSuffixOf` fp = True+#if MIN_VERSION_fsnotify(0,3,0)+ filterF (Removed fp _ _)+#else+ filterF (Removed fp _)+#endif+ | ".lock" `isSuffixOf` fp = True filterF _ = False dropEnd :: Int -> [a] -> [a]
src/Cachix/Client/InstallationMode.hs view
@@ -50,8 +50,8 @@ getInstallationMode NixEnv{..} | nixMode == Nix1XX = UnsupportedNix1X | isNixOS && isRoot = EchoNixOS- | isNixOS && (not isTrusted) = EchoNixOSWithTrustedUser- | (not isNixOS) && isRoot = Install NixConf.Global+ | isNixOS && not isTrusted = EchoNixOSWithTrustedUser+ | not isNixOS && isRoot = Install NixConf.Global | nixMode == Nix20 = Nix20RequiresSudo | isTrusted = Install NixConf.Local | not isTrusted = UntrustedRequiresSudo@@ -107,11 +107,11 @@ user <- getUser -- to detect single user installations permissions <- getPermissions "/nix/store"- unless (groups == []) $ do+ unless (null groups) $ do -- TODO: support Nix group syntax putText "Warn: cachix doesn't yet support checking if user is trusted via groups, so it will recommend sudo" putStrLn $ "Warn: groups found " <> T.intercalate "," groups- return $ (writable permissions) || (user `elem` users)+ return $ writable permissions || user `elem` users where groups = filter (\u -> T.head u == '@') users
src/Cachix/Client/NixConf.hs view
@@ -50,15 +50,15 @@ type NixConf = NixConfG [NixConfLine] readLines :: [NixConf] -> (NixConfLine -> Maybe [Text]) -> [Text]-readLines nixconfs predicate = concat $ fmap f nixconfs+readLines nixconfs predicate = concatMap f nixconfs where f (NixConf xs) = foldl foldIt [] xs foldIt :: [Text] -> NixConfLine -> [Text]- foldIt prev new = prev <> (fromMaybe [] $ predicate new)+ foldIt prev new = prev <> fromMaybe [] (predicate new) writeLines :: (NixConfLine -> Maybe [Text]) -> NixConfLine -> NixConf -> NixConf-writeLines predicate addition nixconf = fmap f nixconf+writeLines predicate addition = fmap f where f x = filter (isNothing . predicate) x <> [addition]
test/InstallationModeSpec.hs view
@@ -9,86 +9,85 @@ spec :: Spec-spec = do- describe "getInstallationMode" $ do- it "Nix 1.X is unsupported" $- let- nixenv = NixEnv- { nixMode = Nix1XX- , isTrusted = False -- any- , isRoot = False -- any- , isNixOS = False -- any- }- in getInstallationMode nixenv `shouldBe` UnsupportedNix1X- it "NixOS with root prints configuration" $- let- nixenv = NixEnv- { nixMode = Nix20 -- any except 1.0- , isTrusted = True -- any- , isRoot = True- , isNixOS = True- }- in getInstallationMode nixenv `shouldBe` EchoNixOS- it "NixOS without trust prints configuration plus trust" $- let- nixenv = NixEnv- { nixMode = Nix20- , isTrusted = False- , isRoot = False- , isNixOS = True- }- in getInstallationMode nixenv `shouldBe` EchoNixOSWithTrustedUser- it "NixOS non-root trusted results into local install" $- let- nixenv = NixEnv- { nixMode = Nix201- , isTrusted = True- , isRoot = False- , isNixOS = True- }- in getInstallationMode nixenv `shouldBe` Install NixConf.Local- it "non-NixOS root results into global install" $- let- nixenv = NixEnv- { nixMode = Nix201- , isTrusted = True- , isRoot = True- , isNixOS = False- }- in getInstallationMode nixenv `shouldBe` Install NixConf.Global- it "non-NixOS non-root trusted results into local install" $- let- nixenv = NixEnv- { nixMode = Nix201- , isTrusted = True- , isRoot = False- , isNixOS = False- }- in getInstallationMode nixenv `shouldBe` Install NixConf.Local- it "non-NixOS non-root non-trusted results into required sudo" $- let- nixenv = NixEnv- { nixMode = Nix201- , isTrusted = False- , isRoot = False- , isNixOS = False- }- in getInstallationMode nixenv `shouldBe` UntrustedRequiresSudo- it "non-NixOS non-root non-trusted on Nix 2.0.0 results into required sudo with upgrade warning" $- let- nixenv = NixEnv- { nixMode = Nix20- , isTrusted = False- , isRoot = False- , isNixOS = False- }- in getInstallationMode nixenv `shouldBe` Nix20RequiresSudo- it "non-NixOS non-root trusted on Nix 2.0.0 results into required sudo with upgrade warning" $- let- nixenv = NixEnv- { nixMode = Nix20- , isTrusted = True- , isRoot = False- , isNixOS = False- }- in getInstallationMode nixenv `shouldBe` Nix20RequiresSudo+spec = describe "getInstallationMode" $ do+ it "Nix 1.X is unsupported" $+ let+ nixenv = NixEnv+ { nixMode = Nix1XX+ , isTrusted = False -- any+ , isRoot = False -- any+ , isNixOS = False -- any+ }+ in getInstallationMode nixenv `shouldBe` UnsupportedNix1X+ it "NixOS with root prints configuration" $+ let+ nixenv = NixEnv+ { nixMode = Nix20 -- any except 1.0+ , isTrusted = True -- any+ , isRoot = True+ , isNixOS = True+ }+ in getInstallationMode nixenv `shouldBe` EchoNixOS+ it "NixOS without trust prints configuration plus trust" $+ let+ nixenv = NixEnv+ { nixMode = Nix20+ , isTrusted = False+ , isRoot = False+ , isNixOS = True+ }+ in getInstallationMode nixenv `shouldBe` EchoNixOSWithTrustedUser+ it "NixOS non-root trusted results into local install" $+ let+ nixenv = NixEnv+ { nixMode = Nix201+ , isTrusted = True+ , isRoot = False+ , isNixOS = True+ }+ in getInstallationMode nixenv `shouldBe` Install NixConf.Local+ it "non-NixOS root results into global install" $+ let+ nixenv = NixEnv+ { nixMode = Nix201+ , isTrusted = True+ , isRoot = True+ , isNixOS = False+ }+ in getInstallationMode nixenv `shouldBe` Install NixConf.Global+ it "non-NixOS non-root trusted results into local install" $+ let+ nixenv = NixEnv+ { nixMode = Nix201+ , isTrusted = True+ , isRoot = False+ , isNixOS = False+ }+ in getInstallationMode nixenv `shouldBe` Install NixConf.Local+ it "non-NixOS non-root non-trusted results into required sudo" $+ let+ nixenv = NixEnv+ { nixMode = Nix201+ , isTrusted = False+ , isRoot = False+ , isNixOS = False+ }+ in getInstallationMode nixenv `shouldBe` UntrustedRequiresSudo+ it "non-NixOS non-root non-trusted on Nix 2.0.0 results into required sudo with upgrade warning" $+ let+ nixenv = NixEnv+ { nixMode = Nix20+ , isTrusted = False+ , isRoot = False+ , isNixOS = False+ }+ in getInstallationMode nixenv `shouldBe` Nix20RequiresSudo+ it "non-NixOS non-root trusted on Nix 2.0.0 results into required sudo with upgrade warning" $+ let+ nixenv = NixEnv+ { nixMode = Nix20+ , isTrusted = True+ , isRoot = False+ , isNixOS = False+ }+ in getInstallationMode nixenv `shouldBe` Nix20RequiresSudo
test/NixVersionSpec.hs view
@@ -6,17 +6,16 @@ import Cachix.Client.NixVersion spec :: Spec-spec = do- describe "parseNixMode" $ do- it "parses 'nix-env (Nix) 2.0' as Nix20" $- parseNixMode "nix-env (Nix) 2.0" `shouldBe` Right Nix20- it "parses 'nix-env (Nix) 2.0.1' as Nix201" $- parseNixMode "nix-env (Nix) 2.0.1" `shouldBe` Right Nix201- it "parses 'nix-env (Nix) 1.11.13' as Nix1XX" $- parseNixMode "nix-env (Nix) 1.11.13" `shouldBe` Right Nix1XX- it "parses 'nix-env (Nix) 2.0.5' as Nix201" $- parseNixMode "nix-env (Nix) 2.0.5" `shouldBe` Right Nix201- it "parses 'nix-env (Nix) 2.0.1pre6053_444b921' as Nix201" $- parseNixMode "nix-env (Nix) 2.0.1pre6053_444b921" `shouldBe` Right Nix201- it "fails with unknown string 'foobar'" $- parseNixMode "foobar" `shouldBe` Left "Couldn't parse 'nix-env --version' output: foobar"+spec = describe "parseNixMode" $ do+ it "parses 'nix-env (Nix) 2.0' as Nix20" $+ parseNixMode "nix-env (Nix) 2.0" `shouldBe` Right Nix20+ it "parses 'nix-env (Nix) 2.0.1' as Nix201" $+ parseNixMode "nix-env (Nix) 2.0.1" `shouldBe` Right Nix201+ it "parses 'nix-env (Nix) 1.11.13' as Nix1XX" $+ parseNixMode "nix-env (Nix) 1.11.13" `shouldBe` Right Nix1XX+ it "parses 'nix-env (Nix) 2.0.5' as Nix201" $+ parseNixMode "nix-env (Nix) 2.0.5" `shouldBe` Right Nix201+ it "parses 'nix-env (Nix) 2.0.1pre6053_444b921' as Nix201" $+ parseNixMode "nix-env (Nix) 2.0.1pre6053_444b921" `shouldBe` Right Nix201+ it "fails with unknown string 'foobar'" $+ parseNixMode "foobar" `shouldBe` Left "Couldn't parse 'nix-env --version' output: foobar"