refactor: generalize flake input injection
This commit is contained in:
parent
c559bf629f
commit
5965922b57
2 changed files with 34 additions and 12 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
{
|
{
|
||||||
options.aether.deploy.rpi5 = {
|
options.aether.deploy.rpi5 = {
|
||||||
kernelPackages = lib.mkOption {
|
_internal.kernelPackages = lib.mkOption {
|
||||||
type = lib.types.raw;
|
type = lib.types.raw;
|
||||||
description = "Kernel package to use for Raspberry Pi 5 support";
|
description = ''
|
||||||
|
Kernel package to use for Raspberry Pi 5 support.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -11,7 +13,7 @@
|
||||||
let cfg = config.aether.deploy.rpi5;
|
let cfg = config.aether.deploy.rpi5;
|
||||||
in {
|
in {
|
||||||
nixpkgs.system = "aarch64-linux";
|
nixpkgs.system = "aarch64-linux";
|
||||||
boot.kernelPackages = cfg.kernelPackages;
|
boot.kernelPackages = cfg._internal.kernelPackages;
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
boot.loader.efi.canTouchEfiVariables = false;
|
boot.loader.efi.canTouchEfiVariables = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
38
flake.nix
38
flake.nix
|
|
@ -19,23 +19,43 @@ outputs = inputs@{ self, nixpkgs, agenix, rpi5-kernel, ... }:
|
||||||
let
|
let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
|
|
||||||
|
# Extra config applied to each module
|
||||||
|
# (Mostly used for injecting flake inputs)
|
||||||
|
extraConfig = {
|
||||||
|
deploy-rpi5 = {
|
||||||
|
aether.deploy.rpi5._internal.kernelPackages = lib.mkDefault
|
||||||
|
rpi5-kernel.legacyPackages.aarch64-linux.linuxPackages_rpi5;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
moduleNames =
|
moduleNames =
|
||||||
let sub = builtins.readDir ./modules;
|
let sub = builtins.readDir ./modules;
|
||||||
in builtins.filter
|
in builtins.filter
|
||||||
(d: sub.${d} == "directory")
|
(d: sub.${d} == "directory")
|
||||||
(builtins.attrNames sub);
|
(builtins.attrNames sub);
|
||||||
|
|
||||||
modules = lib.genAttrs moduleNames (name: ./modules/${name});
|
deployNames =
|
||||||
|
let sub = builtins.readDir ./deploy;
|
||||||
|
in builtins.map (d: "deploy-${d}")
|
||||||
|
(builtins.filter
|
||||||
|
(d: sub.${d} == "directory")
|
||||||
|
(builtins.attrNames sub));
|
||||||
|
|
||||||
|
modules = lib.genAttrs moduleNames
|
||||||
|
(name: ./modules/${name});
|
||||||
|
deployments = lib.genAttrs deployNames
|
||||||
|
(name: ./deploy/${lib.removePrefix "deploy-" name});
|
||||||
|
|
||||||
|
modulesWithCfg = builtins.mapAttrs (k: v: {
|
||||||
|
imports = [ v ];
|
||||||
|
} // extraConfig.${k} or {}) modules;
|
||||||
|
deploymentsWithCfg = builtins.mapAttrs (k: v: {
|
||||||
|
imports = [ v ];
|
||||||
|
} // extraConfig.${k} or {}) deployments;
|
||||||
in {
|
in {
|
||||||
nixosModules =
|
nixosModules =
|
||||||
modules
|
modulesWithCfg // deploymentsWithCfg // {
|
||||||
// {
|
all.imports = lib.attrValues modulesWithCfg;
|
||||||
all.imports = lib.attrValues modules;
|
|
||||||
deploy-rpi5 = { lib, ... }: {
|
|
||||||
imports = [ ./deploy/rpi5 ];
|
|
||||||
aether.deploy.rpi5.kernelPackages = lib.mkDefault
|
|
||||||
rpi5-kernel.legacyPackages.aarch64-linux.linuxPackages_rpi5;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosConfigurations."toki-aether" =
|
nixosConfigurations."toki-aether" =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue