nix language
This commit is contained in:
parent
8f3a1b443b
commit
88db5fdb43
@ -1,7 +1,8 @@
|
|||||||
# Nix
|
# Nix
|
||||||
|
|
||||||
- [ ] Nix scripts
|
- [ ] Nix scripts
|
||||||
- [ ] Nix home-manager
|
- [ ] Nix home-manager, standalone vs sysconfig module
|
||||||
|
- [ ] Plasma manager
|
||||||
- [ ] Stylix
|
- [ ] Stylix
|
||||||
- [ ] NixOS Everywhere, NixOS Anywhere
|
- [ ] NixOS Everywhere, NixOS Anywhere
|
||||||
- [x] Inputs in Nix
|
- [x] Inputs in Nix
|
||||||
@ -12,7 +13,7 @@
|
|||||||
- [ ] Impermanence
|
- [ ] Impermanence
|
||||||
- [x] Own nixos ISO
|
- [x] Own nixos ISO
|
||||||
- [ ] NixOS helper
|
- [ ] NixOS helper
|
||||||
- [ ] NixOS builders and writers
|
- [x] NixOS builders and writers
|
||||||
- [ ] Ovverrides and overlays
|
- [ ] Ovverrides and overlays
|
||||||
- [ ] Nix Shell
|
- [ ] Nix Shell
|
||||||
- [x] Nix writers
|
- [x] Nix writers
|
||||||
|
|||||||
@ -4,6 +4,7 @@ class: invert
|
|||||||
paginate: true
|
paginate: true
|
||||||
footer: "Albert Vala, Filip Kohout, Nix flakes & Nix command"
|
footer: "Albert Vala, Filip Kohout, Nix flakes & Nix command"
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap');
|
@import url('https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap');
|
||||||
:root {
|
:root {
|
||||||
@ -69,16 +70,22 @@ nix run nixpkgs#cowsay #New
|
|||||||
* Cokoliv.
|
* Cokoliv.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Nix command + flakes
|
# Nix command + flakes
|
||||||
|
|
||||||
- temp shell
|
- temp shell
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix shell nixpkgs#alejandra
|
nix shell nixpkgs#alejandra
|
||||||
nix shell github:kamadorueda/alejandra
|
nix shell github:kamadorueda/alejandra
|
||||||
```
|
```
|
||||||
|
|
||||||
- Show output attr
|
- Show output attr
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix flake show github:kamadorueda/alejandra
|
nix flake show github:kamadorueda/alejandra
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Jak použít flakes na systémovou configuraci?
|
# Jak použít flakes na systémovou configuraci?
|
||||||
@ -145,7 +152,9 @@ nix flake show github:kamadorueda/alejandra
|
|||||||
programs.home-manager.enable = true;
|
programs.home-manager.enable = true;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
#configuration.nix
|
#configuration.nix
|
||||||
{
|
{
|
||||||
@ -179,11 +188,11 @@ nix flake show github:kamadorueda/alejandra
|
|||||||
* `nix flake update [home-manager]` - aktualizace jednoho vstupu
|
* `nix flake update [home-manager]` - aktualizace jednoho vstupu
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11";
|
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-24.11";
|
||||||
nixpkgs-current = "github:nixos/nixpkgs?ref=3058cf84bce1aba7b1820cb24319a171572217ba-dirty";
|
nixpkgs-current = "github:nixos/nixpkgs?ref=3058cf84bce1aba7b1820cb24319a171572217ba-dirty";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -212,23 +221,72 @@ nix build /etc/nixos#nixosConfigurations.nixos.config.system.build.toplevel
|
|||||||
* `--build-host` - konfigurace tady
|
* `--build-host` - konfigurace tady
|
||||||
* `--target-host` - konfigurace tam
|
* `--target-host` - konfigurace tam
|
||||||
|
|
||||||
|
* `nix.settings.trusted-users`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Virtual machine
|
# Virtual machine
|
||||||
|
|
||||||
* `nix run github:nix-community/nixos-generators -- -c ./flake.nix --flake '#default' -f vm --disk-size 20480`
|
* `nix run github:nix-community/nixos-generators -- -c ./flake.nix --flake '#default' -f vm --disk-size 20480`
|
||||||
|
* možnost generovat pro různé platformy (Amazon E2C, Docker, ISO, Proxmox, VMware, vagrant, qcow, ...)
|
||||||
|
* [https://github.com/nix-community/nixos-generators](https://github.com/nix-community/nixos-generators)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# Nix language
|
||||||
|
|
||||||
|
* `nix-repl` nebo `nix-instantiate --eval foo.nix`
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# Deklarace setu
|
||||||
|
foo = {
|
||||||
|
bar = "test"
|
||||||
|
}
|
||||||
|
|
||||||
|
# "Čtení" setu (evaluation)
|
||||||
|
foo.bar
|
||||||
|
|
||||||
|
# Let-In syntaxe
|
||||||
|
let
|
||||||
|
foo = {
|
||||||
|
bar = "test"
|
||||||
|
};
|
||||||
|
in
|
||||||
|
foo.bar
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# Rekurze
|
||||||
|
foo = rec {
|
||||||
|
bar = 10;
|
||||||
|
ham = 5;
|
||||||
|
eggs = bar + ham;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# Použití with
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
neovim
|
||||||
|
wireshark
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Nix writers
|
# Nix writers
|
||||||
|
|
||||||
* Jednoduchý způsob přidávání skriptů v různých programovacích jazycích do
|
* Jednoduchý způsob přidávání skriptů v různých programovacích jazycích do
|
||||||
systému ve flake konfiguraci
|
systému
|
||||||
* Rozdíl oproti klasickému `pkgs.writeShellScriptBin`
|
* Rozdíl oproti klasickému `pkgs.writeShellScriptBin`
|
||||||
* [nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/writers/scripts.nix) -
|
* [nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/writers/scripts.nix) - pro všechny možnosti konfigurace skriptů
|
||||||
pro všechny možnosti konfigurace skriptů
|
* [https://nixos.wiki/wiki/Nix-writers](https://nixos.wiki/wiki/Nix-writers) - osekaná wiki
|
||||||
* [https://nixos.wiki/wiki/Nix-writers](https://nixos.wiki/wiki/Nix-writers) -
|
|
||||||
osekaná wiki
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user