summaryrefslogtreecommitdiff
path: root/README.md
blob: e44cdf871f4302072b6ac156107e55fca782a039 (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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# nix-exprs

[![Build status](https://img.shields.io/github/actions/workflow/status/getchoo/nix-exprs/ci.yaml?style=flat-square&logo=github&label=Build%20status&color=5277c3)](https://github.com/getchoo/nix-exprs/actions/workflows/ci.yaml)
[![FlakeHub](https://img.shields.io/endpoint?url=https://flakehub.com/f/getchoo/nix-exprs/badge)](https://flakehub.com/flake/getchoo/nix-exprs)

## how to use

### enabling the binary cache

all packages are cached by [cachix](https://cachix.org). to enable it, you can run
`nix run nixpkgs#cachix use getchoo`. it may may also be used in the `nixConfig` attribute
of flakes or in a system configuration.

<details>
<summary>example</summary>

```nix
{pkgs, ...}: {
  nix.settings = {
    trusted-substituters = ["https://getchoo.cachix.org"];
    trusted-public-keys = ["getchoo.cachix.org-1:ftdbAUJVNaFonM0obRGgR5+nUmdLMM+AOvDOSx0z5tE="];
  };
}
```

</details>

### flake-based

flakes are the primary supported method to use this repository - and in my opinion, can offer a much
nicer user experience :)

#### installing packages

you can add this repository as an input, and optionally override the nixpkgs input to build against
your own revision of nixpkgs

```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 and possibly duplicated dependencies
      # inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    nixpkgs,
    getchoo,
    ...
  }: {
    nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        ./configuration.nix

        ({pkgs, ...}: {
          environment.systemPackages = with getchoo.packages.${pkgs.system}; [
            treefetch
          ];
        })
      ];
    };
  };
}
```

<details>
<summary>using the overlay</summary>

the overlay (though not preferred for the sake of reproducibility) is also an
option for those who want to avoid the verbosity of installing packages directly,
a "plug-n-play" solution to using the packages, and/or a reduction in duplicated dependencies.

```nix
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    darwin = {
      url = "github:LnL7/nix-darwin";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    getchoo = {
      url = "github:getchoo/nix-exprs";
      # this should probably be used in this scenario as reproducibility is
      # already broken by using an overlay
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    nixpkgs,
    getchoo,
    ...
  }: {
    nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        ./configuration.nix

        ({pkgs, ...}: {
          nixpkgs.overlays = [getchoo.overlays.default];
          environment.systemPackages = with pkgs; [
            treefetch
          ];
        })
      ];
    };
  };
}
```

</details>

#### ad-hoc installation

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

the best way to make these packages available for you is to
add it to your flake registry like so.

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

### standard nix

this repository uses [flake-compat](https://github.com/edolstra/flake-compat) to allow for non-flake environments to use the packages provided.

there are two ways to do this: through channels or `fetchTarball` (or similar functions). i personally recommend
channels as they are the easiest to update - though if you want to pin a specific revision of this repository,
`fetchTarball` would probably be a better alternative.

to add the channel, run:

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

```

to use `fetchTarball`, please view the [documentation](https://nixos.org/manual/nix/stable/language/builtins.html?highlight=fetchtarball#builtins-fetchTarball) as there are a fair number of ways to use it.
at it's most basic, you could use this:

```nix
{
  getchoo = import (builtins.fetchTarball "https://github.com/getchoo/nix-exprs/archive/main.tar.gz");
}
```

#### installing packages

```nix
{pkgs, ...}: let
  # if you use channels
  getchoo = import <getchoo>;

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

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

```nix
{pkgs, ...}: let
  # if you use channels
  getchoo = import <getchoo>;

  # or if you 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>

#### ad-hoc installation

there are two ways to use ad-hoc commands: through channels or `overlays.nix`.

channels are again then the preferred method here, where once it's added it can be used
like so:

```sh
nix-env -f '<getchoo>' -iA getchoo.packages.x86_64-linux.treefetch # replace x86_64-linux with your system
nix-shell '<getchoo>' -p treefetch
```

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

for those who don't want to use this flake's revision of nixpkgs - or have the verbosity
of the `flake-compat` provided commands - `overlays.nix` is a good option.

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

```nix
let
  # if you use channels
  getchoo = import <getchoo>;

  # or if you use `fetchTarball`
  # getchoo = import (builtins.fetchTarball "https://github.com/getchoo/nix-exprs/archive/main.tar.gz");
in [getchoo.overlays.default]
```

</details>