1
0
Fork 0
nix-system-configurations/nix-darwin/flake-module.nix
2025-08-12 19:25:57 -05:00

59 lines
1.7 KiB
Nix

# SPDX-FileCopyrightText: 2025 Ethan Reece <contact@ethanreece.com>
#
# SPDX-License-Identifier: MIT
{
config,
flake-parts-lib,
inputs,
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.isDarwin {
commands = [
{
help = "󰘥 show nix-darwin documentation";
name = "man-darwin";
command = "darwin-help";
category = " nix-darwin";
}
]
++ builtins.concatMap (
name:
if config.targets.${name}.enable && config.targets.${name}.system == system then
[
{
help = " `darwin-rebuild switch` for ${name}";
name = "darwin-${name}";
command = "sudo ${
inputs.nix-darwin.packages.${system}.default
}/bin/darwin-rebuild switch --flake .#${name}";
category = " ${name}";
}
{
help = " 󰸨 `darwin-rebuild switch` for ${name} with backup";
name = "darwin-${name}-backup";
command = "sudo ${
inputs.nix-darwin.packages.${system}.default
}/bin/darwin-rebuild switch --flake .#${name} -b backup";
category = " ${name}";
}
]
else
[ ]
) modules;
};
};
}