nix-cfg/flake.nix

114 lines
3.3 KiB
Nix
Raw Normal View History

2023-09-09 16:31:01 +02:00
{
description = "Lgm's NixOS Flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
2024-05-16 15:43:14 +02:00
flake-parts.url = "github:hercules-ci/flake-parts";
flake-compat.url = "github:edolstra/flake-compat";
systems.url = "github:nix-systems/default";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
2023-09-09 16:31:01 +02:00
home-manager = {
2023-10-30 17:20:54 +01:00
url = "github:nix-community/home-manager/master";
2023-09-09 16:31:01 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
2024-01-21 19:53:13 +01:00
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs-stable";
};
mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver/master";
inputs.flake-compat.follows = "flake-compat";
inputs.nixpkgs.follows = "nixpkgs";
};
2024-05-16 15:43:14 +02:00
authentik-nix = {
url = "github:nix-community/authentik-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
nix-cfg-extra.url = "git+https://git.lgmrszd.xyz/lgmrszd/nix-cfg-extra-public.git";
2023-09-09 16:31:01 +02:00
};
outputs = inputs@{
nixpkgs,
nixpkgs-stable,
home-manager,
2024-01-21 19:53:13 +01:00
sops-nix,
mailserver,
2024-05-16 15:43:14 +02:00
authentik-nix,
2023-09-09 16:31:01 +02:00
...
}:
let
system = "x86_64-linux";
2024-05-30 19:33:20 +02:00
# overlay-stable = final: prev: {
# stable = import nixpkgs-stable {
2024-05-20 23:23:04 +02:00
# inherit system;
# config.allowUnfree = true;
# };
# };
2023-12-11 17:47:25 +01:00
overlay-vaapiIntel = final: prev: {
vaapiIntel = prev.vaapiIntel.override { enableHybridCodec = true; };
};
my-overlays = [
2024-05-20 23:23:04 +02:00
# overlay-stable
2023-12-11 17:47:25 +01:00
overlay-vaapiIntel
];
inherit (inputs.nix-cfg-extra.lib) extra-data;
inherit (inputs.nix-cfg-extra.lib) extra-host-modules;
inherit (inputs.nix-cfg-extra.lib) extra-host-home-modules;
2024-05-30 19:33:20 +02:00
mkHostConfig = ({ host, extraModules ? [], useHome ? false }:
2024-05-30 19:33:20 +02:00
let
# TODO: rename some of those
data = import ./hosts/${host}/data // (if extra-data ? ${host} then extra-data.${host} else {});
extra-modules = (if extra-host-modules ? ${host} then extra-host-modules.${host} else []);
extra-home-modules = (if extra-host-home-modules ? ${host} then extra-host-home-modules.${host} else []);
2024-05-30 19:33:20 +02:00
in
nixpkgs.lib.nixosSystem {
inherit system;
2024-05-30 19:33:20 +02:00
specialArgs = { inherit data; };
2023-09-09 16:31:01 +02:00
modules = [
2024-05-30 19:33:20 +02:00
{ nixpkgs.overlays = my-overlays; }
./hosts/${host}/configuration.nix
./hosts/${host}/hardware-configuration.nix
2024-01-21 19:53:13 +01:00
sops-nix.nixosModules.sops
]
++ extra-modules
++ extraModules
++ (if !useHome then [] else [
2023-09-09 16:31:01 +02:00
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.lgm = {
imports = [
2024-05-31 15:08:30 +02:00
./hosts/${host}/home
] ++ extra-home-modules;
};
2023-09-09 16:31:01 +02:00
}
])
;
});
in
{
nixosConfigurations.lgm-nixos = mkHostConfig {
host = "laptop";
useHome = true;
2023-09-09 16:31:01 +02:00
};
2024-05-30 19:33:20 +02:00
nixosConfigurations.lgm-vps1 = mkHostConfig {
host = "vps1";
extraModules = [
mailserver.nixosModule
2024-05-16 15:43:14 +02:00
authentik-nix.nixosModules.default
];
};
2023-09-09 16:31:01 +02:00
};
}