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
- [ ] Stylix
- [ ] NixOS Everywhere, NixOS Anywhere
- [ ] Inputs in Nix
- [ ] Nix language
- [x] Inputs in Nix
- [ ] Nix language (if else statements, pipes, and other interesting things)
- [ ] Nix Modules
- [ ] Vlastní options
- [ ] Nix fetching
@ -16,4 +16,4 @@
- [ ] Ovverrides and overlays
- [ ] Nix Shell
- [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
* Jednoduchý způsob přidávání skriptů v různých programovacích jazycích do systému ve flake konfiguraci
* 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ů
* [https://nixos.wiki/wiki/Nix-writers](https://nixos.wiki/wiki/Nix-writers) - osekaná wiki
- Jednoduchý způsob přidávání skriptů v různých programovacích jazycích do
systému ve flake konfiguraci
- 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ů
- [https://nixos.wiki/wiki/Nix-writers](https://nixos.wiki/wiki/Nix-writers) -
osekaná wiki
---
```nix
pkgs.writers.writeBash "hello-world-bash" {}
pkgs.writers.writeBash "hello-world-bash" {}
''
echo "Hello world!"
''
pkgs.writers.writePython3 "hello-world-python" {}
pkgs.writers.writePython3 "hello-world-python" {}
''
print("Hello world!")
''
pkgs.writers.writeRust "hello-world-rust" {}
pkgs.writers.writeRust "hello-world-rust" {}
''
fn main() {
println!("Hello world!")
@ -204,18 +223,16 @@ fn main() {
---
```nix
pkgs.writers.writePython3 "hello-world-python"
pkgs.writers.writePython3 "hello-world-python"
{
libraries = [ pkgs.python3Packages.requests ];
makeWrapperArgs = [
"--prefix", "PATH", ":", "${pkgs.sl}/bin",
];
}
}
''
print("Hello world!")
''
```