Last active
May 30, 2021 20:47
-
-
Save Mic92/34a2604189b9603415fa7cf891a5468a to your computer and use it in GitHub Desktop.
What if flake outputs were a module?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # specialArgs provided as module parameters: | |
| # - pkgs = inputs.nixpkgs.legacyPackages.${system}; | |
| # - inputs = flake.inputs with ${system} stripped | |
| # This design requires two phases: | |
| # 1. First evaluation collects all `meta.platforms`. While doing this, we set `pkgs = {};` and `inputs == {}`. | |
| # 2. Than we evaluate for every output attribute and for every platform listed in `meta.platforms`. | |
| # TODO: How to make outputs extensible? | |
| # Do we even want this? Maybe having a standard interface would be better? | |
| { config, pkgs, inputs, ... }: { | |
| meta.platforms = [ "x86_64-linux" ]; # defaults to nixpkgs.lib.defaultPlatforms; | |
| checks = { | |
| meta.platforms = [ "x86_64-linux" ]; # defaults to config.meta.platforms; | |
| meta.default = config.checks.hello; | |
| hello = pkgs.hello; | |
| }; | |
| apps = { | |
| meta.platforms = [ "x86_64-linux" ]; # defaults to config.meta.platforms; | |
| meta.default = config.apps.hello; | |
| hello = { | |
| type = "app"; # defaults to "app" | |
| program = "${pkgs.hello}/bin/hello"; | |
| }; | |
| }; | |
| packages = { | |
| meta.platforms = [ "x86_64-linux" ]; # defaults to config.meta.platforms; | |
| meta.default = config.packages.hello; | |
| hello = pkgs.hello; | |
| }; | |
| devShell = pkgs.mkShell { | |
| meta.platforms = [ "x86_64-linux" ]; # defaults to config.meta.platforms; | |
| buildInputs = [ pkgs.hello ]; | |
| }; | |
| overlays = { | |
| meta.default = config.overlays.default; | |
| foo = {}; | |
| }; | |
| templates = { | |
| meta.default = config.templates.hello; | |
| hello = { | |
| path = "<store-path>"; | |
| description = "template description goes here?"; | |
| }; | |
| }; | |
| nixosModule = { | |
| meta.default = config.modules.hello; | |
| hello = { ... }: { | |
| imports = [ | |
| inputs.input.modules | |
| ]; | |
| }; | |
| }; | |
| nixosConfiguration = { | |
| hello = inputs.nixpkgs.lib.nixosSystem { | |
| system = "foo"; | |
| modules = [ | |
| config.modules.fancy-module | |
| ./configuration.nix | |
| ]; | |
| }; | |
| }; | |
| hydraJob = { | |
| helloHydra = { | |
| hello = config.packages.hello; | |
| }; | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| # ... | |
| outputs = flake-modules.lib.outputs { | |
| imports = [ | |
| ./flake-module.nix | |
| ]; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment