about summary refs log tree commit diff
path: root/modules/common/curl.nix
blob: 97b4b5555b9a8d5896b7782843750305cf448610 (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
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.curl;
in {
  options.nixfiles.modules.curl.enable = mkEnableOption "cURL";

  config = mkIf cfg.enable {
    hm.home.file.".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"
      '')
    ];
  };
}

Consider giving Nix/NixOS a try! <3