summaryrefslogtreecommitdiff
path: root/modules/curl.nix
blob: 68952620065ef8e43cbc30598424680abb324e8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  config,
  lib,
  pkgs,
  ...
}:
with lib;
let
  cfg = config.nixfiles.modules.curl;
in
{
  options.nixfiles.modules.curl.enable = mkEnableOption "cURL";

  config = mkIf cfg.enable {
    hm.xdg.configFile.".curlrc".text = ''
      connect-timeout = 60
      progress-bar
      remote-time
      show-error
    '';

    environment.systemPackages = with pkgs; [
      curl
      (writeShellScriptBin "0x0" ''
        url="https://0x0.st"
        form="file=@"

        if [ -t 0 ] && [ -n "$1" ]; then
            form="$form$1"
        else
            form="$form-"
        fi

        ${getExe curl} --form "$form" "$url"
      '')
    ];
  };
}