File tree 2 files changed +22
-6
lines changed
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ import qualified Turtle as T
15
15
isExecutableInPath :: T. FilePath -> IO Bool
16
16
isExecutableInPath name = isJust <$> T. which name
17
17
18
+ isNixInstalled :: IO Bool
19
+ isNixInstalled = isExecutableInPath " nix"
20
+
18
21
isGhcInstalled :: IO Bool
19
22
isGhcInstalled = isExecutableInPath " ghc"
20
23
@@ -28,11 +31,16 @@ data NixConfiguration
28
31
= User | NixOS deriving (Eq , Show )
29
32
30
33
doesFileExist' :: FilePath -> IO Bool
31
- doesFileExist' path
32
- | " ~" `isPrefixOf` path = do
34
+ doesFileExist' filePath = do
35
+ fullFilePath <- toFullFilePath filePath
36
+ doesFileExist fullFilePath
37
+
38
+ toFullFilePath :: FilePath -> IO FilePath
39
+ toFullFilePath filePath
40
+ | " ~" `isPrefixOf` filePath = do
33
41
homepath <- getHomeDirectory
34
- doesFileExist $ homepath ++ RU. tail path
35
- | otherwise = doesFileExist path
42
+ return $ homepath ++ RU. tail filePath
43
+ | otherwise = return filePath
36
44
37
45
getExistingNixConfigurations :: IO [NixConfiguration ]
38
46
getExistingNixConfigurations = map fst <$> filterM
Original file line number Diff line number Diff line change @@ -52,12 +52,20 @@ logStep text sink actions = do
52
52
appendLog (" END : " <> text) sink
53
53
54
54
configureNix :: Bool -> Sink Action -> IO ()
55
- configureNix run sink = undefined
55
+ configureNix run sink = do
56
+ isNixInstalled' <- isNixInstalled
57
+ if isNixInstalled'
58
+ then
59
+ appendLog " Nix is already installed" sink
60
+ else
61
+ logStep " Installing Nix" sink (when run $ do
62
+ _ <- runShellCommand " curl -L https://nixos.org/nix/install | sh"
63
+ return () )
56
64
57
65
configureNixPackage :: Bool -> Sink Action -> ExtensionInfo -> IO ()
58
66
configureNixPackage run sink (ExtensionInfo name package) = do
59
67
nixConfiguration <- getOptimalNixConfiguration
60
- let configurationNixFilePath = unpack $ getNixConfigurationPath nixConfiguration
68
+ configurationNixFilePath <- toFullFilePath $ unpack $ getNixConfigurationPath nixConfiguration
61
69
oldConfigurationNixText <- liftIO $ readFile configurationNixFilePath
62
70
63
71
-- FIXME vvv requires Nix parsing using HNIX
You can’t perform that action at this time.
0 commit comments