mirror of
https://github.com/nix-community/flakelight.git
synced 2025-02-02 02:29:23 +01:00
Allow configuring the stdenv for devShell
This commit is contained in:
parent
366733be87
commit
a4e4a341f2
@ -368,6 +368,9 @@ access packages.
|
|||||||
attribute set mapping variables to values. It can optionally be a function to
|
attribute set mapping variables to values. It can optionally be a function to
|
||||||
such an attribute set in order to access packages.
|
such an attribute set in order to access packages.
|
||||||
|
|
||||||
|
`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.
|
||||||
|
|
||||||
For example, these can be configured as follows:
|
For example, these can be configured as follows:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
@ -386,6 +389,7 @@ For example, these can be configured as follows:
|
|||||||
'';
|
'';
|
||||||
# Set an environment var. `env` can be an be a function
|
# Set an environment var. `env` can be an be a function
|
||||||
env.TEST_VAR = "test value";
|
env.TEST_VAR = "test value";
|
||||||
|
stdenv = pkgs: pkgs.clangStdenv;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,11 @@ in
|
|||||||
(optFunctionTo (lazyAttrsOf str));
|
(optFunctionTo (lazyAttrsOf str));
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
stdenv = mkOption {
|
||||||
|
type = nullOr (functionTo package);
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
devShells = mkOption {
|
devShells = mkOption {
|
||||||
@ -45,19 +50,22 @@ in
|
|||||||
|
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
(mkIf (any (x: x != null) (attrValues config.devShell)) {
|
(mkIf (any (x: x != null) (attrValues config.devShell)) {
|
||||||
devShells.default = mkDefault ({ pkgs, mkShell }: mkShell (
|
devShells.default = mkDefault ({ pkgs, mkShell }: mkShell.override
|
||||||
optionalAttrs (config.devShell.env != null)
|
(if config.devShell.stdenv == null then { }
|
||||||
(config.devShell.env pkgs)
|
else { stdenv = config.devShell.stdenv pkgs; })
|
||||||
// optionalAttrs (config.devShell.inputsFrom != null) {
|
(
|
||||||
inputsFrom = config.devShell.inputsFrom pkgs;
|
optionalAttrs (config.devShell.env != null)
|
||||||
}
|
(config.devShell.env pkgs)
|
||||||
// optionalAttrs (config.devShell.packages != null) {
|
// optionalAttrs (config.devShell.inputsFrom != null) {
|
||||||
packages = config.devShell.packages pkgs;
|
inputsFrom = config.devShell.inputsFrom pkgs;
|
||||||
}
|
}
|
||||||
// optionalAttrs (config.devShell.shellHook != null) {
|
// optionalAttrs (config.devShell.packages != null) {
|
||||||
shellHook = config.devShell.shellHook pkgs;
|
packages = config.devShell.packages pkgs;
|
||||||
}
|
}
|
||||||
));
|
// optionalAttrs (config.devShell.shellHook != null) {
|
||||||
|
shellHook = config.devShell.shellHook pkgs;
|
||||||
|
}
|
||||||
|
));
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (config.devShells != { }) {
|
(mkIf (config.devShells != { }) {
|
||||||
|
@ -284,6 +284,7 @@ in
|
|||||||
echo Welcome to example shell!
|
echo Welcome to example shell!
|
||||||
'';
|
'';
|
||||||
env.TEST_VAR = "test value";
|
env.TEST_VAR = "test value";
|
||||||
|
stdenv = pkgs: pkgs.clangStdenv;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
(f: lib.isDerivation f.devShells.x86_64-linux.default);
|
(f: lib.isDerivation f.devShells.x86_64-linux.default);
|
||||||
|
Loading…
Reference in New Issue
Block a user