remote building and vm

This commit is contained in:
foglar 2025-03-14 09:31:44 +01:00
parent e6e4ccc0bb
commit 8277a2ca7b
2 changed files with 31 additions and 14 deletions

View File

@ -4,8 +4,8 @@
- [ ] Nix home-manager - [ ] Nix home-manager
- [ ] Stylix - [ ] Stylix
- [ ] NixOS Everywhere, NixOS Anywhere - [ ] NixOS Everywhere, NixOS Anywhere
- [ ] Inputs in Nix - [x] Inputs in Nix
- [ ] Nix language - [ ] Nix language (if else statements, pipes, and other interesting things)
- [ ] Nix Modules - [ ] Nix Modules
- [ ] Vlastní options - [ ] Vlastní options
- [ ] Nix fetching - [ ] Nix fetching
@ -16,4 +16,4 @@
- [ ] Ovverrides and overlays - [ ] Ovverrides and overlays
- [ ] Nix Shell - [ ] Nix Shell
- [x] Nix writers - [x] Nix writers
- [ ] [Nixhub](https://www.nixhub.io/) - [ ] [Nixhub](https://www.nixhub.io/)

View File

@ -173,27 +173,46 @@ nix build /etc/nixos#nixosConfigurations.nixos.config.system.build.toplevel \
--- ---
# Remote building
- `nixos-rebuild --target-host nixFreak@192.168.8.32 switch --flake .#default`
- `--use-remote-sudo`
- `--build-host` - konfigurace tady
- `--target-host` - konfigurace tam
---
# Virtual machine
`nix run github:nix-community/nixos-generators -- -c ./flake.nix --flake '#default' -f vm --disk-size 20480`
---
# Nix writers # Nix writers
* Jednoduchý způsob přidávání skriptů v různých programovacích jazycích do systému ve flake konfiguraci - Jednoduchý způsob přidávání skriptů v různých programovacích jazycích do
* Rozdíl oproti klasickému `pkgs.writeShellScriptBin` systému ve flake konfiguraci
* [nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/writers/scripts.nix) - pro všechny možnosti konfigurace skriptů - Rozdíl oproti klasickému `pkgs.writeShellScriptBin`
* [https://nixos.wiki/wiki/Nix-writers](https://nixos.wiki/wiki/Nix-writers) - osekaná wiki - [nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/writers/scripts.nix) -
pro všechny možnosti konfigurace skriptů
- [https://nixos.wiki/wiki/Nix-writers](https://nixos.wiki/wiki/Nix-writers) -
osekaná wiki
--- ---
```nix ```nix
pkgs.writers.writeBash "hello-world-bash" {} pkgs.writers.writeBash "hello-world-bash" {}
'' ''
echo "Hello world!" echo "Hello world!"
'' ''
pkgs.writers.writePython3 "hello-world-python" {} pkgs.writers.writePython3 "hello-world-python" {}
'' ''
print("Hello world!") print("Hello world!")
'' ''
pkgs.writers.writeRust "hello-world-rust" {} pkgs.writers.writeRust "hello-world-rust" {}
'' ''
fn main() { fn main() {
println!("Hello world!") println!("Hello world!")
@ -204,18 +223,16 @@ fn main() {
--- ---
```nix ```nix
pkgs.writers.writePython3 "hello-world-python"
pkgs.writers.writePython3 "hello-world-python"
{ {
libraries = [ pkgs.python3Packages.requests ]; libraries = [ pkgs.python3Packages.requests ];
makeWrapperArgs = [ makeWrapperArgs = [
"--prefix", "PATH", ":", "${pkgs.sl}/bin", "--prefix", "PATH", ":", "${pkgs.sl}/bin",
]; ];
} }
'' ''
print("Hello world!") print("Hello world!")
'' ''
``` ```