revert(dotfiles): share Nix file discovery

This commit is contained in:
2026-09-26 23:04:45 -04:00
parent e49d4c7bed
commit 34174d9424
3 changed files with 22 additions and 13 deletions

View File

@@ -17,7 +17,7 @@ let
util = import ./util.nix { inherit lib; };
registry = import ./registry.nix {
inherit lib util;
inherit lib;
hosts = self.nixosConfigurations;
root = root + "/registry";
};

View File

@@ -8,7 +8,6 @@
util,
}:
let
files = util.collectNixFiles root;
mkGuest =
name:
{ config, lib, ... }:
@@ -168,22 +167,22 @@ let
config = lib.mkIf cfg.enable {
assertions =
let
hasDirectorySettings = mount: mount.owner != null || mount.group != null || mount.mode != null;
hasCompleteDirectorySettings =
mount: mount.owner != null && mount.group != null && mount.mode != null;
hasOneSource = mount: (mount.directory != null) != (mount.file != null);
mountsWithInvalidSource = lib.attrNames (
lib.filterAttrs (_: mount: !hasOneSource mount) cfg.mounts
);
hasOneSource = mount: (mount.directory != null) != (mount.file != null);
fileMountsWithHostSettings = lib.attrNames (
lib.filterAttrs (_: mount: mount.file != null && hasDirectorySettings mount) cfg.mounts
);
hasDirectorySettings = mount: mount.owner != null || mount.group != null || mount.mode != null;
directoryMountsWithPartialHostSettings = lib.attrNames (
lib.filterAttrs (
_: mount:
mount.directory != null && hasDirectorySettings mount && !hasCompleteDirectorySettings mount
) cfg.mounts
);
hasCompleteDirectorySettings =
mount: mount.owner != null && mount.group != null && mount.mode != null;
in
[
{
@@ -276,7 +275,11 @@ let
};
};
names = map (path: lib.removeSuffix ".nix" (builtins.baseNameOf path)) files;
files = util.collectNixFiles root;
guestFiles = lib.filterAttrs (file: type: type == "regular" && lib.hasSuffix ".nix" file) (
builtins.readDir root
);
names = map (file: lib.removeSuffix ".nix" file) (lib.attrNames guestFiles);
in
{
imports = files ++ map mkGuest names;

View File

@@ -2,14 +2,20 @@
hosts,
lib,
root,
util,
}:
let
definitions = lib.listToAttrs (
map (path: lib.nameValuePair (registryName (builtins.baseNameOf path)) (mkRegistry path)) (
util.collectNixFiles root
)
);
definitions =
lib.mapAttrs'
(
name: _type:
let
path = root + "/${name}";
in
lib.nameValuePair (registryName name) (mkRegistry path)
)
(
lib.filterAttrs (name: type: type == "regular" && lib.hasSuffix ".nix" name) (builtins.readDir root)
);
registryName = fileName: lib.removeSuffix ".nix" fileName;