mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-02-07 12:19:07 +00:00
flake.nix: filter NixOS config as images and deployments
Though there are systems that can be used for both. For now, we'll use the deploy key as a surefire attribute that it is used for deployment while having an intended output image format. The best solution is simply have a conditional config for certain output formats.
This commit is contained in:
parent
3fa45623ed
commit
a29b1ee5e0
17
flake.nix
17
flake.nix
@ -82,6 +82,7 @@
|
|||||||
# purposes. The format used here is whatever formats nixos-generators
|
# purposes. The format used here is whatever formats nixos-generators
|
||||||
# support.
|
# support.
|
||||||
images = import ./setups/nixos.nix { inherit lib inputs; };
|
images = import ./setups/nixos.nix { inherit lib inputs; };
|
||||||
|
images' = listImagesWithSystems images;
|
||||||
|
|
||||||
# A set of users with their metadata to be deployed with home-manager.
|
# A set of users with their metadata to be deployed with home-manager.
|
||||||
users = import ./setups/home-manager.nix { inherit lib inputs; };
|
users = import ./setups/home-manager.nix { inherit lib inputs; };
|
||||||
@ -370,14 +371,17 @@
|
|||||||
|
|
||||||
# A list of NixOS configurations from the `./hosts` folder. It also has
|
# A list of NixOS configurations from the `./hosts` folder. It also has
|
||||||
# some sensible default configurations.
|
# some sensible default configurations.
|
||||||
nixosConfigurations =
|
nixosConfigurations = let
|
||||||
|
validImages = lib.filterAttrs (name: metadata:
|
||||||
|
metadata.format == null || metadata ? deploy) images;
|
||||||
|
in
|
||||||
lib.mapAttrs
|
lib.mapAttrs
|
||||||
(host: metadata:
|
(host: metadata:
|
||||||
mkHost {
|
mkHost {
|
||||||
extraModules = [ (hostSpecificModule host metadata) ];
|
extraModules = [ (hostSpecificModule host metadata) ];
|
||||||
nixpkgs-channel = metadata.nixpkgs-channel or "nixpkgs";
|
nixpkgs-channel = metadata.nixpkgs-channel or "nixpkgs";
|
||||||
})
|
})
|
||||||
(listImagesWithSystems images);
|
(listImagesWithSystems validImages);
|
||||||
|
|
||||||
# We're going to make our custom modules available for our flake. Whether
|
# We're going to make our custom modules available for our flake. Whether
|
||||||
# or not this is a good thing is debatable, I just want to test it.
|
# or not this is a good thing is debatable, I just want to test it.
|
||||||
@ -419,10 +423,9 @@
|
|||||||
# This contains images that are meant to be built and distributed
|
# This contains images that are meant to be built and distributed
|
||||||
# somewhere else including those NixOS configurations that are built as
|
# somewhere else including those NixOS configurations that are built as
|
||||||
# an ISO.
|
# an ISO.
|
||||||
images =
|
images = forAllSystems (system: let
|
||||||
forAllSystems (system:
|
validImages = lib.filterAttrs (host: metadata:
|
||||||
let
|
system == metadata._system && metadata.format != null) images';
|
||||||
images' = lib.filterAttrs (host: metadata: (system == metadata._system) && (metadata.format != null)) (listImagesWithSystems images);
|
|
||||||
in
|
in
|
||||||
lib.mapAttrs'
|
lib.mapAttrs'
|
||||||
(host: metadata:
|
(host: metadata:
|
||||||
@ -435,7 +438,7 @@
|
|||||||
inherit nixpkgs-channel format;
|
inherit nixpkgs-channel format;
|
||||||
extraModules = [ (hostSpecificModule host metadata) ];
|
extraModules = [ (hostSpecificModule host metadata) ];
|
||||||
}))
|
}))
|
||||||
images');
|
validImages);
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
{
|
{
|
||||||
ni = {
|
ni = {
|
||||||
systems = [ "x86_64-linux" ];
|
systems = [ "x86_64-linux" ];
|
||||||
format = "iso";
|
format = null;
|
||||||
modules = [
|
modules = [
|
||||||
inputs.nur.nixosModules.nur
|
inputs.nur.nixosModules.nur
|
||||||
inputs.nix-index-database.nixosModules.nix-index
|
inputs.nix-index-database.nixosModules.nix-index
|
||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
plover = {
|
plover = {
|
||||||
systems = [ "x86_64-linux" ];
|
systems = [ "x86_64-linux" ];
|
||||||
format = "iso";
|
format = null;
|
||||||
domain = "foodogsquared.one";
|
domain = "foodogsquared.one";
|
||||||
deploy = {
|
deploy = {
|
||||||
hostname = "plover.foodogsquared.one";
|
hostname = "plover.foodogsquared.one";
|
||||||
@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
winnowing = {
|
winnowing = {
|
||||||
systems = [ "x86_64-linux" ];
|
systems = [ "x86_64-linux" ];
|
||||||
format = "iso";
|
format = null;
|
||||||
modules = [
|
modules = [
|
||||||
inputs.nixos-wsl.nixosModules.default
|
inputs.nixos-wsl.nixosModules.default
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user