phoebe/lib/shell.nix
Peter Jones 4964d95974
rails: Support background workers and other Rails services/workers
The new `services' option is used to request additional processes be
run in the background with the same environment as the main Rails
process.
2019-01-04 11:17:40 -07:00

27 lines
655 B
Nix

# Functions for generating and working with shell scripts:
{ lib, pkgs, ... }:
with lib;
let
funcs = rec {
# Generate a shell script that exports the given variables.
#
# Type:
#
# string -> attrset -> derivation
#
# Arguments:
#
# fileName: The name of the file in the nix store to create.
# attrs: The variables to include in the generated script.
#
attrsToShellExports = fileName: attrs:
let export = name: value: "export ${name}=${escapeShellArg value}";
lines = mapAttrsToList export attrs;
in pkgs.writeText fileName (concatStringsSep "\n" lines);
};
in funcs