diff options
| author | Jakub Stachurski <j.stachurski@student.utwente.nl> | 2026-04-18 23:38:22 +0200 |
|---|---|---|
| committer | Jakub Stachurski <j.stachurski@student.utwente.nl> | 2026-04-18 23:38:22 +0200 |
| commit | ff05ad9be1e136fc8eb3f7904739be97cca51ce9 (patch) | |
| tree | 5f3f44f2683c094a10dd398e96e7ff7e98bb43ae /flake.nix | |
| parent | bccc574ba48356a5f134425b14489cc802d1acf1 (diff) | |
Tweak formatting
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 28 |
1 files changed, 19 insertions, 9 deletions
@@ -50,8 +50,24 @@ "x86_64-linux" "aarch64-linux" ]; + # Allows code to execute for all used architectures forAllSystems = f: (lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system})); - treefmtEval = forAllSystems (pkgs: treefmt-nix.lib.evalModule pkgs ./modules/treefmt.nix); + + # Treefmt has a bunch of long paths that we want to bundle. + treefmtStuff = forAllSystems ( + pkgs: + let + treefmt = treefmt-nix.lib.evalModule pkgs ./modules/treefmt.nix; + in + { + formatter = treefmt.config.build.wrapper; + formatCheck = { + formatting = treefmt.config.build.check self; + }; + } + ); + # Convenient extractor which generates an attrset of system: attribute, with the attribute being picked from treefmtStuff by name. + treefmtExtract = name: (builtins.mapAttrs (_system: conf: conf."${name}") (treefmtStuff)); in { # packages."x86_64-linux".full-iso = self.nixosConfigurations.full-iso.config.system.build.isoImage; @@ -61,15 +77,9 @@ }) ); # for `nix fmt` - formatter = ( - forAllSystems (pkgs: treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.wrapper) - ); + formatter = treefmtExtract "formatter"; # for `nix flake check` - checks = ( - forAllSystems (pkgs: { - formatting = treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.check self; - }) - ); + checks = treefmtExtract "formatCheck"; nixosConfigurations = { apocalypse = nixpkgs.lib.nixosSystem { |
