about summary refs log tree commit diff
path: root/modules/curl.nix
blob: 3c318fc5d62c82a8286f9644f650e0ec20ff084c (plain) (blame)
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; [
      curlHTTP3
      (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"
      '')
    ];
  };
}

Consider giving Nix/NixOS a try! <3