trying nix anywhere
This commit is contained in:
1 parent
76e396cd43
commit
a5cf4fcd00
7 files changed
+104
-17
No files matched your search
@@ -22,6 +22,7 @@ bin/
|
||||
|---|---|
|
||||
| `skyg os switch` | Rebuild and switch local system |
|
||||
| `skyg remote switch <host>` | Deploy to a remote host |
|
||||
| `skyg remote install <host>` | Fresh-install a remote host via nixos-anywhere, using `hosts/<profile>.disko.nix` (errors if that file is missing) |
|
||||
| `skyg hm switch` | Apply Home Manager config |
|
||||
| `skyg update [input]` | Update flake inputs |
|
||||
| `skyg build-image iso|pi1|pi2` | Build bootable image — ISO (`iso`) or Pi SD card image (`pi1`, `pi2`) |
|
||||
|
||||
@@ -118,6 +118,28 @@ export def "skyg remote" [
|
||||
bash -c $runcmd
|
||||
}
|
||||
|
||||
# Fresh-install a remote machine via nixos-anywhere, using its disko config
|
||||
# Errors out if hosts/<profile>.disko.nix is missing — refuses to wipe a disk blind
|
||||
export def "skyg remote install" [
|
||||
target: string@remote_targets,
|
||||
] {
|
||||
cd $REPO_ROOT
|
||||
let target_host = $"root@($target).lab.internal"
|
||||
let profile = $"hl-($target)"
|
||||
if not (is-valid-profile $profile true) {
|
||||
print $"Invalid Remote Profile '(ansi green_bold)($target)(ansi reset)', please select one of:"
|
||||
return (remote_targets)
|
||||
}
|
||||
let disko_file = $"hosts/($profile).disko.nix"
|
||||
if not ($disko_file | path exists) {
|
||||
error make { msg: $"Missing disko config: ($disko_file). Refusing to install ($profile) without a disko layout." }
|
||||
}
|
||||
$"Installing [(ansi green_bold)($profile)(ansi reset)] on ($target_host) via nixos-anywhere, using ($disko_file)" | print
|
||||
let runcmd = $"nix run github:nix-community/nixos-anywhere -- --flake .#($profile) ($target_host)"
|
||||
$runcmd | print
|
||||
bash -c $runcmd
|
||||
}
|
||||
|
||||
# Boot all remote hosts except the current machine (fwbook)
|
||||
# Checks online status first, runs `skyg remote boot --build-host fwdesk <host>` for each online host,
|
||||
# and writes a summary report to .tmp/boot-report.txt
|
||||
|
||||
Generated
+21
@@ -270,6 +270,26 @@
|
||||
"url": "https://install.determinate.systems/determinate-nixd/tag/v3.22.0/x86_64-linux"
|
||||
}
|
||||
},
|
||||
"disko": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1781152676,
|
||||
"narHash": "sha256-RxWs5ND31KzTG7wvMM+PMfUjyNpmIEr999lqNARaM5o=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "ff8702b4de27f72b4c78573dfb89ec74e36abdf1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"dms": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
@@ -1710,6 +1730,7 @@
|
||||
"agenix": "agenix",
|
||||
"claude-desktop": "claude-desktop",
|
||||
"determinate": "determinate",
|
||||
"disko": "disko",
|
||||
"dms": "dms",
|
||||
"flox": "flox",
|
||||
"git-hooks": "git-hooks",
|
||||
|
||||
@@ -65,6 +65,11 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
herdr.url = "github:herdrdev/herdr";
|
||||
# Declarative disk partitioning (for nixos-anywhere installs)
|
||||
disko = {
|
||||
url = "github:nix-community/disko";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
outputs =
|
||||
{ self
|
||||
@@ -89,6 +94,7 @@
|
||||
, tether
|
||||
, herdr
|
||||
, claude-desktop
|
||||
, disko
|
||||
}:
|
||||
let
|
||||
# Libs
|
||||
@@ -237,7 +243,9 @@
|
||||
configuration = [
|
||||
./hosts/hl-fws1.nix
|
||||
./hosts/hl-fws1.hardware-configuration.nix
|
||||
./hosts/hl-fws1.disko.nix
|
||||
nixos-hardware.nixosModules.framework-11th-gen-intel
|
||||
disko.nixosModules.disko
|
||||
];
|
||||
};
|
||||
hl-fwdesk = lib.makeNixOs {
|
||||
|
||||
@@ -8,6 +8,8 @@ One NixOS configuration file per managed machine, plus hardware configs and host
|
||||
hosts/
|
||||
├── <hostname>.nix # Host configuration (packages, services, options)
|
||||
├── <hostname>.hardware-configuration.nix # Generated by nixos-generate-config — DO NOT EDIT
|
||||
├── <hostname>.disko.nix # Optional: declarative disk layout for `skyg remote install` (nixos-anywhere).
|
||||
│ # Only present for hosts installed/reinstalled this way (currently: hl-fws1)
|
||||
└── scripts/
|
||||
├── fwbook/ # fwbook-specific shell scripts
|
||||
│ ├── functions.sh # ZSH functions sourced at shell startup
|
||||
@@ -37,5 +39,6 @@ hosts/
|
||||
|
||||
- **Do not add `imports = [...]`** to host files — module composition happens in `flake.nix` via `modules/main.nix`
|
||||
- **Do not edit `*.hardware-configuration.nix`** — these are generated and will be overwritten
|
||||
- Hosts with a `<hostname>.disko.nix` own their `fileSystems` via disko; if a generated `hardware-configuration.nix` still contains its own `fileSystems` stanzas for the same host, that's a conflict the machine's owner needs to resolve by hand (regenerating or trimming it) — not something to script around
|
||||
- Host-specific packages and one-off settings belong here; anything reused across hosts belongs in `modules/`
|
||||
- See `docs/hosts/README.md` for full per-host service/port/package reference
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
disko.devices = {
|
||||
disk = {
|
||||
main = {
|
||||
device = "/dev/nvme0n1";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
ESP = {
|
||||
size = "1G";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
mountOptions = [ "umask=0077" ];
|
||||
};
|
||||
};
|
||||
swap = {
|
||||
size = "80G";
|
||||
content = {
|
||||
type = "swap";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "btrfs";
|
||||
extraArgs = [ "-f" ];
|
||||
subvolumes = {
|
||||
"@" = {
|
||||
mountpoint = "/";
|
||||
};
|
||||
"@home" = {
|
||||
mountpoint = "/home";
|
||||
};
|
||||
"@nix" = {
|
||||
mountpoint = "/nix";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -13,23 +13,6 @@
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" =
|
||||
{
|
||||
device = "/dev/disk/by-uuid/3fbf3ccf-655a-4040-b898-b97a1d555912";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" =
|
||||
{
|
||||
device = "/dev/disk/by-uuid/3342-B2BE";
|
||||
fsType = "vfat";
|
||||
};
|
||||
|
||||
swapDevices = [{
|
||||
device = "/var/lib/swapfile";
|
||||
size = 64 * 1024;
|
||||
}];
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
}
|
||||
Reference in new issue
Block a user