flake: refactor

This commit is contained in:
Guanran Wang 2024-03-09 12:06:08 +08:00
parent db92d6ed01
commit f457676f1c
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8

View file

@ -118,8 +118,10 @@
}; };
}; };
outputs = inputs: let outputs = inputs:
inherit (inputs.flake-utils.lib) eachDefaultSystemMap; inputs.flake-utils.lib.eachDefaultSystem (system: let
pkgs = inputs.nixpkgs.legacyPackages.${system};
treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
mkNixOS = system: modules: mkNixOS = system: modules:
inputs.nixpkgs.lib.nixosSystem { inputs.nixpkgs.lib.nixosSystem {
@ -132,13 +134,20 @@
inherit system modules; inherit system modules;
specialArgs = {inherit inputs;}; specialArgs = {inherit inputs;};
}; };
treefmtEval = eachDefaultSystemMap (system: inputs.treefmt-nix.lib.evalModule inputs.nixpkgs.legacyPackages.${system} ./treefmt.nix);
in { in {
formatter = eachDefaultSystemMap (system: treefmtEval.${system}.config.build.wrapper); ### nix fmt
checks = eachDefaultSystemMap (system: {formatting = treefmtEval.${system}.config.build.check inputs.self;}); formatter = treefmtEval.config.build.wrapper;
packages = eachDefaultSystemMap (system: import ./pkgs inputs.nixpkgs.legacyPackages.${system});
### nix flake check
checks = {formatting = treefmtEval.config.build.check inputs.self;};
### nix {run,shell,build}
packages = import ./pkgs pkgs;
### nixpkgs.overlays = [];
overlays = import ./overlays; overlays = import ./overlays;
### imports = [];
nixosModules.default = ./nixos/modules; nixosModules.default = ./nixos/modules;
darwinModules.default = ./darwin/modules; darwinModules.default = ./darwin/modules;
homeManagerModules.default = ./home/modules; homeManagerModules.default = ./home/modules;
@ -154,5 +163,5 @@
"plato" = mkDarwin "x86_64-darwin" [./hosts/plato]; "plato" = mkDarwin "x86_64-darwin" [./hosts/plato];
"whitesteel" = mkDarwin "x86_64-darwin" [./hosts/whitesteel]; "whitesteel" = mkDarwin "x86_64-darwin" [./hosts/whitesteel];
}; };
}; });
} }