revert(dotfiles): share Nix file discovery
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user