cerulean/nix/snow/lib/nixpkgs.nix

55 lines
1.3 KiB
Nix
Raw Normal View History

2026-03-14 22:18:28 +10:00
{
2026-03-15 01:10:36 +10:00
inputs,
2026-03-14 22:18:28 +10:00
lib,
2026-03-15 01:10:36 +10:00
...
2026-03-14 22:18:28 +10:00
}: let
inherit
(lib)
mkOption
types
;
# A best effort, lenient estimate. Please use a recent nixpkgs lib if you
# override it at all.
minVersion = "23.05pre-git";
2026-03-15 01:10:36 +10:00
isNixpkgsValidVersion = let
2026-03-17 20:37:59 +10:00
revInfo =
if inputs.nixpkgs?rev
then " (nixpkgs-lib.rev: ${inputs.nixpkgs.rev})"
else "";
2026-03-15 01:10:36 +10:00
in
2026-03-17 20:37:59 +10:00
(builtins.compareVersions lib.version minVersion >= 0)
2026-03-14 22:18:28 +10:00
|| abort ''
2026-03-15 01:10:36 +10:00
The nixpkgs dependency of snow was overridden but is too old.
2026-03-14 22:18:28 +10:00
The minimum supported version of nixpkgs-lib is ${minVersion},
but the actual version is ${lib.version}${revInfo}.
'';
in
assert isNixpkgsValidVersion; {
# Helper function for defining a per-system option that
# gets transposed by the usual flake system logic to a
# top-level outputs attribute.
mkPerSystemFlakeOutput = {
name,
option,
file,
}: {
_file = file;
options = {
outputs.${name} = mkOption {
type = types.attrsWith {
elemType = option.type;
lazy = true;
placeholder = "system";
};
default = {};
description = ''
See {option}`perSystem.${name}` for description and examples.
'';
};
};
};
}