status-mobile/nix/tools/envParser.nix
Jakub Sokołowski 0652d18653
nix: upgrade nixpkgs, keep Go at 1.14.15
Notable software upgrades:

- Go `1.14.13` to `1.14.15`
- Clojure `1.10.1.763` to `1.10.3.855`
- NodeJS `12.20.1` to `12.22.1`
- Git `2.29.2` to `2.31.1`
- CMake `3.10.2` to `3.18.1`
- Curl `7.74.0` to `7.76.1`
- Android NDK `21.3.6528147` to `22.1.7171670`
- Android Platform Tools `30.0.5` to `31.0.2`

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2021-06-15 17:49:33 +02:00

37 lines
1.3 KiB
Nix

# This Nix expression takes care of reading/parsing the correct .env configuration file and return it as an attr set
{ config, stdenv, lib }:
let
inherit (builtins) listToAttrs head tail readFile;
inherit (lib) attrByPath filter hasPrefix nameValuePair splitString;
build-type = attrByPath ["status-im" "build-type"] "" config;
ci = (attrByPath ["status-im" "ci"] "" config) != "";
readLinesFromFile =
file:
let
lines = splitString "\n" (readFile file);
removeComments = filter (line: line != "" && !(hasPrefix "#" line));
meaningfulLines = removeComments lines;
in
meaningfulLines;
readFlagsFromFile =
file:
let
lines = readLinesFromFile file;
genAttrs = lines:
listToAttrs (map (line:
let flag = splitString "=" line;
in nameValuePair (head flag) (head (tail flag))) lines);
in
genAttrs lines;
envFileName =
if build-type == "release" then ../../.env.release else
if build-type == "nightly" then ../../.env.nightly else
if build-type == "e2e" then ../../.env.e2e else
if build-type == "pr" then ../../.env.jenkins else ../../.env;
flags = readFlagsFromFile envFileName; # TODO: Simplify this path search with lib.locateDominatingFile
in flags