Skip to content

Commit

Permalink
docs: add installation guide for nix flakes (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
musjj authored Mar 19, 2024
1 parent c9c4b36 commit 73cc537
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,81 @@ environment.systemPackages = with pkgs; [

You can also manage Yazi's configuration using [home-manager](https://nix-community.github.io/home-manager/options.xhtml#opt-programs.yazi.enable).

## Flake

The upstream repository provides a flake so that Nix users can easily keep up with the bleeding edge. A basic `flake.nix` setup to get you started:

```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
yazi.url = "github:sxyazi/yazi";
};
outputs = { nixpkgs, home-manager, yazi, ... }: {
# To install yazi system-wide:
nixosConfigurations = {
nixos = nixpkgs.lib.nixosSystem {
modules = [
({ pkgs, ... }: {
environment.systemPackages =
[ yazi.packages.${pkgs.system}.default ];
})
];
};
};
# To install it for a specific user:
homeConfigurations = {
"alice@nixos" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [
({ pkgs, ... }: {
home.packages = [ yazi.packages.${pkgs.system}.default ];
})
];
};
};
};
}
```

If you want to override the package inside nixpkgs with the one from the flake, you can use overlays:

```nix
nixpkgs.overlays = [ yazi.overlays.default ];
```

A module is also available for both NixOS and home-manager:

```nix
programs.yazi = {
enable = true;
package = yazi.packages.${pkgs.system}.default; # if you use overlays, you can omit this
};
```

### Cache

Pre-built artifacts are served at https://yazi.cachix.org, so that Nix users don't have to build Yazi on their machine.
You can make use of it by adding the following options to `nix.settings`, either in your NixOS or home-manager configuration:

```nix
extra-substituters = [ "https://yazi.cachix.org" ];
extra-trusted-public-keys =
[ "yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k=" ];
```

Note that the cache will only be applied _after_ you rebuild your Nix config. If you want to ensure that the cache gets applied right away, add the options above to your flake's `nixConfig` attribute.

If you're having any problems, refer to this [entry](https://docs.cachix.org/faq#why-is-nix-not-picking-up-on-any-of-the-pre-built-artifacts) from Cachix's FAQ.

## MacPorts

```bash
Expand Down

0 comments on commit 73cc537

Please sign in to comment.