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,41 +118,50 @@
}; };
}; };
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 {
inherit system modules; inherit system modules;
specialArgs = {inherit inputs;}; specialArgs = {inherit inputs;};
};
mkDarwin = system: modules:
inputs.nix-darwin.lib.darwinSystem {
inherit system modules;
specialArgs = {inherit inputs;};
};
in {
### nix fmt
formatter = treefmtEval.config.build.wrapper;
### nix flake check
checks = {formatting = treefmtEval.config.build.check inputs.self;};
### nix {run,shell,build}
packages = import ./pkgs pkgs;
### nixpkgs.overlays = [];
overlays = import ./overlays;
### imports = [];
nixosModules.default = ./nixos/modules;
darwinModules.default = ./darwin/modules;
homeManagerModules.default = ./home/modules;
### NixOS
nixosConfigurations = {
"aristotle" = mkNixOS "x86_64-linux" [./hosts/aristotle];
"blacksteel" = mkNixOS "x86_64-linux" [./hosts/blacksteel];
}; };
mkDarwin = system: modules: ### Darwin
inputs.nix-darwin.lib.darwinSystem { darwinConfigurations = {
inherit system modules; "plato" = mkDarwin "x86_64-darwin" [./hosts/plato];
specialArgs = {inherit inputs;}; "whitesteel" = mkDarwin "x86_64-darwin" [./hosts/whitesteel];
}; };
});
treefmtEval = eachDefaultSystemMap (system: inputs.treefmt-nix.lib.evalModule inputs.nixpkgs.legacyPackages.${system} ./treefmt.nix);
in {
formatter = eachDefaultSystemMap (system: treefmtEval.${system}.config.build.wrapper);
checks = eachDefaultSystemMap (system: {formatting = treefmtEval.${system}.config.build.check inputs.self;});
packages = eachDefaultSystemMap (system: import ./pkgs inputs.nixpkgs.legacyPackages.${system});
overlays = import ./overlays;
nixosModules.default = ./nixos/modules;
darwinModules.default = ./darwin/modules;
homeManagerModules.default = ./home/modules;
### NixOS
nixosConfigurations = {
"aristotle" = mkNixOS "x86_64-linux" [./hosts/aristotle];
"blacksteel" = mkNixOS "x86_64-linux" [./hosts/blacksteel];
};
### Darwin
darwinConfigurations = {
"plato" = mkDarwin "x86_64-darwin" [./hosts/plato];
"whitesteel" = mkDarwin "x86_64-darwin" [./hosts/whitesteel];
};
};
} }