mirror of
https://codeberg.org/leana8959/.files.git
synced 2026-02-01 22:49:41 +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
|
||||
nixpkgs <- readNixpkgsPath
|
||||
void $ readProcessFriendly "nixos-rebuild" (action : nixosRebuildArgs nixpkgs host <> extraArgs)
|
||||
exitWith =<< transparentProcess "nixos-rebuild" (action : nixosRebuildArgs nixpkgs host <> extraArgs)
|
||||
|
||||
( "install" : host
|
||||
: (partitionArgs -> (manageArgs, extraArgs))
|
||||
) ->
|
||||
manageArgs `showHelpOr` do
|
||||
nixpkgs <- readNixpkgsPath
|
||||
void $ readProcessFriendly "nixos-install" (nixosInstallArgs nixpkgs host <> extraArgs)
|
||||
exitWith =<< transparentProcess "nixos-install" (nixosInstallArgs nixpkgs host <> extraArgs)
|
||||
|
||||
_ -> putStr help >> exitFailure
|
||||
|
||||
|
|
@ -79,8 +79,10 @@ quote x = "\"" <> x <> "\""
|
|||
blueForeground :: String -> String
|
||||
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
|
||||
$ "Executing: " <> (quote . blueForeground) (showCommandForUser cmdName args)
|
||||
(_, _, _, pid) <- createProcess
|
||||
|
|
@ -89,8 +91,13 @@ readProcessFriendly cmdName args = do
|
|||
, std_out = UseHandle stdout
|
||||
, std_err = UseHandle stderr
|
||||
}
|
||||
_ <- waitForProcess pid
|
||||
pure ""
|
||||
waitForProcess pid
|
||||
|
||||
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 =
|
||||
|
|
@ -100,5 +107,6 @@ readNixpkgsPath =
|
|||
, "-E"
|
||||
, "let sources = import ./npins; in sources.nixpkgs.outPath"
|
||||
]
|
||||
""
|
||||
where
|
||||
clean = filter (\c -> c /= '\n' && c /= '"')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue