utils/lib/ren-module.nix

56 lines
1.5 KiB
Nix
Raw Normal View History

2025-10-04 17:32:44 +02:00
{
lib,
2025-10-06 17:18:22 +02:00
config,
options,
2025-10-04 17:32:44 +02:00
...
}: let
2025-10-06 17:18:22 +02:00
inherit (lib) mkOption mkOptionType types isAttrs hasAttr literalExpression;
mkInputOption = name: description:
2025-10-04 17:32:44 +02:00
mkOption {
type = mkOptionType {
name = "input";
2025-10-06 17:18:22 +02:00
description = "flake input for ${name}";
2025-10-04 17:32:44 +02:00
check = x: (isAttrs x) && (hasAttr "sourceInfo" x);
};
description = ''
The flake input for ${description}.
'';
2025-10-06 17:18:22 +02:00
example = literalExpression "inputs.${name}";
2025-10-04 17:32:44 +02:00
};
in {
options.ren = {
system = mkOption {
type = types.str;
description = ''
2025-10-06 17:18:22 +02:00
The system architecture (e.g., `x86_64-linux`, `aarch64-darwin`).
'';
default =
if options.ren.pkgs.isDefined
then config.ren.pkgs.system
else "";
defaultText = literalExpression ''
if options.ren.pkgs.isDefined then config.ren.pkgs.system else "";
2025-10-04 17:32:44 +02:00
'';
};
2025-10-06 17:18:22 +02:00
home-manager = mkInputOption "home-manager" "Home Manager";
disko = mkInputOption "disko" "Disko";
nixos-wsl = mkInputOption "nixos-wsl" "NixOS-WSL";
nix-darwin = mkInputOption "nix-darwin" "nix-darwin";
2025-10-04 17:32:44 +02:00
pkgs = mkOption {
type = mkOptionType {
name = "packages";
description = "instance of nixpkgs";
check = x: (isAttrs x) && (hasAttr "path" x);
};
description = ''
An instantiated nixpkgs set. Used for general pkgs and to get NixOS systems' modules.
'';
2025-10-06 17:18:22 +02:00
example = literalExpression ''
import inputs.nixpkgs { system = "aarch64-linux"; };
'';
2025-10-04 17:32:44 +02:00
};
};
}