nix writers short explanation
This commit is contained in:
parent
9df3d557ea
commit
bcc6a4ab66
60
sigma.md
Normal file
60
sigma.md
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
---
|
||||||
|
marp: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# NixOS
|
||||||
|
|
||||||
|
## Build your own ISO image from flake
|
||||||
|
|
||||||
|
```shell
|
||||||
|
nix run github:nix-community/nixos-generators -- -c ./flake.nix --flake '#ginoza' -f vm --disk-size 20480
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Nix writers
|
||||||
|
|
||||||
|
- Jednoduchý způsob přidávání skriptů v různých programovacích jazycích do systému
|
||||||
|
- [https://nixos.wiki/wiki/Nix-writers](https://nixos.wiki/wiki/Nix-writers) - pro všechny podporované jazyky
|
||||||
|
- Rozdíl oproti klasickému `pkgs.writeShellScriptBin`
|
||||||
|
- [nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/writers/scripts.nix) - pro všechny možnosti konfigurace skriptů
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```nix
|
||||||
|
pkgs.writers.writeBash "hello-world-bash" {}
|
||||||
|
''
|
||||||
|
echo "Hello world!"
|
||||||
|
''
|
||||||
|
|
||||||
|
pkgs.writers.writePython3 "hello-world-python" {}
|
||||||
|
''
|
||||||
|
print("Hello world!")
|
||||||
|
''
|
||||||
|
|
||||||
|
pkgs.writers.writeRust "hello-world-rust" {}
|
||||||
|
''
|
||||||
|
fn main() {
|
||||||
|
println!("Hello world!")
|
||||||
|
}
|
||||||
|
''
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
```nix
|
||||||
|
|
||||||
|
pkgs.writers.writePython3 "hello-world-python"
|
||||||
|
{
|
||||||
|
libraries = [ pkgs.python3Packages.requests ];
|
||||||
|
|
||||||
|
makeWrapperArgs = [
|
||||||
|
"--prefix", "PATH", ":", "${pkgs.sl}/bin",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
''
|
||||||
|
print("Hello world!")
|
||||||
|
''
|
||||||
|
|
||||||
|
```
|
||||||
Loading…
Reference in New Issue
Block a user