From cb8ca601e2d11e5791543e4471ead5d7ef0434fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 14 Jan 2025 19:04:35 +0100 Subject: [PATCH 1/2] switch to nixos-facter for hardware-config --- checks/installation/flake-module.nix | 4 ++-- docs/site/getting-started/configure.md | 3 ++- pkgs/clan-cli/clan_cli/machines/hardware.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/checks/installation/flake-module.nix b/checks/installation/flake-module.nix index f48c4e040..efa6c0a3b 100644 --- a/checks/installation/flake-module.nix +++ b/checks/installation/flake-module.nix @@ -126,9 +126,9 @@ 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.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("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") try: installer.shutdown() diff --git a/docs/site/getting-started/configure.md b/docs/site/getting-started/configure.md index 218e1dc2f..3dc2e190d 100644 --- a/docs/site/getting-started/configure.md +++ b/docs/site/getting-started/configure.md @@ -163,7 +163,8 @@ replace `[MACHINE_NAME]` with the name of the machine i.e. `jon` and `[HOSTNAME] 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 diff --git a/pkgs/clan-cli/clan_cli/machines/hardware.py b/pkgs/clan-cli/clan_cli/machines/hardware.py index 28c7b3c7c..e7b62431f 100644 --- a/pkgs/clan-cli/clan_cli/machines/hardware.py +++ b/pkgs/clan-cli/clan_cli/machines/hardware.py @@ -237,5 +237,5 @@ def register_update_hardware_config(parser: argparse.ArgumentParser) -> None: "--backend", help="The type of hardware report to generate.", choices=["nixos-generate-config", "nixos-facter"], - default="nixos-generate-config", + default="nixos-facter", ) From fb217cc4b276da076b23e59a36f6d41f87d10fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 15 Jan 2025 14:31:07 +0100 Subject: [PATCH 2/2] remove flip functions from sops code --- .../clanCore/vars/secret/sops/funcs.nix | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/nixosModules/clanCore/vars/secret/sops/funcs.nix b/nixosModules/clanCore/vars/secret/sops/funcs.nix index 63f06ab23..ed3e3d6b1 100644 --- a/nixosModules/clanCore/vars/secret/sops/funcs.nix +++ b/nixosModules/clanCore/vars/secret/sops/funcs.nix @@ -7,7 +7,6 @@ let inherit (lib) filterAttrs flatten - flip mapAttrsToList ; in @@ -18,20 +17,18 @@ in let relevantFiles = 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 ( - flip mapAttrsToList vars.generators ( + mapAttrsToList ( gen_name: generator: - flip mapAttrsToList (relevantFiles generator) ( - fname: file: { - name = fname; - generator = gen_name; - neededForUsers = file.neededFor == "users"; - inherit (generator) share; - inherit (file) owner group; - } - ) - ) + mapAttrsToList (fname: file: { + name = fname; + generator = gen_name; + neededForUsers = file.neededFor == "users"; + inherit (generator) share; + inherit (file) owner group; + }) (relevantFiles generator) + ) vars.generators ); in allFiles;