diff options
| author | Chris Wells <chris@mathematicaster.org> | 2024-09-10 11:21:08 -0500 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2024-09-10 11:21:08 -0500 |
| commit | 8eae39e8e670f228e9675fb3bc432ce512560396 (patch) | |
| tree | d3736c2f236f0878c2d199b042deb6b4d25e9c6c /pkgs/manager | |
| parent | 373d5246eb53ef1a13166b066248526f33f935db (diff) | |
| download | kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.gz kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.bz2 kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.lz kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.xz kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.zst kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.zip | |
Created a merge function which will probably be better than symlinkJoin. Also started writing the cli manager in haskell
Diffstat (limited to 'pkgs/manager')
| -rw-r--r-- | pkgs/manager/main.hs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/pkgs/manager/main.hs b/pkgs/manager/main.hs new file mode 100644 index 0000000..6eac0a7 --- /dev/null +++ b/pkgs/manager/main.hs @@ -0,0 +1,72 @@ +module Main where + +import Control.Applicative +import Control.Monad +import Data.Bifunctor +import Data.Function +import Data.Functor +import Options.Applicative +import System.FilePath (FilePath) +import System.Process.Typed qualified as P +-- import Turtle + + + +main :: IO () +main = undefined + + + +flakeArg :: Parser Flake +flakeArg = argument (maybeReader parseFlake) $ fold + [ metavar "FLAKE" + , help "Flake location" + ] + +sysOption :: Parser String +sysOption = strOption $ fold + [ long "system" + , metavar "SYSTEM" + , help "Like x86_64-linux" + ] + +koboConfigFlake :: Flake -> String -> Flake +koboConfigFlake (Flake u a) sys = Flake u $ "koboConfigurations" : sys : a + +data Flake = Flake + { uri :: !FilePath + , attrs :: ![String] + } deriving stock (Eq, Show) + +parseFlake :: String -> Maybe Flake +parseFlake str = + let (u, a) = second (drop 1) $ break (== '#') str + in case u of + [] -> Nothing + _ -> Flake u $ splitter a + where + splitter xs = + let (y, ys) = second (drop 1) $ break (== '.') xs + in case ys of + [] -> [y] + _ -> y : splitter ys + + +data Action + = Build + | BuildFirmware + | Deploy + | DeployFirmware + | Check + deriving stock (Eq, Show) + + +data CLIArgs = CLIArgs + { _action :: !Action + , _flake :: !Flake + , _system :: !String + } deriving stock (Eq, Show) + + +runNix :: [String] -> IO () +runNix = P.runProcess_ . P.proc "nix" |
