From 38c2e5aece5d3196ed0a36b6cac2547d855aae6d Mon Sep 17 00:00:00 2001 From: Zuckerberg Date: Fri, 21 Apr 2023 23:24:05 -0600 Subject: [PATCH] Fix properties.nix path loading --- common/machine-info/default.nix | 20 ++++++-------------- common/machine-info/moduleless.nix | 6 ------ secrets/secrets.nix | 4 +--- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/common/machine-info/default.nix b/common/machine-info/default.nix index e993914..67c2df8 100644 --- a/common/machine-info/default.nix +++ b/common/machine-info/default.nix @@ -13,13 +13,6 @@ in ]; options.machines = { - # For some reason (presumably a bug), using the best value of "../../machines" - # as the path causes nix to search for invalid paths for flake imports but *not* - # secrets.nix for agenix. - machinesPath = lib.mkOption { - type = lib.types.path; - default = ../..; - }; hosts = lib.mkOption { type = lib.types.attrsOf @@ -194,15 +187,14 @@ in }) (propertiesFiles dir); propertiesFiles = dir: - lib.foldl (lib.mergeAttrs) { } (propertiesFiles' dir ""); - propertiesFiles' = dir: dirName: + lib.foldl (lib.mergeAttrs) { } (propertiesFiles' dir); + propertiesFiles' = dir: let - dirContents = builtins.readDir dir; - dirPaths = lib.filter (path: dirContents.${path} == "directory") (lib.attrNames dirContents); - propFiles = builtins.map (p: "${dir}/${p}") (lib.filter (path: path == "properties.nix") (lib.attrNames dirContents)); + propFiles = lib.filter (p: baseNameOf p == "properties.nix") (lib.filesystem.listFilesRecursive dir); + dirName = path: builtins.baseNameOf (builtins.dirOf path); in - lib.concatMap (d: propertiesFiles' "${dir}/${d}" d) dirPaths ++ builtins.map (p: { "${dirName}" = p; }) propFiles; + builtins.map (p: { "${dirName p}" = p; }) propFiles; in - properties config.machines.machinesPath; + properties ../../machines; }; } diff --git a/common/machine-info/moduleless.nix b/common/machine-info/moduleless.nix index 44e66ac..2045124 100644 --- a/common/machine-info/moduleless.nix +++ b/common/machine-info/moduleless.nix @@ -2,7 +2,6 @@ { nixpkgs ? import { } , assertionsModule ? -, machinesPath ? null }: { @@ -11,11 +10,6 @@ modules = [ ./default.nix assertionsModule - { - config = nixpkgs.lib.mkIf (machinesPath != null) { - machines.machinesPath = machinesPath; - }; - } ]; }).config.machines; } diff --git a/secrets/secrets.nix b/secrets/secrets.nix index e343709..7fe5b8d 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -1,8 +1,6 @@ let lib = (import { }).lib; - sshKeys = (import ../common/machine-info/moduleless.nix { - machinesPath = ../machines; - }).machines.ssh; + sshKeys = (import ../common/machine-info/moduleless.nix { }).machines.ssh; # add userkeys to all roles so that I can r/w the secrets from my personal computers roles = lib.mapAttrs (role: hosts: hosts ++ sshKeys.userKeys) sshKeys.hostKeysByRole;