about summary refs log tree commit diff
path: root/modules/common/curl.nix
blob: e7bee31725946b25dd6aa9a62118851021d3d94a (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 "Wether to enable cURL.";

  config = mkIf cfg.enable {
    hm.home.file.".curlrc".text = ''
      connect-timeout = 60
      progress-bar
      referer = ";auto"
      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

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

Consider giving Nix/NixOS a try! <3