Signal drop!
Relay (operand.online) is unreachable.
Usually, a dropped signal means an upgrade is happening. Hold on!
Sorry, no connección.
Hang in there while we get back on track
gram: nue
> ./incus.nu
def "incus clean" [...names: string] {
let names = $names | replace ($in | is-empty) { (incus ls).name }
print "cleaning" $names
$names | each {
try { incus stop $in }
incus delete $in
} }
def "incus choose" [--many (-m)] { (incus ls).name | choose --many=$many }
# incus pause (incus ls).name.0
# incus resume (incus ls).name.0
# incus restart (incus ls).name.0
# incus shell (incus ls).name.0
def "incus sh" [name?: string] {
let name = $name | assure { (incus ls).name | choose }
incus shell $name
}
# container
def "incus compile c" [label: string, code: string] {
try { (incus image import --reuse --alias $label
(glob (nix build $"($code).config.system.build.metadata" --print-out-paths)/tarball/*.tar.xz).0
(glob (nix build $"($code).config.system.build.squashfs" --print-out-paths)/*.squashfs).0
) } }
# virtual machine
def "incus compile m" [label: string, code: string] {
(incus image import --alias $label
(glob (nix build $"($code).config.system.build.metadata" --print-out-paths)/tarball/*.tar.xz).0
(glob (nix build $"($code).config.system.build.qemuImage" --print-out-paths)/*.qcow2).0
) }
def "incus ls" [label?: string] {
incus list -f json
| from json
# | reject -o auto_update architecture public expires_at profiles project created_at cached
# | to yaml
}
def "incus image ls" [] {
incus image list -f json
| from json
}
def "incus bind" [pod: string, label: string, source: path, bind: path] {
incus config device add $pod $label disk source=($source) path=($bind)
}
# https://blog.simos.info/useful-networking-tips-with-incus/
def "incus signal" [
pod: string,
--signal (-s): string = "incusbr0",
address: string,
] {
incus config device set $pod $signal ipv4.address=($address)
# incus config device override $name eth0@if36 ipv4.address=10.0.100.250
# incus --help
# incus list -c ns4t
# incus config device --help
# incus config device show (incus ls).name.0
# incus config device unset $name eth0 ipv4.address
# incus config device override $name eth0 ipv4.address=10.0.100.250
# incus config device set $name eth0 ipv4.address=10.0.100.250
# incus config device show $name
}
def "incus run" [label: string] {
let response = do -i {
incus launch $label -c security.nesting=true --storage default
} | complete | tee { print }
$response.stdout | lines | last | split row ':' | last | str trim | tee { print }
}
def "incus sandbox" [place: path = .] {
cd $place
let label = pwd | path basename
cache node flake.nix { incus flake }
git add flake.nix
incus compile c $label ".#machine"
let name = incus run $label
sleep 1sec;
if ('./incus.bind.yml' | path exists) {
print "Opening binds."
open ($place)/incus.bind.yml
| update cells -c [source] { path expand }
| tee { each { print } }
| each {|bind| try {
incus bind $name $bind.name $bind.source $bind.bind
} }
}
$name
}
def "incus flake" [] {
'
{ inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (arch: let
pkgs = import nixpkgs { system = arch; };
bundle = with pkgs; [
isd helix gnupg openssl inotify-tools nushell
];
in {
packages.machine = nixpkgs.lib.nixosSystem {
system = arch;
modules = [
"${nixpkgs}/nixos/modules/virtualisation/lxc-container.nix"
# "${nixpkgs}/nixos/modules/virtualisation/incus-virtual-machine.nix"
({...}:
{ users.users.root = { name = "root"; shell = pkgs.nushell; password = "abcd1234"; };
environment.systemPackages = bundle;
networking.firewall.allowedTCPPorts = [];
imports = [
# ./module/psql.nix
];
})
];
};
devShells.default = pkgs.mkShell {
packages = bundle;
shellHook = "set -a; source .call; set +a;";
};
});
}
'
}