2023-02-06 22:44:12 +01:00
|
|
|
{
|
|
|
|
description = "NixOS Configuration";
|
|
|
|
inputs = rec {
|
2023-04-16 13:43:17 +02:00
|
|
|
nixpkgs-git.url = "github:/NixOS/nixpkgs";
|
2023-02-06 22:44:12 +01:00
|
|
|
nixpkgs-stable.url = "github:/NixOS/nixpkgs/nixos-22.11";
|
2023-04-16 13:43:17 +02:00
|
|
|
nixpkgs-unstable.url = "github:/NixOS/nixpkgs/nixos-unstable";
|
|
|
|
nixpkgs.url = "github:/NixOS/nixpkgs/nixos-unstable";
|
2023-09-11 20:05:16 +02:00
|
|
|
alejandra = {
|
|
|
|
url = github:kamadorueda/alejandra/3.0.0;
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-02-06 22:44:12 +01:00
|
|
|
mailserver.url = "gitlab:/simple-nixos-mailserver/nixos-mailserver";
|
|
|
|
sops-nix = {
|
|
|
|
url = github:Mic92/sops-nix;
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
2023-09-11 20:23:04 +02:00
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
alejandra,
|
|
|
|
mailserver,
|
|
|
|
sops-nix,
|
|
|
|
...
|
|
|
|
} @ attrs: let
|
2023-02-06 22:44:12 +01:00
|
|
|
lib = nixpkgs.lib;
|
2023-09-11 20:23:04 +02:00
|
|
|
fn = import ./fn.nix {inherit lib;};
|
2023-09-11 20:05:16 +02:00
|
|
|
mappedFormatter = builtins.mapAttrs (arch: packages: packages.default) alejandra.packages;
|
2023-02-06 22:44:12 +01:00
|
|
|
system = "x86_64-linux";
|
2023-09-11 20:23:04 +02:00
|
|
|
machineList = fn.lst {
|
|
|
|
p = toString ./machines;
|
|
|
|
t = "directory";
|
|
|
|
b = false;
|
|
|
|
};
|
|
|
|
configFiles = fn.lst {
|
|
|
|
p = toString ./config;
|
|
|
|
b = true;
|
|
|
|
};
|
|
|
|
pkgsFiles = fn.lst {
|
|
|
|
p = toString ./pkgs;
|
|
|
|
b = true;
|
|
|
|
};
|
|
|
|
serviceFiles = fn.lst {
|
|
|
|
p = toString ./services;
|
|
|
|
b = true;
|
|
|
|
};
|
2023-02-06 22:44:12 +01:00
|
|
|
nixosSystemFor = machine: {
|
|
|
|
name = machine;
|
|
|
|
value = let
|
|
|
|
machinePath = lib.concatStringsSep "/" [(toString ./.) "machines" machine];
|
2023-09-11 20:23:04 +02:00
|
|
|
machineFiles = lib.filter (name: lib.strings.hasSuffix ".nix" name) (fn.lst {
|
|
|
|
p = machinePath;
|
|
|
|
b = true;
|
|
|
|
});
|
|
|
|
in
|
|
|
|
nixpkgs.lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
specialArgs = attrs // {fn = fn;};
|
|
|
|
modules =
|
|
|
|
[
|
|
|
|
(toString ./options/machine.nix)
|
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
]
|
|
|
|
++ machineFiles
|
|
|
|
++ configFiles
|
|
|
|
++ pkgsFiles
|
|
|
|
++ serviceFiles;
|
|
|
|
};
|
2023-02-06 22:44:12 +01:00
|
|
|
};
|
|
|
|
in {
|
2023-09-11 20:05:16 +02:00
|
|
|
formatter = mappedFormatter;
|
2023-02-06 22:44:12 +01:00
|
|
|
nixosConfigurations = lib.listToAttrs (map nixosSystemFor machineList);
|
|
|
|
};
|
|
|
|
}
|