aboutsummaryrefslogtreecommitdiff
path: root/pkgs/manager/main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/manager/main.hs')
-rw-r--r--pkgs/manager/main.hs72
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"