nixos-configuration/nix-os/unstable-packages.nix
Wroclaw ffb6be2ea2 Don't depend on external nixos-unstable channel
modules can now use unstablePkgs argument
2024-02-19 07:20:12 +01:00

36 lines
No EOL
1.5 KiB
Nix

{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")
];
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;
# FIXME: move it to the system derivation output (overrideAttrs config.system.build.toplevel?)
config.environment.etc."NIXOS-UNSTABLE-VERSION".text = nixos-unstable-version;
}