diff options
-rw-r--r-- | Documentation/development/build-configuration.adoc | 20 | ||||
-rw-r--r-- | lib/config.default.nix | 6 | ||||
-rw-r--r-- | lib/eval-config.nix | 15 |
3 files changed, 25 insertions, 16 deletions
diff --git a/Documentation/development/build-configuration.adoc b/Documentation/development/build-configuration.adoc index c9a8c99..4f7d8e9 100644 --- a/Documentation/development/build-configuration.adoc +++ b/Documentation/development/build-configuration.adoc @@ -23,17 +23,15 @@ custom Nixpkgs to evaluate Spectrum. [example] [source,nix] ---- +{ default, ... }: + { - pkgs = import <nixpkgs> { - overlays = [ - (final: super: { - weston = super.weston.overrideAttrs ({ patches ? [], ... }: { - patches = patches ++ [ - path/to/weston.patch - ]; - }); - }) - ]; - }; + pkgs = default.pkgs.extend (final: super: { + weston = super.weston.overrideAttrs ({ patches ? [], ... }: { + patches = patches ++ [ + path/to/weston.patch + ]; + }); + }); } ---- diff --git a/lib/config.default.nix b/lib/config.default.nix new file mode 100644 index 0000000..682c0fc --- /dev/null +++ b/lib/config.default.nix @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2023 Alyssa Ross <hi@alyssa.is> +# SPDX-License-Identifier: MIT + +{ + pkgs = import <nixpkgs> {}; +} diff --git a/lib/eval-config.nix b/lib/eval-config.nix index 282f5e2..bbc83d7 100644 --- a/lib/eval-config.nix +++ b/lib/eval-config.nix @@ -9,14 +9,19 @@ callback: { ... } @ args: let customConfigPath = builtins.tryEval <spectrum-config>; + + default = import ./config.default.nix; + + callConfig = config: if builtins.typeOf config == "lambda" then config { + inherit default; + } else config; in callback (args // rec { - config = ({ pkgs ? import <nixpkgs> {} }: { - inherit pkgs; - }) args.config or (if customConfigPath.success then import customConfigPath.value - else if builtins.pathExists ../config.nix then import ../config.nix - else {}); + config = default // callConfig args.config or + (if customConfigPath.success then import customConfigPath.value + else if builtins.pathExists ../config.nix then import ../config.nix + else {}); src = with config.pkgs.lib; cleanSourceWith { filter = path: type: |