From db88731eba37dd71c1198e271bdff858669c40e8 Mon Sep 17 00:00:00 2001 From: reo101 Date: Thu, 1 Aug 2024 13:26:56 +0300 Subject: [PATCH] refactor(flake): move flake modules into separate subdirectories Also put `outputs` before `inputs` in `flake.nix` (readability) --- flake.nix | 121 +++++++++--------- .../flake/{agenix.nix => agenix/default.nix} | 0 .../default.nix} | 0 .../flake/{deploy.nix => deploy/default.nix} | 0 .../{modules.nix => modules/default.nix} | 0 modules/flake/{pkgs.nix => pkgs/default.nix} | 0 6 files changed, 60 insertions(+), 61 deletions(-) rename modules/flake/{agenix.nix => agenix/default.nix} (100%) rename modules/flake/{configurations.nix => configurations/default.nix} (100%) rename modules/flake/{deploy.nix => deploy/default.nix} (100%) rename modules/flake/{modules.nix => modules/default.nix} (100%) rename modules/flake/{pkgs.nix => pkgs/default.nix} (100%) diff --git a/flake.nix b/flake.nix index f53b1a4..f7071b1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,66 @@ { description = "reo101's NixOS, nix-on-droid and nix-darwin configs"; + outputs = inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, flake-parts-lib, ... }: { + systems = [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + + imports = [ + ./modules/flake/lib.nix + ./modules/flake/pkgs + ./modules/flake/modules + ./modules/flake/configurations + ./modules/flake/agenix + ./modules/flake/deploy + ./modules/flake/topology + ./modules/flake/packages + ]; + + perSystem = { lib, pkgs, system, ... }: { + # Apps (`nix run`) + apps = import ./apps { inherit pkgs; }; + + # Dev Shells (`nix develop`) + devShells = import ./shells { + inherit inputs; + # NOTE: for `nixVersions.monitored` + pkgs = pkgs.extend inputs.self.overlays.modifications; + }; + + # Formatter (`nix fmt`) + formatter = pkgs.nixpkgs-fmt; + }; + + flake = { + inherit (inputs) self; + + # Automatic modules, see `./modules/flake/modules.nix` + autoModules.enableAll = true; + + # Automatic configurations, see `./modules/flake/configurations.nix` + autoConfigurations.enableAll = true; + + # Automatic packages, see `./modules/flake/packages/default.nix` + autoPackages.enable = true; + + # Templates + templates = import ./templates { + inherit inputs; + }; + + # Overlays + overlays = import ./overlays { + inherit inputs; + }; + }; + }); + inputs = { # Nixpkgs nixpkgs = { @@ -132,65 +192,4 @@ inputs.nixpkgs.follows = "nixpkgs"; }; }; - - outputs = inputs: - inputs.flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, flake-parts-lib, ... }: { - systems = [ - "aarch64-linux" - "i686-linux" - "x86_64-linux" - "aarch64-darwin" - "x86_64-darwin" - ]; - - imports = [ - ./modules/flake/lib.nix - ./modules/flake/pkgs.nix - ./modules/flake/modules.nix - ./modules/flake/configurations.nix - ./modules/flake/agenix.nix - ./modules/flake/deploy.nix - ./modules/flake/topology - ./modules/flake/packages - ]; - - - perSystem = { lib, pkgs, system, ... }: { - # Apps (`nix run`) - apps = import ./apps { inherit pkgs; }; - - # Dev Shells (`nix develop`) - devShells = import ./shells { - inherit inputs; - # NOTE: for `nixVersions.monitored` - pkgs = pkgs.extend inputs.self.overlays.modifications; - }; - - # Formatter (`nix fmt`) - formatter = pkgs.nixpkgs-fmt; - }; - - flake = { - inherit (inputs) self; - - # Automatic modules, see `./modules/flake/modules.nix` - autoModules.enableAll = true; - - # Automatic configurations, see `./modules/flake/configurations.nix` - autoConfigurations.enableAll = true; - - # Automatic packages, see `./modules/flake/packages/default.nix` - autoPackages.enable = true; - - # Templates - templates = import ./templates { - inherit inputs; - }; - - # Overlays - overlays = import ./overlays { - inherit inputs; - }; - }; - }); } diff --git a/modules/flake/agenix.nix b/modules/flake/agenix/default.nix similarity index 100% rename from modules/flake/agenix.nix rename to modules/flake/agenix/default.nix diff --git a/modules/flake/configurations.nix b/modules/flake/configurations/default.nix similarity index 100% rename from modules/flake/configurations.nix rename to modules/flake/configurations/default.nix diff --git a/modules/flake/deploy.nix b/modules/flake/deploy/default.nix similarity index 100% rename from modules/flake/deploy.nix rename to modules/flake/deploy/default.nix diff --git a/modules/flake/modules.nix b/modules/flake/modules/default.nix similarity index 100% rename from modules/flake/modules.nix rename to modules/flake/modules/default.nix diff --git a/modules/flake/pkgs.nix b/modules/flake/pkgs/default.nix similarity index 100% rename from modules/flake/pkgs.nix rename to modules/flake/pkgs/default.nix