diff --git a/ChangeLog.md b/ChangeLog.md index 9b693f1..c9d894e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,12 @@ +# 2022-12-07 + + - The `darwinModules` option has been removed. This was added in the early days + without full consideration. The removal will have no effect on most flakes + considering that the [`flake` option](https://flake.parts/options/flake-parts.html#opt-flake) + allows any attribute to be set. This attribute and related attributes should + be added to the nix-darwin project instead. + # 2022-10-11 - The `nixpkgs` input has been renamed to `nixpkgs-lib` to signify that the diff --git a/all-modules.nix b/all-modules.nix index 42bfdf2..039ce97 100644 --- a/all-modules.nix +++ b/all-modules.nix @@ -3,7 +3,6 @@ imports = [ ./modules/apps.nix ./modules/checks.nix - ./modules/darwinModules.nix ./modules/devShells.nix ./modules/flake.nix ./modules/formatter.nix diff --git a/dev/flake-module.nix b/dev/flake-module.nix index 40fe958..49b1102 100644 --- a/dev/flake-module.nix +++ b/dev/flake-module.nix @@ -26,6 +26,10 @@ }; }; + checks.eval-tests = + let tests = import ./tests/eval-tests.nix; + in tests.runTests pkgs.emptyFile // { internals = tests; }; + }; flake = { # for repl exploration / debug diff --git a/dev/tests/eval-tests.nix b/dev/tests/eval-tests.nix new file mode 100644 index 0000000..276269c --- /dev/null +++ b/dev/tests/eval-tests.nix @@ -0,0 +1,61 @@ +rec { + f-p = builtins.getFlake (toString ../..); + f-p-lib = f-p.lib; + + inherit (f-p-lib) mkFlake; + inherit (f-p.inputs.nixpkgs-lib) lib; + + pkg = system: name: derivation { + name = name; + builder = "no-builder"; + system = system; + }; + + empty = mkFlake + { self = { }; } + { + systems = [ ]; + }; + + example1 = mkFlake + { self = { }; } + { + systems = [ "a" "b" ]; + perSystem = { system, ... }: { + packages.hello = pkg system "hello"; + }; + }; + + runTests = ok: + + assert empty == { + apps = { }; + checks = { }; + devShells = { }; + formatter = { }; + legacyPackages = { }; + nixosConfigurations = { }; + nixosModules = { }; + overlays = { }; + packages = { }; + }; + + assert example1 == { + apps = { a = { }; b = { }; }; + checks = { a = { }; b = { }; }; + devShells = { a = { }; b = { }; }; + formatter = { }; + legacyPackages = { a = { }; b = { }; }; + nixosConfigurations = { }; + nixosModules = { }; + overlays = { }; + packages = { + a = { hello = pkg "a" "hello"; }; + b = { hello = pkg "b" "hello"; }; + }; + }; + + ok; + + result = runTests "ok"; +} diff --git a/modules/darwinModules.nix b/modules/darwinModules.nix deleted file mode 100644 index 2e39a00..0000000 --- a/modules/darwinModules.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ config, self, lib, flake-parts-lib, ... }: -let - inherit (lib) - filterAttrs - mapAttrs - mkOption - optionalAttrs - types - ; - inherit (flake-parts-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](https://daiderd.com/nix-darwin/) modules. - ''; - }; - }; - }; -}