pkgs/overlays: create, move unstable there
also in unstable: use nixpkgs option to define if unstable nixpkgs expressions should be from nixos or nixpkgs channel (default true, use nixos channel)
This commit is contained in:
parent
3b7c1594ac
commit
88f348a2c9
2 changed files with 46 additions and 27 deletions
|
@ -1,37 +1,20 @@
|
|||
{config, pkgs, lib, ...}:
|
||||
|
||||
let
|
||||
nixos-unstable-exprs = builtins.fetchTarball https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz;
|
||||
nixos-unstable = import nixos-unstable-exprs {
|
||||
inherit (config.nixpkgs) config localSystem crossSystem;
|
||||
overlays = if config.unstable.usePkgsOverlays then config.pkgs.overlays else [];
|
||||
};
|
||||
nixos-unstable-version = builtins.concatStringsSep "." [
|
||||
(builtins.readFile "${builtins.toString nixos-unstable-exprs}/.version")
|
||||
(builtins.readFile "${builtins.toString nixos-unstable-exprs}/.version-suffix")
|
||||
];
|
||||
cfg = config.unstable;
|
||||
unstableOverlay = import ../pkgs/overlays/unstable.nix;
|
||||
in
|
||||
{
|
||||
options.unstable = {
|
||||
enable = lib.mkEnableOption (lib.mkDoc ''
|
||||
use of unstable packages in configuration. You can use `unstablePkgs` in configuration modules
|
||||
'') // { default = true; };
|
||||
usePkgsOverlays = lib.mkEnableOption (lib.mkDoc ''
|
||||
use overlays from `nixpkgs.overlays`
|
||||
'');
|
||||
pkgs = lib.mkOption {
|
||||
default = if config.unstable.enable then nixos-unstable else pkgs;
|
||||
description = lib.mkDoc ''
|
||||
acts like pkgs, but it has unstable packages if `unstable.enable` is enabled.
|
||||
You can also use `unstablePkgs` in module arguments.
|
||||
'';
|
||||
visible = true;
|
||||
readOnly = true;
|
||||
type = lib.types.pkgs;
|
||||
};
|
||||
};
|
||||
config._module.args.unstablePkgs = config.unstable.pkgs;
|
||||
config.system.extraSystemBuilderCmds = lib.mkIf config.unstable.enable ''
|
||||
echo ${nixos-unstable-version} > $out/nixos-unstable-version
|
||||
'';
|
||||
}
|
||||
config = {
|
||||
_module.args.unstablePkgs = if config.unstable.enable then pkgs.unstable else pkgs;
|
||||
nixpkgs.overlays = lib.mkIf cfg.enable [ unstableOverlay ];
|
||||
system.extraSystemBuilderCmds = lib.mkIf config.unstable.enable ''
|
||||
echo ${pkgs.unstableVersion} > $out/nixos-unstable-version
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue