diff --git a/all-modules.nix b/all-modules.nix index bc194a5..f6e508c 100644 --- a/all-modules.nix +++ b/all-modules.nix @@ -2,9 +2,12 @@ { imports = [ ./modules/checks.nix + ./modules/darwinModules.nix ./modules/devShell.nix ./modules/flake.nix ./modules/legacyPackages.nix + ./modules/nixosModules.nix + ./modules/overlay.nix ./modules/packages.nix ./modules/perSystem.nix ]; diff --git a/modules/darwinModules.nix b/modules/darwinModules.nix new file mode 100644 index 0000000..fb3df5b --- /dev/null +++ b/modules/darwinModules.nix @@ -0,0 +1,27 @@ +{ config, self, lib, flake-modules-core-lib, ... }: +let + inherit (lib) + filterAttrs + mapAttrs + mkOption + optionalAttrs + types + ; + inherit (flake-modules-core-lib) + mkSubmoduleOptions + ; +in +{ + options = { + flake = mkSubmoduleOptions { + darwinModules = mkOption { + type = types.lazyAttrsOf types.unspecified; + default = { }; + apply = mapAttrs (k: v: { _file = "${toString self.outPath}/flake.nix#darwinModules.${k}"; imports = [ v ]; }); + description = '' + Nix-darwin modules. + ''; + }; + }; + }; +} diff --git a/modules/devShell.nix b/modules/devShell.nix index 4f347c3..b4154ac 100644 --- a/modules/devShell.nix +++ b/modules/devShell.nix @@ -36,6 +36,10 @@ in options = { devShell = mkOption { type = types.package; + # We don't have a way to unset devShell in the flake without computing + # the root of each allSystems module, so to improve laziness, the best + # choice seems to be to require a devShell and give the opportunity + # to unset it manually. default = throw "The default devShell was not configured for system ${system}. Please set it, or if you don't want to use the devShell attribute, set flake.devShell = lib.mkForce {};"; description = '' A derivation that nix develop bases its environment on. diff --git a/modules/nixosModules.nix b/modules/nixosModules.nix new file mode 100644 index 0000000..e26d040 --- /dev/null +++ b/modules/nixosModules.nix @@ -0,0 +1,27 @@ +{ config, self, lib, flake-modules-core-lib, ... }: +let + inherit (lib) + filterAttrs + mapAttrs + mkOption + optionalAttrs + types + ; + inherit (flake-modules-core-lib) + mkSubmoduleOptions + ; +in +{ + options = { + flake = mkSubmoduleOptions { + nixosModules = mkOption { + type = types.lazyAttrsOf types.unspecified; + default = { }; + apply = mapAttrs (k: v: { _file = "${toString self.outPath}/flake.nix#nixosModules.${k}"; imports = [ v ]; }); + description = '' + NixOS modules. + ''; + }; + }; + }; +} diff --git a/modules/overlay.nix b/modules/overlay.nix new file mode 100644 index 0000000..88405ae --- /dev/null +++ b/modules/overlay.nix @@ -0,0 +1,32 @@ +{ config, lib, flake-modules-core-lib, ... }: +let + inherit (lib) + mkOption + types + ; + inherit (flake-modules-core-lib) + mkSubmoduleOptions + ; +in +{ + options = { + flake = mkSubmoduleOptions { + overlay = mkOption { + # uniq should be ordered: https://github.com/NixOS/nixpkgs/issues/147052 + # also update description when done + type = types.uniq (types.functionTo (types.functionTo (types.lazyAttrsOf types.unspecified))); + # This eta expansion exists for the sole purpose of making nix flake check happy. + apply = f: final: prev: f final prev; + default = _: _: { }; + defaultText = lib.literalExpression or lib.literalExample ''final: prev: {}''; + description = '' + An overlay. + + Note that this option's type is not mergeable. While overlays can be + composed, the order of composition is significant, but the module + system does not guarantee deterministic definition ordering. + ''; + }; + }; + }; +}