diff --git a/prezentace.md b/prezentace.md index 418e911..7231cd5 100644 --- a/prezentace.md +++ b/prezentace.md @@ -250,7 +250,7 @@ foo.bar let foo = { bar = "test" - }; + }; in 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 { +... +``` ---