flake: start moving away from flake-parts

This commit is contained in:
Nikodem Rabuliński 2025-03-23 12:59:03 +01:00
parent f401950470
commit 9a382947e3
Signed by: nrabulinski
SSH key fingerprint: SHA256:AZZVyfKStaCo8sbJB+3Rr/CRrlym1oEgw7vMnynJeR8

View file

@ -3,6 +3,23 @@
inputs@{ flake-parts, ... }: inputs@{ flake-parts, ... }:
let let
nilla = import ./nilla.nix { inherit inputs; }; nilla = import ./nilla.nix { inherit inputs; };
transpose =
attrs:
let
inherit (inputs.nixpkgs) lib;
# maps an attrset of systems to packages to list of [ {name; system; value;} ]
pkgToListAll =
name: pkg:
map (system: {
inherit name system;
value = pkg.${system};
}) (builtins.attrNames pkg);
pkgsToListAll = pkgs: map (name: pkgToListAll name pkgs.${name}) (builtins.attrNames pkgs);
# list of all packages in format [ {name; system; value;} ]
allPkgs = lib.flatten (pkgsToListAll attrs);
systems = builtins.groupBy (pkg: pkg.system) allPkgs;
in
builtins.mapAttrs (_: pkgs: lib.listToAttrs pkgs) systems;
in in
flake-parts.lib.mkFlake { inherit inputs; } { flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ systems = [
@ -22,17 +39,16 @@
./services ./services
]; ];
flake.devShells = transpose (builtins.mapAttrs (_: shell: shell.result) nilla.shells);
perSystem = perSystem =
{ {
inputs', inputs',
self', self',
pkgs, pkgs,
system,
... ...
}: }:
{ {
devShells = builtins.mapAttrs (_: shell: shell.result.${system}) nilla.shells;
packages = { packages = {
# Re-export it for convenience and for caching # Re-export it for convenience and for caching
inherit (inputs'.attic.packages) attic-client attic-server; inherit (inputs'.attic.packages) attic-client attic-server;