2020-12-16 18:26:20 +00:00
|
|
|
let
|
2021-07-04 22:53:03 +00:00
|
|
|
persistPath = "/disk/persist/maralorn";
|
|
|
|
hasPersistDisk = builtins.pathExists persistPath;
|
2020-12-16 18:26:20 +00:00
|
|
|
privateExists = builtins.pathExists private/submodule-is-checked-out;
|
2021-07-04 22:53:03 +00:00
|
|
|
var = "WITH_SECRETS";
|
|
|
|
explicitUsePrivate = builtins.getEnv var == "true";
|
|
|
|
explicitNotUsePrivate = builtins.getEnv var == "false";
|
2020-12-16 18:26:20 +00:00
|
|
|
usePrivate = !explicitNotUsePrivate && (explicitUsePrivate || privateExists);
|
2022-08-11 09:50:05 +00:00
|
|
|
withSecrets =
|
|
|
|
builtins.trace
|
|
|
|
(
|
|
|
|
if usePrivate
|
|
|
|
then assert privateExists; "Building _with_ secrets!"
|
|
|
|
else "Building _without_ secrets!"
|
|
|
|
)
|
|
|
|
usePrivate;
|
2022-03-08 01:42:46 +00:00
|
|
|
in {
|
2020-12-16 18:26:20 +00:00
|
|
|
inherit withSecrets;
|
2022-03-08 01:42:46 +00:00
|
|
|
privatePath = name: let
|
|
|
|
path = "${
|
|
|
|
if hasPersistDisk
|
|
|
|
then persistPath
|
|
|
|
else "/home/maralorn"
|
|
|
|
}/git/config/private/${name}";
|
|
|
|
in
|
|
|
|
if withSecrets
|
|
|
|
then assert builtins.pathExists (./private + "/${name}"); path
|
|
|
|
else path;
|
2020-12-16 18:26:20 +00:00
|
|
|
privateValue = default: name:
|
2022-03-08 01:42:46 +00:00
|
|
|
if withSecrets
|
|
|
|
then import (./private + "/${name}.nix")
|
|
|
|
else default;
|
2020-12-16 18:26:20 +00:00
|
|
|
privateFile = name:
|
2022-03-08 01:42:46 +00:00
|
|
|
if withSecrets
|
|
|
|
then ./private + "/${name}"
|
2022-11-11 23:24:40 +00:00
|
|
|
else builtins.toFile "missing-secret-file-${builtins.replaceStrings ["/"] [""] name}" "";
|
2020-12-16 18:26:20 +00:00
|
|
|
}
|