refactor(nix): use precommit flake module
This commit is contained in:
parent
04f68bbf01
commit
8677925c11
1 changed files with 72 additions and 67 deletions
139
flake.nix
139
flake.nix
|
@ -1,4 +1,76 @@
|
|||
{
|
||||
outputs = {
|
||||
flake-parts,
|
||||
self,
|
||||
...
|
||||
} @ inputs: let
|
||||
overlays = [
|
||||
(final: prev: rec {
|
||||
atuin = unstable.atuin;
|
||||
unstable = import inputs.nixpkgs-unstable {inherit (prev) system;};
|
||||
})
|
||||
];
|
||||
in
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
flake = {
|
||||
nixosConfigurations.main-node = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
{
|
||||
_module.args.nixinate = {
|
||||
host = "main-node";
|
||||
buildOn = "remote";
|
||||
hermetic = false;
|
||||
};
|
||||
nixpkgs = {
|
||||
config.allowUnfree = true;
|
||||
inherit overlays;
|
||||
};
|
||||
}
|
||||
./hosts/main-node
|
||||
./config
|
||||
./modules
|
||||
inputs.agenix.nixosModules.default
|
||||
inputs.valheim-server.nixosModules.default
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
perSystem = {
|
||||
config,
|
||||
inputs',
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}: {
|
||||
apps = (inputs.nixinate.nixinate.${system} self).nixinate;
|
||||
|
||||
pre-commit = {
|
||||
check.enable = true;
|
||||
settings.hooks = {
|
||||
alejandra.enable = true;
|
||||
commitizen.enable = true;
|
||||
editorconfig-checker.enable = true;
|
||||
nil.enable = true;
|
||||
shellcheck.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = config.pre-commit.devShell.overrideAttrs (old: {
|
||||
buildInputs = [
|
||||
pkgs.alejandra
|
||||
pkgs.nil
|
||||
inputs'.agenix.packages.agenix
|
||||
];
|
||||
});
|
||||
|
||||
formatter = pkgs.alejandra;
|
||||
};
|
||||
|
||||
imports = [inputs.pre-commit-hooks.flakeModule];
|
||||
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
|
||||
};
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
|
||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
|
@ -36,71 +108,4 @@
|
|||
"pre-commit-hooks.cachix.org-1:Pkk3Panw5AW24TOv6kz3PvLhlH8puAsJTBbOPmBo7Rc="
|
||||
];
|
||||
};
|
||||
|
||||
outputs = {
|
||||
flake-parts,
|
||||
self,
|
||||
...
|
||||
} @ inputs: let
|
||||
overlays = [
|
||||
(final: prev: rec {
|
||||
atuin = unstable.atuin;
|
||||
unstable = import inputs.nixpkgs-unstable {
|
||||
inherit (prev) system;
|
||||
};
|
||||
})
|
||||
];
|
||||
in
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
flake = {
|
||||
nixosConfigurations.main-node = inputs.nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
{
|
||||
_module.args.nixinate = {
|
||||
host = "main-node";
|
||||
buildOn = "remote";
|
||||
hermetic = false;
|
||||
};
|
||||
nixpkgs = {
|
||||
config.allowUnfree = true;
|
||||
inherit overlays;
|
||||
};
|
||||
}
|
||||
./hosts/main-node
|
||||
./config
|
||||
./modules
|
||||
# inputs.attic.nixosModules.atticd
|
||||
inputs.agenix.nixosModules.default
|
||||
inputs.valheim-server.nixosModules.default
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
perSystem = {
|
||||
inputs',
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}: {
|
||||
apps = (inputs.nixinate.nixinate.${system} self).nixinate;
|
||||
|
||||
checks.pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
alejandra.enable = true;
|
||||
nil.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [inputs'.agenix.packages.agenix];
|
||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||
};
|
||||
|
||||
formatter = pkgs.alejandra;
|
||||
};
|
||||
|
||||
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue