mirror of
https://codeberg.org/leana8959/.files.git
synced 2026-02-01 14:39:39 +00:00
chore/manage: fix bug where nixpkgs store path is ""
This commit is contained in:
parent
acf4bba56d
commit
895173460a
1 changed files with 14 additions and 6 deletions
|
|
@ -23,14 +23,14 @@ main = do
|
||||||
) ->
|
) ->
|
||||||
manageArgs `showHelpOr` do
|
manageArgs `showHelpOr` do
|
||||||
nixpkgs <- readNixpkgsPath
|
nixpkgs <- readNixpkgsPath
|
||||||
void $ readProcessFriendly "nixos-rebuild" (action : nixosRebuildArgs nixpkgs host <> extraArgs)
|
exitWith =<< transparentProcess "nixos-rebuild" (action : nixosRebuildArgs nixpkgs host <> extraArgs)
|
||||||
|
|
||||||
( "install" : host
|
( "install" : host
|
||||||
: (partitionArgs -> (manageArgs, extraArgs))
|
: (partitionArgs -> (manageArgs, extraArgs))
|
||||||
) ->
|
) ->
|
||||||
manageArgs `showHelpOr` do
|
manageArgs `showHelpOr` do
|
||||||
nixpkgs <- readNixpkgsPath
|
nixpkgs <- readNixpkgsPath
|
||||||
void $ readProcessFriendly "nixos-install" (nixosInstallArgs nixpkgs host <> extraArgs)
|
exitWith =<< transparentProcess "nixos-install" (nixosInstallArgs nixpkgs host <> extraArgs)
|
||||||
|
|
||||||
_ -> putStr help >> exitFailure
|
_ -> putStr help >> exitFailure
|
||||||
|
|
||||||
|
|
@ -79,8 +79,10 @@ quote x = "\"" <> x <> "\""
|
||||||
blueForeground :: String -> String
|
blueForeground :: String -> String
|
||||||
blueForeground x = "\ESC[34m" <> x <> "\ESC[0m"
|
blueForeground x = "\ESC[34m" <> x <> "\ESC[0m"
|
||||||
|
|
||||||
readProcessFriendly :: String -> [String] -> IO String
|
-- |
|
||||||
readProcessFriendly cmdName args = do
|
-- Run with a shared std{in,out,err}
|
||||||
|
transparentProcess :: String -> [String] -> IO ExitCode
|
||||||
|
transparentProcess cmdName args = do
|
||||||
hPutStrLn stderr
|
hPutStrLn stderr
|
||||||
$ "Executing: " <> (quote . blueForeground) (showCommandForUser cmdName args)
|
$ "Executing: " <> (quote . blueForeground) (showCommandForUser cmdName args)
|
||||||
(_, _, _, pid) <- createProcess
|
(_, _, _, pid) <- createProcess
|
||||||
|
|
@ -89,8 +91,13 @@ readProcessFriendly cmdName args = do
|
||||||
, std_out = UseHandle stdout
|
, std_out = UseHandle stdout
|
||||||
, std_err = UseHandle stderr
|
, std_err = UseHandle stderr
|
||||||
}
|
}
|
||||||
_ <- waitForProcess pid
|
waitForProcess pid
|
||||||
pure ""
|
|
||||||
|
readProcessFriendly :: String -> [String] -> String -> IO String
|
||||||
|
readProcessFriendly cmdName args inp = do
|
||||||
|
hPutStrLn stderr
|
||||||
|
$ "Executing: " <> (quote . blueForeground) (showCommandForUser cmdName args)
|
||||||
|
readProcess cmdName args inp
|
||||||
|
|
||||||
readNixpkgsPath :: IO StorePath
|
readNixpkgsPath :: IO StorePath
|
||||||
readNixpkgsPath =
|
readNixpkgsPath =
|
||||||
|
|
@ -100,5 +107,6 @@ readNixpkgsPath =
|
||||||
, "-E"
|
, "-E"
|
||||||
, "let sources = import ./npins; in sources.nixpkgs.outPath"
|
, "let sources = import ./npins; in sources.nixpkgs.outPath"
|
||||||
]
|
]
|
||||||
|
""
|
||||||
where
|
where
|
||||||
clean = filter (\c -> c /= '\n' && c /= '"')
|
clean = filter (\c -> c /= '\n' && c /= '"')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue