From fa75b68c677d71aa17ec0efacd09aa0f69d5a4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elizabeth=20Pa=C5=BA?= Date: Tue, 21 Nov 2023 23:43:19 +0100 Subject: [PATCH] Allow for usage without setting the root option --- flake-module.nix | 9 +++++---- template/darwin-configurations/.gitkeep | 0 template/darwin-configurations/dummy | 1 - template/darwin-modules/.gitkeep | 0 template/darwin-modules/dummy | 1 - template/flake.nix | 3 --- template/home-configurations/.gitkeep | 0 template/home-configurations/dummy | 1 - template/home-modules/.gitkeep | 0 template/home-modules/dummy | 1 - template/nixos-configurations/.gitkeep | 0 template/nixos-configurations/dummy | 1 - template/nixos-modules/.gitkeep | 0 template/nixos-modules/dummy | 1 - unset-directory/.gitkeep | 0 15 files changed, 5 insertions(+), 13 deletions(-) create mode 100644 template/darwin-configurations/.gitkeep delete mode 100644 template/darwin-configurations/dummy create mode 100644 template/darwin-modules/.gitkeep delete mode 100644 template/darwin-modules/dummy create mode 100644 template/home-configurations/.gitkeep delete mode 100644 template/home-configurations/dummy create mode 100644 template/home-modules/.gitkeep delete mode 100644 template/home-modules/dummy create mode 100644 template/nixos-configurations/.gitkeep delete mode 100644 template/nixos-configurations/dummy create mode 100644 template/nixos-modules/.gitkeep delete mode 100644 template/nixos-modules/dummy create mode 100644 unset-directory/.gitkeep diff --git a/flake-module.nix b/flake-module.nix index f101833..958d27f 100644 --- a/flake-module.nix +++ b/flake-module.nix @@ -279,7 +279,7 @@ let configurationOptions = configType: { modulesDirectory = mkOption { - default = "${cfg.root}/${configType}-modules"; + default = if cfg.root != null then "${cfg.root}/${configType}-modules" else ./unset-directory; defaultText = literalExpression "\"\${ezConfigs.root}/${configType}-modules\""; type = types.pathInStore; description = '' @@ -288,7 +288,7 @@ let }; configurationsDirectory = mkOption { - default = "${cfg.root}/${configType}-configurations"; + default = if cfg.root != null then "${cfg.root}/${configType}-configurations" else ./unset-directory; defaultText = literalExpression "\"\${ezConfigs.root}/${configType}-configurations\""; type = types.pathInStore; description = '' @@ -375,7 +375,8 @@ in { options.ezConfigs = { root = mkOption { - type = types.pathInStore; + default = null; + type = types.nullOr types.pathInStore; example = literalExpression "./."; description = '' The root from which configurations and modules should be searched. @@ -398,7 +399,7 @@ in darwin = configurationOptions "darwin"; }; - config.flake = mkIf (cfg ? root) rec { + config.flake = rec { homeModules = readModules cfg.home.modulesDirectory; nixosModules = readModules cfg.nixos.modulesDirectory; darwinModules = readModules cfg.darwin.modulesDirectory; diff --git a/template/darwin-configurations/.gitkeep b/template/darwin-configurations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/template/darwin-configurations/dummy b/template/darwin-configurations/dummy deleted file mode 100644 index 9c558e3..0000000 --- a/template/darwin-configurations/dummy +++ /dev/null @@ -1 +0,0 @@ -. diff --git a/template/darwin-modules/.gitkeep b/template/darwin-modules/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/template/darwin-modules/dummy b/template/darwin-modules/dummy deleted file mode 100644 index 9c558e3..0000000 --- a/template/darwin-modules/dummy +++ /dev/null @@ -1 +0,0 @@ -. diff --git a/template/flake.nix b/template/flake.nix index 939b88f..22a2aa3 100644 --- a/template/flake.nix +++ b/template/flake.nix @@ -42,9 +42,6 @@ systems = [ ]; ezConfigs = { - # All subdirectories under this contain a `dummy` file. - # They can be deleted after the template has been initialised. - # They are only there to preserve the directory structure within git. root = ./.; globalArgs = { inherit inputs; }; }; diff --git a/template/home-configurations/.gitkeep b/template/home-configurations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/template/home-configurations/dummy b/template/home-configurations/dummy deleted file mode 100644 index 9c558e3..0000000 --- a/template/home-configurations/dummy +++ /dev/null @@ -1 +0,0 @@ -. diff --git a/template/home-modules/.gitkeep b/template/home-modules/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/template/home-modules/dummy b/template/home-modules/dummy deleted file mode 100644 index 9c558e3..0000000 --- a/template/home-modules/dummy +++ /dev/null @@ -1 +0,0 @@ -. diff --git a/template/nixos-configurations/.gitkeep b/template/nixos-configurations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/template/nixos-configurations/dummy b/template/nixos-configurations/dummy deleted file mode 100644 index 9c558e3..0000000 --- a/template/nixos-configurations/dummy +++ /dev/null @@ -1 +0,0 @@ -. diff --git a/template/nixos-modules/.gitkeep b/template/nixos-modules/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/template/nixos-modules/dummy b/template/nixos-modules/dummy deleted file mode 100644 index 9c558e3..0000000 --- a/template/nixos-modules/dummy +++ /dev/null @@ -1 +0,0 @@ -. diff --git a/unset-directory/.gitkeep b/unset-directory/.gitkeep new file mode 100644 index 0000000..e69de29