forked from extern/flakelight
Allow devShell to be set to a package definition
This commit is contained in:
parent
b094ced95d
commit
8f3bfc39aa
@ -371,6 +371,9 @@ such an attribute set in order to access packages.
|
|||||||
`devShell.stdenv` allows changing the stdenv used for the shell. It is a
|
`devShell.stdenv` allows changing the stdenv used for the shell. It is a
|
||||||
function that takes the package set and returns the stdenv to use.
|
function that takes the package set and returns the stdenv to use.
|
||||||
|
|
||||||
|
`devShell` can alternatively be set to a package definition, which is then used
|
||||||
|
as the default shell, overriding the above options.
|
||||||
|
|
||||||
For example, these can be configured as follows:
|
For example, these can be configured as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
@ -397,7 +400,7 @@ For example, these can be configured as follows:
|
|||||||
|
|
||||||
The above exports `devShells.${system}.default` outputs.
|
The above exports `devShells.${system}.default` outputs.
|
||||||
|
|
||||||
To add build inputs of one of your packages, you can do as follows:
|
To add the build inputs of one of your packages, you can do as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
|
@ -5,43 +5,51 @@
|
|||||||
{ config, lib, flakelight, ... }:
|
{ config, lib, flakelight, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) filterAttrs mapAttrs mkDefault mkIf mkMerge mkOption;
|
inherit (lib) filterAttrs mapAttrs mkDefault mkIf mkMerge mkOption;
|
||||||
inherit (lib.types) functionTo lazyAttrsOf lines listOf nullOr package str
|
inherit (lib.types) coercedTo functionTo lazyAttrsOf lines listOf nullOr
|
||||||
submodule;
|
package str submodule;
|
||||||
inherit (flakelight) supportedSystem;
|
inherit (flakelight) supportedSystem;
|
||||||
inherit (flakelight.types) optFunctionTo packageDef;
|
inherit (flakelight.types) optFunctionTo packageDef;
|
||||||
|
|
||||||
|
devShellModule.options = {
|
||||||
|
inputsFrom = mkOption {
|
||||||
|
type = functionTo (listOf package);
|
||||||
|
default = _: [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = mkOption {
|
||||||
|
type = functionTo (listOf package);
|
||||||
|
default = _: [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
shellHook = mkOption {
|
||||||
|
type = optFunctionTo lines;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
env = mkOption {
|
||||||
|
type = optFunctionTo (lazyAttrsOf str);
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
stdenv = mkOption {
|
||||||
|
type = functionTo package;
|
||||||
|
default = pkgs: pkgs.stdenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
overrideShell = mkOption {
|
||||||
|
type = nullOr packageDef;
|
||||||
|
internal = true;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
devShell = mkOption {
|
devShell = mkOption {
|
||||||
default = null;
|
default = null;
|
||||||
type = nullOr (submodule {
|
type = nullOr (coercedTo packageDef
|
||||||
options = {
|
(x: { overrideShell = x; })
|
||||||
inputsFrom = mkOption {
|
(submodule devShellModule));
|
||||||
type = functionTo (listOf package);
|
|
||||||
default = _: [ ];
|
|
||||||
};
|
|
||||||
|
|
||||||
packages = mkOption {
|
|
||||||
type = functionTo (listOf package);
|
|
||||||
default = _: [ ];
|
|
||||||
};
|
|
||||||
|
|
||||||
shellHook = mkOption {
|
|
||||||
type = optFunctionTo lines;
|
|
||||||
default = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
env = mkOption {
|
|
||||||
type = optFunctionTo (lazyAttrsOf str);
|
|
||||||
default = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
stdenv = mkOption {
|
|
||||||
type = functionTo package;
|
|
||||||
default = pkgs: pkgs.stdenv;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells = mkOption {
|
devShells = mkOption {
|
||||||
@ -53,12 +61,13 @@ in
|
|||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
(mkIf (config.devShell != null) {
|
(mkIf (config.devShell != null) {
|
||||||
devShells.default = mkDefault ({ pkgs, mkShell }:
|
devShells.default = mkDefault ({ pkgs, mkShell }:
|
||||||
mkShell.override { stdenv = config.devShell.stdenv pkgs; }
|
let cfg = mapAttrs (_: v: v pkgs) config.devShell; in
|
||||||
((config.devShell.env pkgs) // {
|
mkShell.override { inherit (cfg) stdenv; }
|
||||||
inputsFrom = config.devShell.inputsFrom pkgs;
|
(cfg.env // { inherit (cfg) inputsFrom packages shellHook; }));
|
||||||
packages = config.devShell.packages pkgs;
|
})
|
||||||
shellHook = config.devShell.shellHook pkgs;
|
|
||||||
}));
|
(mkIf (config.devShell.overrideShell or null != null) {
|
||||||
|
devShells.default = config.devShell.overrideShell;
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (config.devShells != { }) {
|
(mkIf (config.devShells != { }) {
|
||||||
|
@ -298,7 +298,7 @@ in
|
|||||||
|
|
||||||
devShell-override = test
|
devShell-override = test
|
||||||
(flakelight ./empty {
|
(flakelight ./empty {
|
||||||
devShells.default = { mkShell }: mkShell { };
|
devShell = { mkShell }: mkShell { };
|
||||||
})
|
})
|
||||||
(f: f ? devShells.x86_64-linux.default);
|
(f: f ? devShells.x86_64-linux.default);
|
||||||
|
|
||||||
@ -314,6 +314,12 @@ in
|
|||||||
&& (f ? devShells.x86_64-linux.shell1)
|
&& (f ? devShells.x86_64-linux.shell1)
|
||||||
&& (f ? devShells.x86_64-linux.shell2));
|
&& (f ? devShells.x86_64-linux.shell2));
|
||||||
|
|
||||||
|
devShells-override = test
|
||||||
|
(flakelight ./empty {
|
||||||
|
devShells.default = { mkShell }: mkShell { };
|
||||||
|
})
|
||||||
|
(f: f ? devShells.x86_64-linux.default);
|
||||||
|
|
||||||
overlay = test
|
overlay = test
|
||||||
(flakelight ./empty {
|
(flakelight ./empty {
|
||||||
overlay = final: prev: { testValue = "hello"; };
|
overlay = final: prev: { testValue = "hello"; };
|
||||||
|
Loading…
Reference in New Issue
Block a user