Add allHosts script and formatting app

This commit is contained in:
Fabian Hauser 2022-04-11 22:26:50 +02:00
parent 66092ec8e5
commit 31e4a7f56f

View file

@ -21,6 +21,7 @@
inherit system;
config.allowUnfree = true; # For vscode
};
hosts = [ "speer" "hummelberg" ];
in {
checks.${system}.formatCheck = let pkgs = pkgsUnstable;
in pkgs.runCommand "nixfmt-check" { } ''
@ -33,7 +34,6 @@
# Build with `nixos-rebuild --flake .#<hostname>` or
# `nix build .#nixosConfigurations.<hostname>.config.system.build.toplevel
nixosConfigurations = let
hosts = [ "speer" "hummelberg" ];
home-manager-config = {
home-manager = {
useGlobalPkgs = true;
@ -80,14 +80,21 @@
};
devShell.${system} = import ./shell.nix { pkgs = pkgsUnstable; };
apps.${system}.format = let
pkgs = pkgsUnstable;
formatter = pkgsUnstable.writeShellScriptBin "formatter" ''
${pkgs.findutils}/bin/find . -type f -name '*.nix' -exec ${pkgs.nixfmt}/bin/nixfmt {} +
'';
in {
type = "app";
program = "${formatter}/bin/formatter";
packages.${system}.defaultPackage.${system} = let
configs = map (host: self.nixosConfigurations.${host}.config.system.build.toplevel) hosts;
in pkgsUnstable.linkFarmFromDrvs "allHosts" configs;
apps.${system} = {
format = let
pkgs = pkgsUnstable;
formatter = pkgsUnstable.writeShellScriptBin "formatter" ''
${pkgs.findutils}/bin/find . -type f -name '*.nix' -exec ${pkgs.nixfmt}/bin/nixfmt {} +
'';
in {
type = "app";
program = "${formatter}/bin/formatter";
};
};
};
}