nix lang explain
This commit is contained in:
parent
88db5fdb43
commit
3b91f038e6
@ -250,7 +250,7 @@ foo.bar
|
|||||||
let
|
let
|
||||||
foo = {
|
foo = {
|
||||||
bar = "test"
|
bar = "test"
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
foo.bar
|
foo.bar
|
||||||
```
|
```
|
||||||
@ -276,7 +276,74 @@ foo.bar
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Funkce
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# Jednoduchá funkce
|
||||||
|
let
|
||||||
|
bar = eggs: eggs + 1;
|
||||||
|
in
|
||||||
|
bar 3 # -> 4
|
||||||
|
|
||||||
|
# Funkce s více parametry
|
||||||
|
let
|
||||||
|
bar = eggs: bacon: (eggs+1) * bacon;
|
||||||
|
in
|
||||||
|
bar 3 7 # -> 28
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```nix
|
||||||
|
let
|
||||||
|
bar = { bacon, eggs }: bacon + eggs;
|
||||||
|
in
|
||||||
|
bar { bacon = 10; eggs = 15; }
|
||||||
|
```
|
||||||
|
|
||||||
|
* konfigurační soubory jsou funkce
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# configuration.nix
|
||||||
|
{inputs, pkgs}:
|
||||||
|
{
|
||||||
|
environment.systemPackages = [
|
||||||
|
inputs.zen-browser.packages.${system}.default
|
||||||
|
pkgs.gcc
|
||||||
|
];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```nix
|
||||||
|
let
|
||||||
|
bar = { bacon ? 10, eggs, ... }: bacon + eggs;
|
||||||
|
in
|
||||||
|
bar { eggs = 15; bread = 30 }
|
||||||
|
```
|
||||||
|
|
||||||
|
```nix
|
||||||
|
let
|
||||||
|
bar = { bacon ? 10, ... }@arguments:
|
||||||
|
bacon + arguments.eggs;
|
||||||
|
in
|
||||||
|
bar { eggs = 15; bread = 30; }
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```nix
|
||||||
|
outputs = inputs @ {
|
||||||
|
nixpkgs,
|
||||||
|
home-manager,
|
||||||
|
zen-browser,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
nixosConfigurations = {
|
||||||
|
nixos = nixpkgs.lib.nixosSystem {
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user