diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/flake.nix b/flake.nix index bcc46c7..568c6e4 100644 --- a/flake.nix +++ b/flake.nix @@ -27,17 +27,7 @@ envErrorMessage = varName: "Error: The ${varName} environment variable is not set."; - parseEnv = file: let - lines = builtins.filter (line: builtins.match "^var=.*" line != null) (builtins.readFile file); - attributes = builtins.listToAttrs (builtins.map (line: let - parts = builtins.split "=" line; - key = builtins.substring 0 (builtins.stringLength parts[0] - 3) parts[0]; # Remove "var" prefix - value = parts[1]; - in { - name = key; - value = value; - }) lines); - in attributes; + parseEnv = import ./parse-env.nix; dotEnv = builtins.getEnv "DOTENV"; minorEnvironment = @@ -82,6 +72,20 @@ # Execute the system's nvim with your custom arguments exec "$SYSTEM_NVIM" --cmd 'lua vim.o.exrc = true' "$@" ''; + printobstacle = + let + name = "printobstacle"; + in + pkgs.writeShellScriptBin "${name}" '' + printf "%s%s%s\n" "''${RED}" "$*" "''${RESET}" + ''; + printprogress = + let + name = "printprogress"; + in + pkgs.writeShellScriptBin "${name}" '' + printf "%s%s%s\n" "''${YELLOW}" "$*" "''${RESET}" + ''; colorize = pkgs.writeShellScriptBin "colorize" '' awk ' BEGIN { @@ -115,7 +119,7 @@ }) // { lib = { # -- For all systems -- - inherit forAllSystemsWithPkgs forSpecSystemsWithPkgs; + inherit dotEnv minorEnvironment parseEnv forAllSystemsWithPkgs forSpecSystemsWithPkgs; # -- Env processing -- getEnv = varName: let diff --git a/parse-env.nix b/parse-env.nix new file mode 100644 index 0000000..5f404a7 --- /dev/null +++ b/parse-env.nix @@ -0,0 +1,14 @@ +# TODO: allow multiline +file: let + envText = builtins.readFile file; + envLines = builtins.split "\n" envText; + lines = builtins.filter (line: (builtins.match "^.*=.*" line) != null) envLines; + #attributes = builtins.listToAttrs (builtins.map (line: let + # parts = builtins.split "=" line; + # key = builtins.substring 0 (builtins.stringLength parts[0] - 3) parts[0]; # Remove "var" prefix + # value = parts[1]; + #in { + # name = key; + # value = value; + #}) lines); +in {inherit envLines lines;}