2024-07-11 22:14:11 -04:00
## Table of contents
2024-07-11 22:17:11 -04:00
- [`nix build` ](##`nix build` )
2024-07-11 22:14:11 -04:00
2024-07-11 22:15:11 -04:00
### `nix build`
Command to build nix packages, either locally sourced or from third parties (like nixpkgs)
2024-07-11 22:16:11 -04:00
### Example
#### Local
2024-07-11 22:21:11 -04:00
Set something to build inside your Nix flake (`flake.nix` ) then run `nix build` .
2024-07-11 22:18:11 -04:00
2024-07-11 22:21:11 -04:00
Here's an example you can put in Nix flake:
2024-07-11 22:19:11 -04:00
2024-07-11 22:21:11 -04:00
```nix
packages.default = pkgs.rustPlatform.buildRustPackage {
name = "zero-to-nix-rust";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
};
```
2024-07-11 22:22:11 -04:00
Then run:
2024-07-11 22:23:11 -04:00
`nix build`
2024-07-11 22:19:11 -04:00
2024-07-11 22:23:11 -04:00
to build your home brewed package!
2024-07-11 22:18:11 -04:00
#### Third party/Remote
2024-07-11 22:23:11 -04:00
You can either grab something from GitHub (using the `github:user/repo*#optional_pkg` ) or a URL (using the `https://scm.wyattjmiller.com/wymiller/cool-repo*#pkg` ).
Example from GitHub:
2024-07-11 22:24:11 -04:00
```bash
nix build "github:"
```
Example from a URL:
```bash
nix build "https://flakehub.com/f/NixOS/nixpkgs/*#bat "
```