diff options
author | Vincent Ambo <mail@tazj.in> | 2022-01-30T16·06+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-01-31T16·11+0000 |
commit | aa122cbae78ce97d60c0c98ba14df753d97e40b1 (patch) | |
tree | 12b98d85c4b18fe870feb26de70db9ba61837bd7 /users/Profpatsch/lib.nix | |
parent | 2d10d60fac0fd00a71b65cfdcb9fba0477b2086c (diff) |
style: format entire depot with nixpkgs-fmt r/3723
This CL can be used to compare the style of nixpkgs-fmt against other formatters (nixpkgs, alejandra). Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: lukegb <lukegb@tvl.fyi> Reviewed-by: wpcarro <wpcarro@gmail.com> Reviewed-by: Profpatsch <mail@profpatsch.de> Reviewed-by: kanepyork <rikingcoding@gmail.com> Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: cynthia <cynthia@tvl.fyi> Reviewed-by: edef <edef@edef.eu> Reviewed-by: eta <tvl@eta.st> Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'users/Profpatsch/lib.nix')
-rw-r--r-- | users/Profpatsch/lib.nix | 79 |
1 files changed, 53 insertions, 26 deletions
diff --git a/users/Profpatsch/lib.nix b/users/Profpatsch/lib.nix index e3d59b7d8beb..879d87755d56 100644 --- a/users/Profpatsch/lib.nix +++ b/users/Profpatsch/lib.nix @@ -1,34 +1,49 @@ { depot, pkgs, ... }: let bins = depot.nix.getBins pkgs.coreutils [ "printf" "echo" "cat" "printenv" "tee" ] - // depot.nix.getBins pkgs.bash [ "bash" ] - // depot.nix.getBins pkgs.fdtools [ "multitee" ] - ; + // depot.nix.getBins pkgs.bash [ "bash" ] + // depot.nix.getBins pkgs.fdtools [ "multitee" ] + ; # Print `msg` and and argv to stderr, then execute into argv - debugExec = msg: depot.nix.writeExecline "debug-exec" {} [ - "if" [ - "fdmove" "-c" "1" "2" - "if" [ bins.printf "%s: " msg ] - "if" [ bins.echo "$@" ] + debugExec = msg: depot.nix.writeExecline "debug-exec" { } [ + "if" + [ + "fdmove" + "-c" + "1" + "2" + "if" + [ bins.printf "%s: " msg ] + "if" + [ bins.echo "$@" ] ] "$@" ]; # Print stdin to stderr and stdout - eprint-stdin = depot.nix.writeExecline "eprint-stdin" {} [ - "pipeline" [ bins.multitee "0-1,2" ] "$@" + eprint-stdin = depot.nix.writeExecline "eprint-stdin" { } [ + "pipeline" + [ bins.multitee "0-1,2" ] + "$@" ]; # Assume the input on stdin is netencode, pretty print it to stderr and forward it to stdout - eprint-stdin-netencode = depot.nix.writeExecline "eprint-stdin-netencode" {} [ - "pipeline" [ + eprint-stdin-netencode = depot.nix.writeExecline "eprint-stdin-netencode" { } [ + "pipeline" + [ # move stdout to 3 - "fdmove" "3" "1" + "fdmove" + "3" + "1" # the multitee copies stdin to 1 (the other pipeline end) and 3 (the stdout of the outer pipeline block) - "pipeline" [ bins.multitee "0-1,3" ] + "pipeline" + [ bins.multitee "0-1,3" ] # make stderr the stdout of pretty, merging with the stderr of pretty - "fdmove" "-c" "1" "2" + "fdmove" + "-c" + "1" + "2" depot.users.Profpatsch.netencode.pretty ] "$@" @@ -36,9 +51,11 @@ let # print the given environment variable in $1 to stderr, then execute into the rest of argv eprintenv = depot.nix.writeExecline "eprintenv" { readNArgs = 1; } [ - "ifelse" [ "fdmove" "-c" "1" "2" bins.printenv "$1" ] + "ifelse" + [ "fdmove" "-c" "1" "2" bins.printenv "$1" ] [ "$@" ] - "if" [ depot.tools.eprintf "eprintenv: could not find \"\${1}\" in the environment\n" ] + "if" + [ depot.tools.eprintf "eprintenv: could not find \"\${1}\" in the environment\n" ] "$@" ]; @@ -52,24 +69,34 @@ let # stdout: foo\n # stderr: foo\nbar\n split-stdin = depot.nix.writeExecline "split-stdin" { argMode = "env"; } [ - "pipeline" [ + "pipeline" + [ # this is horrible yes but the quickest way I knew how to implement it - "runblock" "1" bins.bash "-c" ''${bins.tee} >("$@")'' "bash-split-stdin" + "runblock" + "1" + bins.bash + "-c" + ''${bins.tee} >("$@")'' + "bash-split-stdin" ] - "runblock" "-r" "1" + "runblock" + "-r" + "1" ]; # remove everything but a few selected environment variables runInEmptyEnv = keepVars: let - importas = pkgs.lib.concatMap (var: [ "importas" "-i" var var ]) keepVars; - # we have to explicitely call export here, because PATH is probably empty - export = pkgs.lib.concatMap (var: [ "${pkgs.execline}/bin/export" var ''''${${var}}'' ]) keepVars; - in depot.nix.writeExecline "empty-env" {} - (importas ++ [ "emptyenv" ] ++ export ++ [ "${pkgs.execline}/bin/exec" "$@" ]); + importas = pkgs.lib.concatMap (var: [ "importas" "-i" var var ]) keepVars; + # we have to explicitely call export here, because PATH is probably empty + export = pkgs.lib.concatMap (var: [ "${pkgs.execline}/bin/export" var ''''${${var}}'' ]) keepVars; + in + depot.nix.writeExecline "empty-env" { } + (importas ++ [ "emptyenv" ] ++ export ++ [ "${pkgs.execline}/bin/exec" "$@" ]); -in { +in +{ inherit debugExec eprint-stdin |