refactor(nix): simplify forAllSystems

This commit is contained in:
seth 2024-08-06 23:27:40 -04:00 committed by Sefa Eyeoglu
parent 068da95e36
commit 75c77fae82

View file

@ -17,6 +17,7 @@
rust-overlay, rust-overlay,
}: }:
let let
inherit (nixpkgs) lib;
systems = [ systems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
@ -24,47 +25,49 @@
"aarch64-darwin" "aarch64-darwin"
]; ];
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); forAllSystems = lib.genAttrs systems;
nixpkgsFor = nixpkgs.legacyPackages;
in in
{ {
devShells = forAllSystems (pkgs: { devShells = forAllSystems (
default = pkgs.mkShell { system:
packages = with pkgs; [ let
redis pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
packages = with pkgs; [
redis
# linters & formatters # linters & formatters
actionlint actionlint
nodePackages.prettier nodePackages.prettier
# rust tools # rust tools
clippy clippy
rustfmt rustfmt
rust-analyzer rust-analyzer
# nix tools # nix tools
self.formatter.${system} self.formatter.${system}
deadnix nil
nil statix
statix ];
];
inputsFrom = [ self.packages.${pkgs.system}.refraction ]; inputsFrom = [ self.packages.${pkgs.system}.refraction ];
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}"; RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
}; };
}); }
);
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style); formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
nixosModules.default = import ./nix/module.nix self; nixosModules.default = import ./nix/module.nix self;
packages = forAllSystems ( packages = forAllSystems (
{ system:
lib,
pkgs,
system,
...
}:
let let
pkgs = nixpkgsFor.${system};
packages' = self.packages.${system}; packages' = self.packages.${system};
mkStatic = pkgs.callPackage ./nix/static.nix { mkStatic = pkgs.callPackage ./nix/static.nix {