From a15388c7adb1d7a038e624900bafad19a8c1d08a Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Thu, 3 Mar 2022 13:53:14 -0500 Subject: [PATCH] docs: document nixos installation --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.md b/README.md index db7d855..47a0d1e 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,56 @@ Then run Alejandra with: $ alejandra --help ``` +### NixOS installation + +- Nix with [Flakes](https://nixos.wiki/wiki/Flakes): + + ```nix + { + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + + alejandra.url = "github:kamadorueda/alejandra/0.7.0"; + alejandra.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = {alejandra, nixpkgs, ...}: { + nixosConfigurations = { + example = nixpkgs.lib.nixosSystem rec { + # We support: aarch64-linux, aarch64-linux, x86_64-darwin, x86_64-linux + system = "x86_64-linux"; + + modules = [ + { + environment.systemPackages = [alejandra.defaultPackage.${system}]; + } + # Import your other modules here + # ./path/to/my/module.nix + # ... + ]; + }; + }; + }; + } + ``` + +- Nix stable: + + ```nix + let + alejandra = + (import (builtins.fetchTarball { + url = "https://github.com/kamadorueda/alejandra/tarball/0.7.0"; + sha256 = "0kqkwi4j1d0n334jl3q6x70ga8jqmqpv514zsbfca2a86c7qs6cf"; + })) + # Pick one from: aarch64-linux, aarch64-linux, x86_64-darwin, x86_64-linux + .x86_64-linux + .outPath; + in { + environment.systemPackages = [alejandra]; + } + ``` + ## Do I need to configure anything? - No.