flake: separate images to images attribute

This also allows for downstream users to import my flake now (if there's
any).
This commit is contained in:
Gabriel Arazas 2023-07-14 13:17:05 +08:00
parent d524444ae0
commit 06704f5ab6
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC

View File

@ -365,29 +365,45 @@
# My custom packages, available in here as well. Though, I mainly support # My custom packages, available in here as well. Though, I mainly support
# "x86_64-linux". I just want to try out supporting other systems. # "x86_64-linux". I just want to try out supporting other systems.
packages = forAllSystems (system: packages = forAllSystems (system:
let inputs.flake-utils.lib.flattenTree (import ./pkgs {
pkgs = import nixpkgs { inherit system overlays; }; pkgs = import nixpkgs {
in inherit system;
inputs.flake-utils.lib.flattenTree (import ./pkgs { inherit pkgs; }) overlays = [
// lib'.mapAttrs' (final: prev: {
(host: metadata: inherit (inputs.firefox-addons.lib.${system}) buildFirefoxXpiAddon;
lib'.nameValuePair "nixos-image-${metadata.format or "iso"}-${host}" (mkImage { })
inherit system pkgs extraArgs; ];
format = metadata.format or "iso"; };
extraModules = [ }));
({ lib, ... }: {
config = lib.mkMerge [
{ networking.hostName = metadata.hostname or host; }
(lib.mkIf (metadata ? domain) # This contains images that are meant to be built and distributed
{ networking.domain = metadata.domain; }) # somewhere else including those NixOS configurations that are built as
]; # an ISO.
}) images =
hostSharedConfig lib'.mapAttrs
./hosts/${host} (host: metadata:
]; let
})) system = metadata.system or defaultSystem;
images); nixpkgs-channel = metadata.nixpkgs-channel or "nixpkgs";
pkgs = import inputs."${nixpkgs-channel}" { inherit system; };
format = metadata.format or "iso";
in
mkImage {
inherit format system pkgs extraArgs;
extraModules = [
({ lib, ... }: {
config = lib.mkMerge [
{ networking.hostName = lib.mkForce metadata.hostname or host; }
(lib.mkIf (metadata ? domain)
{ networking.domain = lib.mkForce metadata.domain; })
];
})
hostSharedConfig
./hosts/${host}
];
})
images;
# My several development shells for usual type of projects. This is much # My several development shells for usual type of projects. This is much
# more preferable than installing all of the packages at the system # more preferable than installing all of the packages at the system