Update formatter
This commit is contained in:
parent
4eea2232fb
commit
d8235cb2a9
55 changed files with 1031 additions and 664 deletions
110
flake.nix
110
flake.nix
|
@ -15,83 +15,79 @@
|
|||
url = "git+file:///etc/nixos/fcc-unlock";
|
||||
inputs.nixos-stable.follows = "nixpkgs-stable";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs-unstable, nixpkgs-stable, home-manager
|
||||
, nixos-hardware, fcc-unlock, catppuccin, ... }@inputs:
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs-unstable,
|
||||
nixpkgs-stable,
|
||||
home-manager,
|
||||
nixos-hardware,
|
||||
fcc-unlock,
|
||||
catppuccin,
|
||||
...
|
||||
}@inputs:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgsUnstable = import nixpkgs-unstable {
|
||||
inherit system;
|
||||
config.allowUnfree = true; # For vscode
|
||||
};
|
||||
hosts = [ "speer" "hummelberg" "ochsenchopf" ];
|
||||
in {
|
||||
checks.${system}.formatCheck = let pkgs = pkgsUnstable;
|
||||
in pkgs.runCommand "nixfmt-check" { } ''
|
||||
set -euo pipefail
|
||||
cd ${self}
|
||||
${self.apps.${system}.format.program} --check
|
||||
mkdir $out
|
||||
'';
|
||||
|
||||
hosts = [
|
||||
"speer"
|
||||
"hummelberg"
|
||||
"ochsenchopf"
|
||||
];
|
||||
in
|
||||
{
|
||||
# Build with `nixos-rebuild --flake .#<hostname>` or
|
||||
# `nix build .#nixosConfigurations.<hostname>.config.system.build.toplevel
|
||||
nixosConfigurations = let
|
||||
sharedSpecialArgs = {
|
||||
inherit pkgsUnstable;
|
||||
pkgFccUnlock = fcc-unlock.packages.${system}.default;
|
||||
|
||||
};
|
||||
home-manager-config = {
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = sharedSpecialArgs;
|
||||
users.fhauser.imports = [
|
||||
./home/fhauser/default.nix
|
||||
catppuccin.homeManagerModules.catppuccin
|
||||
];
|
||||
nixosConfigurations =
|
||||
let
|
||||
sharedSpecialArgs = {
|
||||
inherit pkgsUnstable;
|
||||
pkgFccUnlock = fcc-unlock.packages.${system}.default;
|
||||
};
|
||||
};
|
||||
mapHostnameToAttr = host:
|
||||
nixpkgs-stable.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = sharedSpecialArgs // {
|
||||
hardwareModules = nixos-hardware.nixosModules;
|
||||
home-manager-config = {
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = sharedSpecialArgs;
|
||||
users.fhauser.imports = [
|
||||
./home/fhauser/default.nix
|
||||
catppuccin.homeManagerModules.catppuccin
|
||||
];
|
||||
};
|
||||
modules = [
|
||||
home-manager.nixosModules.home-manager
|
||||
catppuccin.nixosModules.catppuccin
|
||||
./host/${host}/default.nix
|
||||
] ++ (if host == "bachtel" then [ ] else [ home-manager-config ]);
|
||||
};
|
||||
in pkgsUnstable.lib.genAttrs hosts mapHostnameToAttr;
|
||||
mapHostnameToAttr =
|
||||
host:
|
||||
nixpkgs-stable.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = sharedSpecialArgs // {
|
||||
hardwareModules = nixos-hardware.nixosModules;
|
||||
};
|
||||
modules = [
|
||||
home-manager.nixosModules.home-manager
|
||||
catppuccin.nixosModules.catppuccin
|
||||
./host/${host}/default.nix
|
||||
] ++ (if host == "bachtel" then [ ] else [ home-manager-config ]);
|
||||
};
|
||||
in
|
||||
pkgsUnstable.lib.genAttrs hosts mapHostnameToAttr;
|
||||
|
||||
# Nix development shell
|
||||
devShells.${system}.default = import ./shell.nix { pkgs = pkgsUnstable; };
|
||||
|
||||
# Run checks and build all hosts as default package
|
||||
packages.${system}.default = with pkgsUnstable.lib;
|
||||
packages.${system}.default =
|
||||
with pkgsUnstable.lib;
|
||||
let
|
||||
checks = attrValues self.checks.${system};
|
||||
nixosConfigs = mapAttrsToList (n: v: v.config.system.build.toplevel)
|
||||
self.nixosConfigurations;
|
||||
in pkgsUnstable.linkFarmFromDrvs "allHosts" (checks ++ nixosConfigs);
|
||||
nixosConfigs = mapAttrsToList (n: v: v.config.system.build.toplevel) self.nixosConfigurations;
|
||||
in
|
||||
pkgsUnstable.linkFarmFromDrvs "allHosts" (checks ++ nixosConfigs);
|
||||
|
||||
apps.${system} = {
|
||||
|
||||
# Execute nixfmt on the repository
|
||||
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";
|
||||
};
|
||||
};
|
||||
formatter.${system} = pkgsUnstable.nixfmt-rfc-style;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue