Merge pull request 'switch to nixos-facter for hardware-config' (#2747) from switch-to-nixos-facter into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/2747
This commit is contained in:
@@ -126,9 +126,9 @@
|
|||||||
client.succeed("cp -r ${../..} test-flake && chmod -R +w test-flake")
|
client.succeed("cp -r ${../..} test-flake && chmod -R +w test-flake")
|
||||||
client.fail("test -f test-flake/machines/test-install-machine/hardware-configuration.nix")
|
client.fail("test -f test-flake/machines/test-install-machine/hardware-configuration.nix")
|
||||||
client.succeed("clan machines update-hardware-config --flake test-flake test-install-machine root@installer >&2")
|
client.succeed("clan machines update-hardware-config --flake test-flake test-install-machine root@installer >&2")
|
||||||
client.succeed("test -f test-flake/machines/test-install-machine/hardware-configuration.nix")
|
|
||||||
client.succeed("clan machines update-hardware-config --backend nixos-facter --flake test-flake test-install-machine root@installer>&2")
|
|
||||||
client.succeed("test -f test-flake/machines/test-install-machine/facter.json")
|
client.succeed("test -f test-flake/machines/test-install-machine/facter.json")
|
||||||
|
client.succeed("clan machines update-hardware-config --backend nixos-generate-config --flake test-flake test-install-machine root@installer>&2")
|
||||||
|
client.succeed("test -f test-flake/machines/test-install-machine/hardware-configuration.nix")
|
||||||
client.succeed("clan machines install --debug --flake ${../..} --yes test-install-machine --target-host root@installer >&2")
|
client.succeed("clan machines install --debug --flake ${../..} --yes test-install-machine --target-host root@installer >&2")
|
||||||
try:
|
try:
|
||||||
installer.shutdown()
|
installer.shutdown()
|
||||||
|
|||||||
@@ -163,7 +163,8 @@ replace `[MACHINE_NAME]` with the name of the machine i.e. `jon` and `[HOSTNAME]
|
|||||||
clan machines update-hardware-config jon
|
clan machines update-hardware-config jon
|
||||||
```
|
```
|
||||||
|
|
||||||
This command connects to the ip configured in the previous step, runs `nixos-generate-config` to detect hardware configurations (excluding filesystems), and writes them to `machines/jon/hardware-configuration.nix`.
|
This command connects to the ip configured in the previous step, runs [nixos-facter](https://github.com/nix-community/nixos-facter)
|
||||||
|
to detect hardware configurations (excluding filesystems), and writes them to `machines/jon/facter.json`.
|
||||||
|
|
||||||
### Step 3: Custom Disk Formatting
|
### Step 3: Custom Disk Formatting
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ let
|
|||||||
inherit (lib)
|
inherit (lib)
|
||||||
filterAttrs
|
filterAttrs
|
||||||
flatten
|
flatten
|
||||||
flip
|
|
||||||
mapAttrsToList
|
mapAttrsToList
|
||||||
;
|
;
|
||||||
in
|
in
|
||||||
@@ -18,20 +17,18 @@ in
|
|||||||
let
|
let
|
||||||
relevantFiles =
|
relevantFiles =
|
||||||
generator:
|
generator:
|
||||||
flip filterAttrs generator.files (_name: f: f.secret && f.deploy && (f.neededFor != "activation"));
|
filterAttrs (_name: f: f.secret && f.deploy && (f.neededFor != "activation")) generator.files;
|
||||||
allFiles = flatten (
|
allFiles = flatten (
|
||||||
flip mapAttrsToList vars.generators (
|
mapAttrsToList (
|
||||||
gen_name: generator:
|
gen_name: generator:
|
||||||
flip mapAttrsToList (relevantFiles generator) (
|
mapAttrsToList (fname: file: {
|
||||||
fname: file: {
|
name = fname;
|
||||||
name = fname;
|
generator = gen_name;
|
||||||
generator = gen_name;
|
neededForUsers = file.neededFor == "users";
|
||||||
neededForUsers = file.neededFor == "users";
|
inherit (generator) share;
|
||||||
inherit (generator) share;
|
inherit (file) owner group;
|
||||||
inherit (file) owner group;
|
}) (relevantFiles generator)
|
||||||
}
|
) vars.generators
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
allFiles;
|
allFiles;
|
||||||
|
|||||||
@@ -237,5 +237,5 @@ def register_update_hardware_config(parser: argparse.ArgumentParser) -> None:
|
|||||||
"--backend",
|
"--backend",
|
||||||
help="The type of hardware report to generate.",
|
help="The type of hardware report to generate.",
|
||||||
choices=["nixos-generate-config", "nixos-facter"],
|
choices=["nixos-generate-config", "nixos-facter"],
|
||||||
default="nixos-generate-config",
|
default="nixos-facter",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user