2021-01-29 15:52:31 +01:00
|
|
|
{ depot, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
2021-04-23 22:04:42 +02:00
|
|
|
exec-helpers = depot.nix.writers.rustSimpleLib
|
|
|
|
{
|
2021-01-29 15:52:31 +01:00
|
|
|
name = "exec-helpers";
|
2021-01-31 15:47:49 +01:00
|
|
|
}
|
|
|
|
(builtins.readFile ./exec_helpers.rs);
|
2021-01-29 15:52:31 +01:00
|
|
|
|
2022-01-09 01:20:46 +01:00
|
|
|
print-one-env = depot.nix.writers.rustSimple
|
|
|
|
{
|
|
|
|
name = "print-one-env";
|
|
|
|
dependencies = [
|
|
|
|
depot.users.Profpatsch.execline.exec-helpers
|
|
|
|
];
|
|
|
|
} ''
|
|
|
|
extern crate exec_helpers;
|
|
|
|
use std::os::unix::ffi::OsStrExt;
|
|
|
|
use std::io::Write;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let args = exec_helpers::args("print-one-env", 1);
|
|
|
|
let valname = std::ffi::OsStr::from_bytes(&args[0]);
|
|
|
|
match std::env::var_os(&valname) {
|
|
|
|
None => exec_helpers::die_user_error("print-one-env", format!("Env variable `{:?}` is not set", valname)),
|
|
|
|
Some(val) => std::io::stdout().write_all(&val.as_bytes()).unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2021-11-23 14:31:17 +01:00
|
|
|
in
|
|
|
|
depot.nix.readTree.drvTargets {
|
2021-01-29 15:52:31 +01:00
|
|
|
inherit
|
|
|
|
exec-helpers
|
2022-01-09 01:20:46 +01:00
|
|
|
print-one-env
|
2021-01-29 15:52:31 +01:00
|
|
|
;
|
|
|
|
}
|