lib/nixos: update to include config

This commit is contained in:
Gabriel Arazas 2024-02-28 18:44:27 +08:00
parent b84d07ac0c
commit c08289419c
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
2 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,5 @@
# All of the functions suitable only for NixOS. # All of the functions suitable only for NixOS.
{ pkgs, lib }: { pkgs, config, lib }:
rec { rec {
# This is only used for home-manager users without a NixOS user counterpart. # This is only used for home-manager users without a NixOS user counterpart.
@ -30,4 +30,14 @@ rec {
settings settings
]; ];
}); });
# Checks if the NixOS configuration is part of the nixos-generator build.
# Typically, we just check if there's a certain attribute that is imported
# from it.
hasNixosFormat =
pkgs.lib.hasAttrByPath [ "formatAttr" ] config;
# Checks if the NixOS config is being built for a particular format.
isFormat = format:
hasNixosFormat && config.formatAttr == format;
} }

View File

@ -1,6 +1,6 @@
# All of the extra module arguments to be passed as part of the holistic NixOS # All of the extra module arguments to be passed as part of the holistic NixOS
# system. # system.
{ options, lib, pkgs, ... }: { config, options, lib, pkgs, ... }:
let let
foodogsquaredLib = import ../../../lib { inherit pkgs; }; foodogsquaredLib = import ../../../lib { inherit pkgs; };
@ -8,7 +8,7 @@ in
{ {
_module.args.foodogsquaredLib = _module.args.foodogsquaredLib =
foodogsquaredLib.extend (final: prev: foodogsquaredLib.extend (final: prev:
import ../../../lib/nixos.nix { inherit pkgs; lib = prev; } import ../../../lib/nixos.nix { inherit pkgs config; lib = prev; }
// lib.optionalAttrs (options?sops) { // lib.optionalAttrs (options?sops) {
sops-nix = import ../../../lib/sops.nix { inherit pkgs; lib = prev; }; sops-nix = import ../../../lib/sops.nix { inherit pkgs; lib = prev; };
}); });