Use flake-utils to map flake outputs.

This commit is contained in:
Kevin Baensch 2024-11-16 18:44:05 +01:00
parent 5a98a03819
commit 44237e65ae
Signed by: derped
GPG key ID: C0F1D326C7626543

View file

@ -7,6 +7,7 @@
nixpkgs.url = "github:/NixOS/nixpkgs/nixos-unstable"; nixpkgs.url = "github:/NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master"; nixos-hardware.url = "github:NixOS/nixos-hardware/master";
impermanence.url = "github:nix-community/impermanence"; impermanence.url = "github:nix-community/impermanence";
flake-utils.url = "github:numtide/flake-utils";
alejandra = { alejandra = {
url = "github:kamadorueda/alejandra/3.0.0"; url = "github:kamadorueda/alejandra/3.0.0";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -20,28 +21,25 @@
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
flake-utils,
alejandra, alejandra,
mailserver, mailserver,
sops-nix, sops-nix,
... ...
} @ attrs: let } @ attrs:
flake-utils.lib.eachDefaultSystem (
system: let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
fn = import ./fn.nix {inherit lib;}; fn = import ./fn.nix {inherit lib;};
mappedFormatter = builtins.mapAttrs (arch: packages: packages.default) alejandra.packages; pkgs = nixpkgs.legacyPackages."${system}";
mappedApps =
builtins.mapAttrs (_arch: packages: {
"lint" = {
type = "app";
program = "${packages.statix}/bin/statix";
};
})
nixpkgs.legacyPackages;
system = "x86_64-linux";
machineList = fn.lst { machineList = fn.lst {
p = toString ./machines; p = toString ./machines;
t = "directory"; t = "directory";
b = false; b = false;
}; };
nixosSystemFor = machine: {
name = machine;
value = let
configFiles = fn.lst { configFiles = fn.lst {
p = toString ./config; p = toString ./config;
b = true; b = true;
@ -54,9 +52,6 @@
p = toString ./services; p = toString ./services;
b = true; b = true;
}; };
nixosSystemFor = machine: {
name = machine;
value = let
machinePath = lib.concatStringsSep "/" [(toString ./.) "machines" machine]; machinePath = lib.concatStringsSep "/" [(toString ./.) "machines" machine];
machineFiles = lib.filter (lib.strings.hasSuffix ".nix") (fn.lst { machineFiles = lib.filter (lib.strings.hasSuffix ".nix") (fn.lst {
p = machinePath; p = machinePath;
@ -83,8 +78,14 @@
}; };
}; };
in { in {
apps = mappedApps; apps = {
formatter = mappedFormatter; "lint" = {
nixosConfigurations = lib.listToAttrs (map nixosSystemFor machineList); type = "app";
program = "${pkgs.statix}/bin/statix";
}; };
};
formatter = alejandra.defaultPackage."${system}";
packages.nixosConfigurations = lib.listToAttrs (map nixosSystemFor machineList);
}
);
} }