nixos/flake.nix

101 lines
2.9 KiB
Nix
Raw Normal View History

2023-02-06 22:44:12 +01:00
{
description = "NixOS Configuration";
2024-07-28 14:27:51 +02:00
inputs = {
nixpkgs-git.url = "github:/NixOS/nixpkgs";
2024-07-28 14:28:25 +02:00
nixpkgs-stable.url = "github:/NixOS/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:/NixOS/nixpkgs/nixos-unstable";
nixpkgs.url = "github:/NixOS/nixpkgs/nixos-unstable";
2024-11-15 21:58:10 +01:00
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
impermanence.url = "github:nix-community/impermanence";
2024-11-16 18:44:05 +01:00
flake-utils.url = "github:numtide/flake-utils";
2024-11-20 11:56:54 +01:00
nixpkgs-wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixpkgs";
};
2023-02-06 22:44:12 +01:00
mailserver.url = "gitlab:/simple-nixos-mailserver/nixos-mailserver";
sops-nix = {
2023-09-11 21:20:14 +02:00
url = "github:Mic92/sops-nix";
2023-02-06 22:44:12 +01:00
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
nixpkgs-wayland,
mailserver,
sops-nix,
...
}@attrs:
2024-11-16 18:44:05 +01:00
flake-utils.lib.eachDefaultSystem (
system:
let
2024-11-16 18:44:05 +01:00
inherit (nixpkgs) lib;
fn = import ./fn.nix { inherit lib; };
2024-11-16 18:44:05 +01:00
pkgs = nixpkgs.legacyPackages."${system}";
machineList = fn.lst {
path = toString ./machines;
fileType = "directory";
fullPath = false;
2023-09-11 21:20:14 +02:00
};
2024-11-16 18:44:05 +01:00
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
2024-11-16 18:44:05 +01:00
nixpkgs.lib.nixosSystem {
2024-05-09 13:28:32 +02:00
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;
2024-05-09 13:28:32 +02:00
};
2023-09-11 20:23:04 +02:00
};
in
{
2024-11-16 18:44:05 +01:00
apps = {
"lint" = {
type = "app";
program = "${pkgs.statix}/bin/statix";
};
};
formatter = pkgs.nixfmt-rfc-style;
2024-11-16 18:44:05 +01:00
packages.nixosConfigurations = lib.listToAttrs (map nixosSystemFor machineList);
}
);
2023-02-06 22:44:12 +01:00
}