2023-12-23 06:49:01 +01:00
|
|
|
{
|
2023-12-23 07:39:10 +01:00
|
|
|
description = "NixOS configuration for RAD-Development Servers";
|
2023-12-23 06:49:01 +01:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
2023-12-25 03:39:20 +01:00
|
|
|
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
2023-12-23 06:49:01 +01:00
|
|
|
|
2023-12-24 18:48:52 +01:00
|
|
|
nixos-modules = {
|
|
|
|
url = "github:SuperSandro2000/nixos-modules";
|
|
|
|
inputs.nixpkgs-lib.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2023-12-25 03:39:20 +01:00
|
|
|
home-manager = {
|
|
|
|
url = "github:nix-community/home-manager";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2023-12-23 06:49:01 +01:00
|
|
|
sops-nix = {
|
|
|
|
url = "github:Mic92/sops-nix";
|
2023-12-24 18:48:52 +01:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.follows = "nixpkgs";
|
|
|
|
nixpkgs-stable.follows = "nixpkgs";
|
|
|
|
};
|
2023-12-23 06:49:01 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-12-25 03:39:20 +01:00
|
|
|
outputs = { nixpkgs, nixos-hardware, nixos-modules, home-manager, sops-nix, ... }:
|
2023-12-24 18:48:52 +01:00
|
|
|
let
|
|
|
|
inherit (nixpkgs) lib;
|
2023-12-24 20:09:35 +01:00
|
|
|
src = builtins.filterSource (path: type: type == "directory" || lib.hasSuffix ".nix" (baseNameOf path)) ./.;
|
|
|
|
ls = dir: lib.attrNames (builtins.readDir (src + "/${dir}"));
|
|
|
|
fileList = dir: map (file: ./. + "/${dir}/${file}") (ls dir);
|
2023-12-24 18:48:52 +01:00
|
|
|
in {
|
2023-12-23 06:49:01 +01:00
|
|
|
nixosConfigurations = let
|
|
|
|
constructSystem = {
|
|
|
|
hostname,
|
|
|
|
system ? "x86_64-linux",
|
|
|
|
modules ? [],
|
2023-12-25 03:39:20 +01:00
|
|
|
users ? ["dennis"],
|
2023-12-24 18:48:52 +01:00
|
|
|
}: lib.nixosSystem {
|
|
|
|
inherit system;
|
|
|
|
|
2023-12-23 06:49:01 +01:00
|
|
|
modules = [
|
2023-12-24 18:48:52 +01:00
|
|
|
nixos-modules.nixosModule
|
2023-12-25 03:39:20 +01:00
|
|
|
home-manager.nixosModules.home-manager
|
2023-12-23 06:49:01 +01:00
|
|
|
sops-nix.nixosModules.sops
|
2023-12-24 18:48:52 +01:00
|
|
|
./systems/programs.nix
|
|
|
|
./systems/configuration.nix
|
2023-12-24 20:09:35 +01:00
|
|
|
./systems/${hostname}/hardware.nix
|
2023-12-24 18:48:52 +01:00
|
|
|
./systems/${hostname}/configuration.nix
|
2023-12-25 03:39:20 +01:00
|
|
|
{ config.networking.hostName = "${hostname}"; }
|
|
|
|
] ++ modules ++ fileList "modules"
|
|
|
|
++ map(user: { config, lib, pkgs, ... }@args: {
|
|
|
|
users.users.${user} = import ./users/${user} (args // { name = "${user}"; });
|
2023-12-25 18:54:38 +01:00
|
|
|
boot.initrd.network.ssh.authorizedKeys = config.users.users.${user}.openssh.authorizedKeys.keys;
|
2023-12-26 19:06:02 +01:00
|
|
|
sops = {
|
|
|
|
secrets."${user}/user-password" = {
|
|
|
|
sopsFile = ./users/${user}/secrets.yaml;
|
|
|
|
neededForUsers = true;
|
|
|
|
};
|
|
|
|
};
|
2023-12-25 03:39:20 +01:00
|
|
|
}) users
|
|
|
|
++ map(user: { home-manager.users.${user} = import ./users/${user}/home.nix; }) users;
|
2023-12-23 06:49:01 +01:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
photon = constructSystem {
|
2023-12-24 18:48:52 +01:00
|
|
|
hostname = "photon";
|
2023-12-25 18:54:38 +01:00
|
|
|
users = [
|
|
|
|
"alice"
|
|
|
|
"dennis"
|
|
|
|
];
|
2023-12-23 06:49:01 +01:00
|
|
|
};
|
2023-12-23 07:39:10 +01:00
|
|
|
|
|
|
|
palatine-hill = constructSystem {
|
2023-12-24 18:48:52 +01:00
|
|
|
hostname = "palatine-hill";
|
2023-12-25 18:54:38 +01:00
|
|
|
users = [
|
|
|
|
"alice"
|
|
|
|
"dennis"
|
|
|
|
];
|
2023-12-23 07:39:10 +01:00
|
|
|
};
|
2023-12-23 06:49:01 +01:00
|
|
|
};
|
2023-12-26 19:06:02 +01:00
|
|
|
|
|
|
|
devShell = lib.mapAttrs (system: sopsPkgs:
|
|
|
|
with nixpkgs.legacyPackages.${system};
|
|
|
|
mkShell {
|
|
|
|
sopsPGPKeyDirs = [ "./keys" ];
|
|
|
|
nativeBuildInputs = [
|
|
|
|
apacheHttpd
|
|
|
|
sopsPkgs.sops-import-keys-hook
|
|
|
|
];
|
|
|
|
}
|
|
|
|
) sops-nix.packages;
|
2023-12-23 06:49:01 +01:00
|
|
|
};
|
|
|
|
}
|