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 // {
|
2024-05-10 23:33:56 +00:00
|
|
|
config = { callPackage, ... }:
|
|
|
|
((callPackage defaultMachine.config { }) // (callPackage machineDefinition.config { }));
|
2024-05-10 23:22:32 +00:00
|
|
|
})
|
|
|
|
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:
|
2024-05-10 23:28:15 +00:00
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
config = {};
|
2024-05-01 23:08:45 +00:00
|
|
|
|
2024-05-10 23:28:15 +00:00
|
|
|
overlays = [
|
|
|
|
sops-nix.overlays.default
|
2024-05-08 22:50:42 +00:00
|
|
|
];
|
2024-05-10 23:28:15 +00:00
|
|
|
};
|
|
|
|
in {
|
2024-05-16 00:25:41 +00:00
|
|
|
packages = {
|
|
|
|
rcloneDocs =
|
|
|
|
let
|
|
|
|
module = lib.evalModules {
|
|
|
|
modules = [
|
|
|
|
({ pkgs, ... }@args: {
|
|
|
|
inherit (import ./lib/modules/rclone.nix args) options;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
optionsDoc = pkgs.nixosOptionsDoc {
|
|
|
|
options = module.options;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
pkgs.runCommand "options-doc.md" {} ''
|
|
|
|
cat ${optionsDoc.optionsCommonMark} >> $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-10 23:28:15 +00:00
|
|
|
devShells.default = pkgs.mkShellNoCC (
|
|
|
|
with pkgs;
|
|
|
|
{
|
|
|
|
sopsPGPKeyDirs = [
|
|
|
|
"${toString ./.}/keys/hosts"
|
|
|
|
"${toString ./.}/keys/users"
|
|
|
|
];
|
2024-05-01 23:08:45 +00:00
|
|
|
|
2024-05-10 23:28:15 +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-10 23:28:15 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
sops-import-keys-hook
|
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
2024-05-08 22:50:42 +00:00
|
|
|
) // {
|
|
|
|
nixosConfigurations =
|
|
|
|
builtins.mapAttrs (
|
2024-05-11 17:40:01 +00:00
|
|
|
hostname: { system, config }@machine: 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 = [
|
|
|
|
(
|
2024-05-10 23:33:56 +00:00
|
|
|
{ pkgs, ... }: {
|
2024-05-11 18:28:41 +00:00
|
|
|
config = {
|
|
|
|
_module.args = {
|
|
|
|
machine = machine // {
|
|
|
|
name = hostname;
|
|
|
|
config = (pkgs.callPackage config { });
|
|
|
|
};
|
2024-05-11 17:40:01 +00:00
|
|
|
};
|
2024-05-11 18:28:41 +00:00
|
|
|
|
|
|
|
home-manager.sharedModules = [
|
|
|
|
sops-nix.homeManagerModules.sops
|
|
|
|
];
|
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;
|
|
|
|
};
|
2024-05-10 23:33:56 +00:00
|
|
|
|
|
|
|
machineConfig = pkgs.callPackage machine.config { };
|
2024-05-08 22:59:02 +00:00
|
|
|
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-11 19:35:13 +00:00
|
|
|
getUserModule = pkgs.callPackage (import ./lib/utils/user-module.nix);
|
|
|
|
in
|
|
|
|
getUserModule {
|
|
|
|
machine = machine // {
|
|
|
|
name = hostname;
|
|
|
|
config = machineConfig;
|
|
|
|
};
|
|
|
|
|
|
|
|
user = {
|
|
|
|
name = username;
|
|
|
|
} // user;
|
|
|
|
} ++ [
|
|
|
|
sops-nix.homeManagerModules.sops
|
|
|
|
];
|
2024-05-08 22:59:02 +00:00
|
|
|
};
|
|
|
|
})
|
2024-05-10 23:33:56 +00:00
|
|
|
machineConfig.users)
|
2024-05-08 22:59:02 +00:00
|
|
|
machines;
|
|
|
|
});
|
2023-12-01 11:29:39 +00:00
|
|
|
}
|