46 lines
1.4 KiB
Nix
46 lines
1.4 KiB
Nix
# SPDX-FileCopyrightText: 2025 Ethan Reece <contact@ethanreece.com>
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
{
|
|
config,
|
|
flake-parts-lib,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
entries = builtins.attrNames (builtins.readDir ./.);
|
|
modules = builtins.filter (dir: builtins.pathExists (./. + "/${dir}/flake-module.nix")) entries;
|
|
in
|
|
{
|
|
imports = builtins.map (
|
|
module-name:
|
|
flake-parts-lib.importApply (./. + "/${module-name}/flake-module.nix") { inherit module-name; }
|
|
) modules;
|
|
perSystem =
|
|
{ pkgs, system, ... }:
|
|
{
|
|
devshells.default = lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
|
|
commands = builtins.concatMap (
|
|
name:
|
|
if config.targets.${name}.enable && config.targets.${name}.system == system then
|
|
[
|
|
{
|
|
help = " `nixos-rebuild switch` for ${name}";
|
|
name = "nixos-${name}";
|
|
command = "${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --flake .#${name}";
|
|
category = " ${name}";
|
|
}
|
|
{
|
|
help = " `nixos-rebuild switch` for ${name} with backup";
|
|
name = "nixos-${name}-backup";
|
|
command = "${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --flake .#${name} -b backup";
|
|
category = " ${name}";
|
|
}
|
|
]
|
|
else
|
|
[ ]
|
|
) modules;
|
|
};
|
|
};
|
|
}
|