79 lines
2.5 KiB
Nix
79 lines
2.5 KiB
Nix
{
|
|
inputs.clan-core.url = "https://git.clan.lol/clan/clan-core/archive/26.05.tar.gz";
|
|
inputs.nixpkgs.follows = "clan-core/nixpkgs";
|
|
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
|
|
inputs.treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
|
# Simple NixOS Mailserver, pinned to the branch matching clan-core's nixpkgs.
|
|
inputs.nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-26.05";
|
|
inputs.nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.flake-parts.follows = "clan-core/flake-parts";
|
|
|
|
outputs =
|
|
inputs@{
|
|
self,
|
|
clan-core,
|
|
flake-parts,
|
|
...
|
|
}:
|
|
let
|
|
in
|
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
|
systems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"aarch64-darwin"
|
|
"x86_64-darwin"
|
|
];
|
|
|
|
imports = [
|
|
inputs.clan-core.flakeModules.default
|
|
|
|
./clan.nix
|
|
./modules/clan/flake-module.nix
|
|
];
|
|
|
|
perSystem =
|
|
{ system, ... }:
|
|
let
|
|
pkgs = clan-core.inputs.nixpkgs.legacyPackages.${system};
|
|
treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs ./fmt.nix;
|
|
clanCli = clan-core.packages.${system}.clan-cli;
|
|
# `clan machines update a b c` normally runs machines in parallel,
|
|
# which interleaves their output and buries the YubiKey PIN prompts.
|
|
# This wrapper (first in PATH) runs them one at a time instead; any
|
|
# flags fall through to the real CLI untouched.
|
|
clanSequential = pkgs.writeShellScriptBin "clan" ''
|
|
if [ "$#" -gt 3 ] && [ "$1" = machines ] && [ "$2" = update ]; then
|
|
shift 2
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
-*) exec ${clanCli}/bin/clan machines update "$@" ;;
|
|
esac
|
|
done
|
|
for machine in "$@"; do
|
|
${clanCli}/bin/clan machines update "$machine" || exit
|
|
done
|
|
exit 0
|
|
fi
|
|
exec ${clanCli}/bin/clan "$@"
|
|
'';
|
|
in
|
|
{
|
|
# `nix fmt` and the `nix flake check` formatting gate.
|
|
formatter = treefmtEval.config.build.wrapper;
|
|
checks.formatting = treefmtEval.config.build.check self;
|
|
|
|
# Add the Clan cli tool to the dev shell.
|
|
# Use "nix develop" to enter the dev shell.
|
|
devShells.default = pkgs.mkShell {
|
|
packages = [
|
|
clanSequential
|
|
clanCli
|
|
treefmtEval.config.build.wrapper
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|