General faff (#9)

This commit is contained in:
Patrick Stevens
2022-08-20 21:45:49 +01:00
committed by GitHub
parent cf0dbe7f44
commit f4678f910f
9 changed files with 203 additions and 166 deletions

View File

@@ -81,14 +81,14 @@ type NixFile =
static member Parse (s : string) : NixFile =
let pre, post =
s.Split "\n] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [\n"
s.Split "++ pkgs.vscode-utils.extensionsFromVscodeMarketplace ["
|> function
| [| pre ; post |] -> pre, post
| _ -> failwith "Unexpected number of '++'"
let verbatim, skipped =
match pre.Split "\n" |> List.ofArray with
| "{ pkgs }:" :: "" :: "with pkgs.vscode-extensions; [" :: rest ->
| "{pkgs}:" :: "with pkgs.vscode-extensions;" :: " [" :: rest ->
rest
|> List.map (fun s ->
if s.StartsWith '#' then Choice2Of2 (s.[2..].Trim()) else Choice1Of2 (s.Trim())