Fix properties.nix path loading

This commit is contained in:
Zuckerberg 2023-04-21 23:24:05 -06:00
parent 0ef689b750
commit 38c2e5aece
3 changed files with 7 additions and 23 deletions

View File

@ -13,13 +13,6 @@ in
]; ];
options.machines = { 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 { hosts = lib.mkOption {
type = lib.types.attrsOf type = lib.types.attrsOf
@ -194,15 +187,14 @@ in
}) })
(propertiesFiles dir); (propertiesFiles dir);
propertiesFiles = dir: propertiesFiles = dir:
lib.foldl (lib.mergeAttrs) { } (propertiesFiles' dir ""); lib.foldl (lib.mergeAttrs) { } (propertiesFiles' dir);
propertiesFiles' = dir: dirName: propertiesFiles' = dir:
let let
dirContents = builtins.readDir dir; propFiles = lib.filter (p: baseNameOf p == "properties.nix") (lib.filesystem.listFilesRecursive dir);
dirPaths = lib.filter (path: dirContents.${path} == "directory") (lib.attrNames dirContents); dirName = path: builtins.baseNameOf (builtins.dirOf path);
propFiles = builtins.map (p: "${dir}/${p}") (lib.filter (path: path == "properties.nix") (lib.attrNames dirContents));
in in
lib.concatMap (d: propertiesFiles' "${dir}/${d}" d) dirPaths ++ builtins.map (p: { "${dirName}" = p; }) propFiles; builtins.map (p: { "${dirName p}" = p; }) propFiles;
in in
properties config.machines.machinesPath; properties ../../machines;
}; };
} }

View File

@ -2,7 +2,6 @@
{ nixpkgs ? import <nixpkgs> { } { nixpkgs ? import <nixpkgs> { }
, assertionsModule ? <nixpkgs/nixos/modules/misc/assertions.nix> , assertionsModule ? <nixpkgs/nixos/modules/misc/assertions.nix>
, machinesPath ? null
}: }:
{ {
@ -11,11 +10,6 @@
modules = [ modules = [
./default.nix ./default.nix
assertionsModule assertionsModule
{
config = nixpkgs.lib.mkIf (machinesPath != null) {
machines.machinesPath = machinesPath;
};
}
]; ];
}).config.machines; }).config.machines;
} }

View File

@ -1,8 +1,6 @@
let let
lib = (import <nixpkgs> { }).lib; lib = (import <nixpkgs> { }).lib;
sshKeys = (import ../common/machine-info/moduleless.nix { sshKeys = (import ../common/machine-info/moduleless.nix { }).machines.ssh;
machinesPath = ../machines;
}).machines.ssh;
# add userkeys to all roles so that I can r/w the secrets from my personal computers # 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; roles = lib.mapAttrs (role: hosts: hosts ++ sshKeys.userKeys) sshKeys.hostKeysByRole;