2023-12-01 11:29:39 +00:00
|
|
|
{
|
2024-05-01 12:00:39 +00:00
|
|
|
description = "NixOS Machine Configurations by manuth";
|
2023-12-01 11:29:39 +00:00
|
|
|
|
2024-05-01 12:00:39 +00:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "nixpkgs/38c01297e7ec11f7b9e3f2cae7d6fcec6cc767ec";
|
2024-05-01 16:14:25 +00:00
|
|
|
flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a";
|
2024-05-09 00:06:59 +00:00
|
|
|
|
|
|
|
home-manager = {
|
|
|
|
url = "github:nix-community/home-manager?ref=6e277d9566de9976f47228dd8c580b97488734d4";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2024-05-01 23:08:45 +00:00
|
|
|
sops-nix.url = "github:Mic92/sops-nix?ref=f1b0adc27265274e3b0c9b872a8f476a098679bd";
|
2024-05-01 12:00:39 +00:00
|
|
|
};
|
2023-12-01 11:29:39 +00:00
|
|
|
|
2024-05-09 00:06:59 +00:00
|
|
|
outputs = { self, nixpkgs, flake-utils, home-manager, sops-nix }: (
|
2024-05-08 22:50:42 +00:00
|
|
|
let
|
|
|
|
inherit (nixpkgs) lib;
|
2024-05-08 22:59:02 +00:00
|
|
|
|
|
|
|
defaultMachine = {
|
|
|
|
system = "x86_64-linux";
|
|
|
|
|
|
|
|
config = { pkgs, ... }: {
|
|
|
|
dualBoot = false;
|
|
|
|
timeZone = null;
|
|
|
|
keyMap = "us";
|
|
|
|
keyboardLayout = "us";
|
|
|
|
localeSettings = { };
|
|
|
|
users = { };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-10 23:19:06 +00:00
|
|
|
machineDefinitions = {
|
2024-05-08 22:59:02 +00:00
|
|
|
nixos.config = { ... }: {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-10 23:22:32 +00:00
|
|
|
machines = builtins.mapAttrs (
|
|
|
|
name: machineDefinition:
|
|
|
|
defaultMachine // machineDefinition // {
|
|
|
|
config = { ... }@args:
|
|
|
|
((defaultMachine.config args) // (machineDefinition.config args));
|
|
|
|
})
|
|
|
|
machineDefinitions;
|
|
|
|
|
2024-05-08 23:04:55 +00:00
|
|
|
tryFiles = import ./lib/utils/try-files.nix { inherit lib; };
|
2024-05-08 22:50:42 +00:00
|
|
|
in
|
|
|
|
flake-utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
config = {};
|
2024-05-01 23:08:45 +00:00
|
|
|
|
2024-05-08 22:50:42 +00:00
|
|
|
overlays = [
|
|
|
|
sops-nix.overlays.default
|
2024-05-01 23:08:45 +00:00
|
|
|
];
|
2024-05-08 22:50:42 +00:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
devShells.default = pkgs.mkShellNoCC (
|
|
|
|
with pkgs;
|
|
|
|
{
|
|
|
|
sopsPGPKeyDirs = [
|
|
|
|
"${toString ./.}/keys/hosts"
|
|
|
|
"${toString ./.}/keys/users"
|
|
|
|
];
|
2024-05-01 23:08:45 +00:00
|
|
|
|
2024-05-08 22:50:42 +00:00
|
|
|
packages = [
|
|
|
|
nixos-rebuild
|
|
|
|
sops
|
|
|
|
sops-import-keys-hook
|
|
|
|
ssh-to-age
|
|
|
|
ssh-to-pgp
|
|
|
|
];
|
2024-05-01 23:08:45 +00:00
|
|
|
|
2024-05-08 22:50:42 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
sops-import-keys-hook
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
) // {
|
|
|
|
nixosConfigurations =
|
|
|
|
builtins.mapAttrs (
|
2024-05-10 23:19:06 +00:00
|
|
|
hostname: { system, config }: nixpkgs.lib.nixosSystem {
|
2024-05-08 22:50:42 +00:00
|
|
|
inherit system;
|
2024-05-01 16:58:39 +00:00
|
|
|
|
2024-05-08 22:50:42 +00:00
|
|
|
modules = [
|
|
|
|
(
|
|
|
|
{ pkgs, ... }@args: {
|
|
|
|
config._module.args = {
|
2024-05-10 23:19:06 +00:00
|
|
|
inherit hostname;
|
2024-05-08 22:35:21 +00:00
|
|
|
|
2024-05-10 23:22:32 +00:00
|
|
|
machineConfig = (config args) // {
|
|
|
|
inherit hostname;
|
|
|
|
};
|
2024-05-08 22:50:42 +00:00
|
|
|
};
|
|
|
|
})
|
2024-05-09 00:06:59 +00:00
|
|
|
home-manager.nixosModules.home-manager
|
2024-05-08 22:50:42 +00:00
|
|
|
sops-nix.nixosModules.sops
|
|
|
|
./lib/configuration.nix
|
2024-05-10 23:19:06 +00:00
|
|
|
(tryFiles [ ./lib/machines/${hostname}.nix ] ./lib/hardware/base.nix)
|
2024-05-08 22:50:42 +00:00
|
|
|
];
|
2024-05-08 22:59:02 +00:00
|
|
|
})
|
2024-05-10 23:19:06 +00:00
|
|
|
machines;
|
2024-05-08 22:59:02 +00:00
|
|
|
|
|
|
|
homeConfigurations =
|
|
|
|
let
|
|
|
|
lib = nixpkgs.lib;
|
|
|
|
in
|
|
|
|
lib.attrsets.concatMapAttrs (
|
2024-05-10 23:19:06 +00:00
|
|
|
hostname: machine:
|
2024-05-08 22:59:02 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit (machine) system;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
lib.attrsets.concatMapAttrs (
|
|
|
|
username: user: {
|
2024-05-09 00:06:59 +00:00
|
|
|
"${username}@${hostname}" = home-manager.lib.homeManagerConfiguration {
|
2024-05-08 22:59:02 +00:00
|
|
|
modules =
|
|
|
|
let
|
2024-05-08 23:10:26 +00:00
|
|
|
getUserConfig = import ./lib/utils/user-config.nix { inherit lib; };
|
|
|
|
userConfigPath = getUserConfig { inherit hostname username; };
|
2024-05-08 22:59:02 +00:00
|
|
|
in [
|
|
|
|
(
|
|
|
|
{ pkgs, ... }: {
|
|
|
|
config._module.args = {
|
|
|
|
userConfig = {
|
|
|
|
inherit
|
|
|
|
hostname
|
|
|
|
username
|
|
|
|
;
|
|
|
|
} // user;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
sops-nix.homeManagerModules.sops
|
|
|
|
] ++ (lib.optional (userConfigPath != null) userConfigPath);
|
|
|
|
};
|
|
|
|
})
|
2024-05-10 23:22:32 +00:00
|
|
|
(machine.config { inherit pkgs; }).users)
|
2024-05-08 22:59:02 +00:00
|
|
|
machines;
|
|
|
|
});
|
2023-12-01 11:29:39 +00:00
|
|
|
}
|