summaryrefslogtreecommitdiff
path: root/README.md
blob: cf41db676c38470117c23b8ba573db9bf0a86adb (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# nix-exprs

[![built with garnix](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fgarnix.io%2Fapi%2Fbadges%2Fgetchoo%2Fnix-exprs)](https://garnix.io)

## how to use

### enabling the binary cache

all packages are built with [garnix](https://garnix.io/), and cached on their servers. you can use this
yourself by following the instructions [here](https://garnix.io/docs/caching). i would also recommend
[donating](https://opencollective.com/garnix_io) if you can!

<details>
<summary>example</summary>

```nix
{
  nix.settings = {
    trusted-substituters = ["https://cache.garnix.io"];

    trusted-public-keys = ["cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="];
  };
}
```

</details>

### installing packages (flake)

you can add this repository as an input, and optionally override the nixpkgs input to build against
your own revision. from there, you can use packages as an overlay or install them directly

<details>
<summary>with the overlay</summary>

```nix
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    darwin = {
      url = "github:LnL7/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    getchoo = {
      url = "github:getchoo/nix-exprs";
      # this will break reproducibility, but lower the instances of nixpkgs
      # in flake.lock
      # inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    nixpkgs,
    getchoo,
    ...
  }: let
    getchooModule = {
      nixpkgs.overlays = [getchoo.overlays.default];
      environment.systemPackages = [pkgs.treefetch];
    };
  in {
    nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
      modules = [getchooModule];
    };

    darwinConfigurations.hostname = darwin.lib.darwinSystem {
      modules = [getchooModule];
    };
  };
}
```

</details>

<details>
<summary>directly</summary>

```nix
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    darwin = {
      url = "github:LnL7/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    getchoo = {
      url = "github:getchoo/nix-exprs";
      # this will break reproducibility, but lower the instances of nixpkgs
      # in flake.lock
      # inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    nixpkgs,
    getchoo,
    ...
  }: let
    getchooModule = ({pkgs, ...}: let
      inherit (pkgs.stdenv.hostPlatform) system;
    in {
      environment.systemPackages = [getchoo.packages.${system}.treefetch];
    });
  in {
    nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
      modules = [getchooModule];
    };

    darwinConfigurations.hostname = darwin.lib.darwinSystem {
      modules = [getchooModule];
    };
  };
}
```

</details>

### installing packages (without flakes)

this repository uses [flake-compat](https://github.com/edolstra/flake-compat) to allow for non-flake users to
import a channel or the `default.nix` to access the flake's outputs.

<details>
<summary>with the overlay</summary>

```nix
{pkgs, ...}: let
  # install with `nix-channel --add https://github.com/getchoo/nix-exprs/archive/main.tar.gz getchoo`
  getchoo = import <getchoo>;

  # or use `fetchTarball`
  # getchoo = import (builtins.fetchTarball "https://github.com/getchoo/nix-exprs/archive/main.tar.gz");
in {
  nixpkgs.overlays = [getchoo.overlays.default];
  environment.systemPackages = [pkgs.treefetch];
}
```

</details>

<details>
<summary>directly</summary>

```nix
{pkgs, ...}: let
  inherit (pkgs.stdenv.hostPlatform) system;

  # install with `nix-channel --add https://github.com/getchoo/nix-exprs/archive/main.tar.gz getchoo`
  getchoo = import <getchoo>;

  # or use `fetchTarball`
  # getchoo = import (builtins.fetchTarball "https://github.com/getchoo/nix-exprs/archive/main.tar.gz");
in {
  environment.systemPackages = [getchoo.packages.${system}.treefetch];
}
```

</details>

### ad-hoc installation

this flake can also be used in the base nix package manager :)

> **Note**
> for nixos/nix-darwin users, `nixpkgs.overlays` does not configure
> overlays for tools such as `nix(-)run`, `nix(-)shell`, etc. so this
> will also be required for you

the best way to make this overlay available for you is to
add it to your flake registry or `~/.config/nixpkgs/overlays.nix`.

<details>
<summary>flake registry</summary>

this is the preferred way to use this overlay in the cli, as it allows
for full reproducibility with the flake.

to use this overlay with commands like `nix build/run/shell/profile`, you can
add it to your flake registry:

```shell
nix registry add getchoo github:getchoo/nix-exprs
nix profile install getchoo#treefetch
```

</details>

<details>
<summary>overlays.nix</summary>

for those who don't want to use this flake's revision of nixpkgs,
or do not use flakes, you can also add it as an overlay.

first, add the channel for this repository with

```sh
nix-channel --add https://github.com/getchoo/nix-exprs/archive/main.tar.gz getchoo
```

then in `~/.config/nixpkgs/overlays.nix`:

```nix
let
  getchoo = import <getchoo>;
in [getchoo.overlays.default]
```

</details>