nixos/flake.nix

100 lines
2.9 KiB
Nix

{
description = "NixOS Configuration";
inputs = {
nixpkgs-git.url = "github:/NixOS/nixpkgs";
nixpkgs-stable.url = "github:/NixOS/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:/NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:/NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
impermanence.url = "github:nix-community/impermanence";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs-wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixpkgs";
};
mailserver.url = "gitlab:/simple-nixos-mailserver/nixos-mailserver";
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
nixpkgs-wayland,
mailserver,
sops-nix,
...
}@attrs:
flake-utils.lib.eachDefaultSystem (
system:
let
inherit (nixpkgs) lib;
fn = import ./fn.nix { inherit lib; };
pkgs = nixpkgs.legacyPackages."${system}";
machineList = fn.lst {
path = toString ./machines;
fileType = "directory";
fullPath = false;
};
nixosSystemFor = machine: {
name = machine;
value =
let
configFiles = fn.lst {
path = toString ./config;
fullPath = true;
};
pkgsFiles = fn.lst {
path = toString ./pkgs;
fullPath = true;
};
serviceFiles = fn.lst {
path = toString ./services;
fullPath = true;
};
machinePath = lib.concatStringsSep "/" [
(toString ./.)
"machines"
machine
];
machineFiles = lib.filter (lib.strings.hasSuffix ".nix") (
fn.lst {
path = machinePath;
fullPath = true;
}
);
in
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = attrs // {
inherit system;
inherit fn;
};
modules = [
(
{ config, ... }:
{
config.nixpkgs.overlays = [ nixpkgs-wayland.overlay ];
}
)
(toString ./options/machine.nix)
sops-nix.nixosModules.sops
] ++ machineFiles ++ configFiles ++ pkgsFiles ++ serviceFiles;
};
};
in
{
apps = {
"lint" = {
type = "app";
program = "${pkgs.statix}/bin/statix";
};
};
formatter = pkgs.nixfmt-rfc-style;
packages.nixosConfigurations = lib.listToAttrs (map nixosSystemFor machineList);
}
);
}