my nixos configuration
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

progress on haskell cli, fix gh action becuase maybe this isn't required

Thunder dce938b3 c7dee758

+79 -8
-1
.github/workflows/update-flake.yaml
··· 33 33 target: 34 34 - nixosConfigurations.vps.pkgs.meowdzbot nixosConfigurations.vps.pkgs.sodexobot 35 35 - nixosConfigurations.vps.pkgs.leptos-kotiboksi 36 - - nixosConfigurations.framework.pkgs.krita nixosConfigurations.framework.pkgs.blender 37 36 update: 38 37 needs: 39 38 - build-matrix
+3 -4
flake/actions.nix
··· 212 212 213 213 vpsPackage = hostPackage "vps"; 214 214 vpsPkgs = map vpsPackage; 215 - 216 - frameworkPackage = hostPackage "framework"; 217 - fwPkgs = map frameworkPackage; 215 + # frameworkPackage = hostPackage "framework"; 216 + # fwPkgs = map frameworkPackage; 218 217 in [ 219 218 (join (vpsPkgs ["meowdzbot" "sodexobot"])) 220 219 (vpsPackage "leptos-kotiboksi") 221 - (join (fwPkgs ["krita" "blender"])) 220 + # (join (fwPkgs ["krita" "blender"])) 222 221 ]; 223 222 } 224 223 // mkBasicNix [
+1
flake/default.nix
··· 41 41 42 42 devShells.meow = pkgs.mkShell { 43 43 packages = [ 44 + (pkgs.callPackage ../pkgs/meow.nix {}) 44 45 (pkgs.haskellPackages.ghcWithPackages (p: 45 46 with p; [ 46 47 aeson
+61
meow/Cli.hs
··· 1 + {-# LANGUAGE LambdaCase #-} 2 + 3 + module Cli where 4 + 5 + import Control.Monad 6 + import Control.Monad.IO.Class 7 + import Control.Monad.Trans.Maybe 8 + 9 + import Nix.Build 10 + import Wireguard 11 + 12 + import Data.Text (pack) 13 + 14 + data WireguardAction = WgAdd String | WgRemove String 15 + deriving (Show) 16 + 17 + toWgAction :: WireguardAction -> IO (WireguardKeys -> WireguardKeys) 18 + toWgAction (WgAdd s) = addKey <$> (newWgKey $ pack s) 19 + toWgAction (WgRemove s) = pure . removeKey $ pack s 20 + 21 + type WgParse a = Either a String 22 + 23 + add s = s == "add" || s == "a" 24 + del s = s == "del" || s == "d" || s == "r" 25 + 26 + parseWgArg :: [String] -> WgParse (WireguardAction, [String]) 27 + parseWgArg (act : name : rest) 28 + | add act = Left (WgAdd name, rest) 29 + | del act = Left (WgRemove name, rest) 30 + parseWgArg (act : []) 31 + | add act || del act = Right "expected name" 32 + parseWgArg _ = Right "invalid keyword" 33 + 34 + parseWgArgs' :: [String] -> [WireguardAction] -> WgParse [WireguardAction] 35 + parseWgArgs' [] actions = Left actions 36 + parseWgArgs' args actions = 37 + case parseWgArg args of 38 + Left (action, rest) -> parseWgArgs' rest (actions ++ [action]) 39 + Right error -> Right error 40 + 41 + parseWgArgs :: [String] -> WgParse [WireguardAction] 42 + parseWgArgs = flip parseWgArgs' $ [] 43 + 44 + wgAct :: [WireguardAction] -> IO (Maybe Bool) 45 + wgAct actions = 46 + -- flip because [add remove] = id . add . remove => id (add (remove)) 47 + modifyKeys "sops/wireguard" =<< foldl' (flip (.)) id <$> mapM toWgAction actions 48 + 49 + wgArgs :: [String] -> IO () 50 + wgArgs args = 51 + case args of 52 + [] -> liftIO $ putStrLn "no arguments given" 53 + ("show" : []) -> liftIO $ showKeys "sops/wireguard" 54 + args -> liftIO $ do 55 + Just actions <- case parseWgArgs args of 56 + Left actions -> return . Just $ actions 57 + Right error -> do 58 + putStrLn error 59 + return Nothing 60 + Just status <- wgAct actions 61 + putStrLn . show $ status
+8 -2
meow/Main.hs
··· 5 5 import Distribution.Simple.Utils 6 6 import System.Environment 7 7 8 + import Cli 9 + import Data.List 8 10 import Nix.Build 9 11 import Wireguard 10 12 ··· 14 16 Just "vterm" -> return False 15 17 Just _ -> return True 16 18 Nothing -> return False 19 + 20 + -- safeTail :: [a] -> Maybe [a] 21 + -- safeTail = fmap snd . uncons 17 22 18 23 main :: IO () 19 24 main = do ··· 22 27 23 28 case safeHead args of 24 29 Just "wg" -> do 25 - showKeys "sops/wireguard" 30 + wgArgs $ safeTail args 26 31 Just "build" -> do 27 32 Just out <- nixBuild [".#nixosConfigurations." ++ (head . tail $ args) ++ ".config.system.build.toplevel"] emacs 28 33 putStrLn out 29 - _ -> putStrLn "ligma" 34 + -- putStrLn "build" 35 + -- _ -> putStrLn "ligma" 30 36 31 37 putStrLn $ "Emacs: " ++ show emacs
+1 -1
meow/Nix/Build.hs
··· 34 34 (_, _, _, nix) <- 35 35 createProcess 36 36 ( proc "nix" $ 37 - ["build", "--print-out-paths"] 37 + ["build", "--print-out-paths", "--accept-flake-config", "--no-warn-dirty"] 38 38 ++ ( if inEmacs 39 39 then [] 40 40 else ["--log-format", "internal-json", "-v"]
+5
pkgs/meow.nix
··· 2 2 lib, 3 3 haskellPackages, 4 4 stdenv, 5 + nix-output-monitor, 5 6 }: 6 7 stdenv.mkDerivation { 7 8 name = "meow"; ··· 14 15 with p; [ 15 16 aeson 16 17 ])) 18 + ]; 19 + 20 + propagatedNativeBuildInputs = [ 21 + nix-output-monitor 17 22 ]; 18 23 19 24 buildPhase = ''