A layer on top of the NixOS module system to make some tasks simpler.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shell.nix 655B

123456789101112131415161718192021222324252627
  1. # Functions for generating and working with shell scripts:
  2. { lib, pkgs, ... }:
  3. with lib;
  4. let
  5. funcs = rec {
  6. # Generate a shell script that exports the given variables.
  7. #
  8. # Type:
  9. #
  10. # string -> attrset -> derivation
  11. #
  12. # Arguments:
  13. #
  14. # fileName: The name of the file in the nix store to create.
  15. # attrs: The variables to include in the generated script.
  16. #
  17. attrsToShellExports = fileName: attrs:
  18. let export = name: value: "export ${name}=${escapeShellArg value}";
  19. lines = mapAttrsToList export attrs;
  20. in pkgs.writeText fileName (concatStringsSep "\n" lines);
  21. };
  22. in funcs