⛩️ Powerful yet Minimal Nix Dependency Manager
flake flakes home-manager nixos go nix dependency dependencies
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: add nixpkgs examples

Fuwn bafff374 aee37e95

+104 -2
+1 -1
.gitignore
··· 1 1 /yae 2 2 .pre-commit-config.yaml 3 3 result 4 - yae.json 4 + /yae.json
+18 -1
README.md
··· 109 109 To add Yae support to your Nix expression after running `yae init`, just read 110 110 from the Yae environment file. See the example below for more details. 111 111 112 - ### Nix Example 112 + ### Examples 113 + 114 + Check out [`examples/nixpkgs`](./examples/nixpkgs) for a pure Nix example of Yae 115 + in action. This example is a little large since it constrains itself to **zero** 116 + inputs and manually constructs multi-system support. In a real-world scenario, 117 + you'd actually use something like [flake-utils](https://github.com/numtide/flake-utils) 118 + to replace all of the boilerplate. For this reason, [`examples/nixpkgs-simple`](./examples/nixpkgs-simple) 119 + exists, which functions identically, but uses `builtins.currentSystem` to 120 + populate the `nixpkgs.system` attribute. (requires `--impure`) 121 + 122 + If Nixpkgs ever goes out of date in these theorectical examples, just run 123 + `yae update`! 124 + 125 + #### Real-world Example 113 126 114 127 Here's an example snippet taken from Tsutsumi's [`zen-browser-bin` package](https://github.com/Fuwn/tsutsumi/blob/main/pkgs/zen-browser-bin.nix) 115 128 and [`yae.json`](https://github.com/Fuwn/tsutsumi/blob/main/yae.json#L59-L67) 116 129 showcasing Yae in action. 130 + 131 + <details closed> 132 + <summary>Expand this!</summary> 117 133 118 134 ```nix 119 135 # pkgs/zen-browser-bin.nix ··· 146 162 # inherit (yae.zen-browser-twilight-bin) sha256 version; 147 163 } { inherit pkgs; } 148 164 ``` 165 + </details> 149 166 150 167 ## `--help` 151 168
+18
examples/nixpkgs-simple/flake.nix
··· 1 + { 2 + outputs = 3 + { self }: 4 + let 5 + nixpkgs = (builtins.fromJSON (builtins.readFile "${self}/yae.json")).nixpkgs; 6 + 7 + pkgs = 8 + import 9 + (builtins.fetchTarball { 10 + inherit (nixpkgs) url sha256; 11 + }) 12 + { 13 + }; 14 + in 15 + { 16 + packages.${pkgs.system}.hello = pkgs.hello; 17 + }; 18 + }
+10
examples/nixpkgs-simple/yae.json
··· 1 + { 2 + "nixpkgs": { 3 + "url": "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz", 4 + "sha256": "1wn29537l343lb0id0byk0699fj0k07m1n2d7jx2n0ssax55vhwy", 5 + "unpack": true, 6 + "type": "git", 7 + "version": "nixos-unstable", 8 + "url_template": "https://github.com/NixOS/nixpkgs/archive/{version}.tar.gz" 9 + } 10 + }
+47
examples/nixpkgs/flake.nix
··· 1 + { 2 + outputs = 3 + { self }: 4 + let 5 + nixpkgs = (builtins.fromJSON (builtins.readFile "${self}/yae.json")).nixpkgs; 6 + 7 + systemsFlakeExposed = [ 8 + "x86_64-linux" 9 + "aarch64-linux" 10 + "x86_64-darwin" 11 + "armv6l-linux" 12 + "armv7l-linux" 13 + "i686-linux" 14 + "aarch64-darwin" 15 + "powerpc64le-linux" 16 + "riscv64-linux" 17 + "x86_64-freebsd" 18 + ]; 19 + 20 + forEachSystem = 21 + systems: action: 22 + builtins.listToAttrs ( 23 + map (system: { 24 + name = system; 25 + value = action system; 26 + }) systems 27 + ); 28 + in 29 + { 30 + packages = (forEachSystem systemsFlakeExposed) ( 31 + system: 32 + let 33 + pkgs = 34 + import 35 + (builtins.fetchTarball { 36 + inherit (nixpkgs) url sha256; 37 + }) 38 + { 39 + inherit system; 40 + }; 41 + in 42 + { 43 + hello = pkgs.hello; 44 + } 45 + ); 46 + }; 47 + }
+10
examples/nixpkgs/yae.json
··· 1 + { 2 + "nixpkgs": { 3 + "url": "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz", 4 + "sha256": "1wn29537l343lb0id0byk0699fj0k07m1n2d7jx2n0ssax55vhwy", 5 + "unpack": true, 6 + "type": "git", 7 + "version": "nixos-unstable", 8 + "url_template": "https://github.com/NixOS/nixpkgs/archive/{version}.tar.gz" 9 + } 10 + }