Skip to content

Commit

Permalink
Improve getImports function and add to hs
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoriguchi committed Nov 4, 2023
1 parent 73f8937 commit 16fda03
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
21 changes: 6 additions & 15 deletions configuration/devices/headless/server/home-assistant/default.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
{ pkgs, config, secrets, ... }: {
imports = [
./adguard.nix
./deluge.nix
./generate-wifi-guest-qr.nix
./lovelace.nix
./mystrom.nix
./netatmo.nix
./postgres.nix
./proxy.nix
./systemmonitor.nix
./unifi.nix
./weather.nix
./yeelight.nix
];
{ pkgs, lib, config, secrets, ... }:
let
getFiles = dir: lib.attrNames (builtins.readDir dir);
getImports = dir: map (file: dir + "/${file}") (lib.filter (file: !(lib.hasSuffix ".md" file) && file != "default.nix") (getFiles dir));
in {
imports = getImports ./.;

services.home-assistant = {
enable = true;
Expand Down
2 changes: 1 addition & 1 deletion modules/default/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ lib, ... }:
let
getFiles = dir: lib.attrNames (builtins.readDir dir);
getImports = dir: map (file: dir + "/${file}") (lib.filter (file: file != "default.nix") (getFiles dir));
getImports = dir: map (file: dir + "/${file}") (lib.filter (file: !(lib.hasSuffix ".md" file) && file != "default.nix") (getFiles dir));
in { imports = getImports ./.; }
2 changes: 1 addition & 1 deletion modules/home-manager/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ lib, ... }:
let
getFiles = dir: lib.attrNames (builtins.readDir dir);
getImports = dir: map (file: dir + "/${file}") (lib.filter (file: file != "default.nix") (getFiles dir));
getImports = dir: map (file: dir + "/${file}") (lib.filter (file: !(lib.hasSuffix ".md" file) && file != "default.nix") (getFiles dir));
in {
imports = getImports ./.;

Expand Down

0 comments on commit 16fda03

Please sign in to comment.