nixos_config/flake.nix

158 lines
4.1 KiB
Nix
Raw Normal View History

2025-07-20 17:46:39 +02:00
{
description = "NixOS configuration for all hosts";
inputs = {
2025-11-30 18:15:29 +01:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
2025-08-08 21:43:53 +02:00
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
2025-09-04 15:05:45 +02:00
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
nur-unstable = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
2025-07-21 20:58:31 +02:00
home-manager = {
2025-11-30 18:15:29 +01:00
url = "github:nix-community/home-manager/release-25.11";
2025-07-21 20:58:31 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
2026-01-07 22:56:05 +01:00
stylix = {
url = "github:danth/stylix";
inputs.nixpkgs.follows = "nixpkgs";
};
2026-02-01 15:53:16 +01:00
nix-minecraft.url = "github:Infinidoge/nix-minecraft";
2025-07-20 17:46:39 +02:00
};
2026-03-10 21:50:51 +01:00
outputs = inputs @ {
self,
nixpkgs,
nixpkgs-unstable,
nur,
nur-unstable,
home-manager,
stylix,
nix-minecraft,
...
}:
2025-07-21 20:58:31 +02:00
let
system = "x86_64-linux";
2026-03-10 21:58:35 +01:00
repoLocalPath =
let
fromEnv = builtins.getEnv "NIXOS_CONFIG_ROOT";
in
if fromEnv != "" then fromEnv else "/home/alisceon/.nixos_config";
2026-03-10 21:50:51 +01:00
2025-07-21 20:58:31 +02:00
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
2025-08-25 16:01:00 +02:00
flake.setFlakeRegistry = true;
2025-09-04 15:05:45 +02:00
overlays = [ nur.overlays.default ];
2025-07-21 20:58:31 +02:00
};
2026-03-10 21:50:51 +01:00
2025-08-08 21:43:53 +02:00
pkgs-unstable = import nixpkgs-unstable {
inherit system;
config.allowUnfree = true;
2025-08-25 16:01:00 +02:00
flake.setFlakeRegistry = true;
2025-09-04 15:05:45 +02:00
overlays = [ nur-unstable.overlays.default ];
2025-08-25 16:01:00 +02:00
};
2026-03-10 21:50:51 +01:00
2025-08-25 16:01:00 +02:00
sharedSpecialArgs = {
2026-03-10 21:58:35 +01:00
inherit pkgs-unstable repoLocalPath;
2026-03-10 21:50:51 +01:00
repoRoot = self;
2025-08-08 21:43:53 +02:00
};
2026-03-10 21:50:51 +01:00
2025-07-23 19:46:19 +02:00
sharedModules = [
2026-03-10 21:50:51 +01:00
./nixos/modules/base.nix
2026-01-07 19:19:47 +01:00
stylix.nixosModules.stylix
2025-08-08 21:43:53 +02:00
home-manager.nixosModules.home-manager
2026-03-10 21:50:51 +01:00
({ ... }: {
2025-08-08 21:43:53 +02:00
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
2026-03-10 21:50:51 +01:00
inherit pkgs pkgs-unstable repoLocalPath;
repoRoot = self;
};
2025-08-08 21:43:53 +02:00
home-manager.backupFileExtension = "backup";
2026-03-10 21:50:51 +01:00
})
];
mkHost = {
hostName,
nixosModules ? [ ],
hmModules ? [ ],
extraModules ? [ ],
}:
nixpkgs.lib.nixosSystem {
inherit system pkgs;
specialArgs = sharedSpecialArgs;
modules =
sharedModules
++ [ (./nixos/hosts + "/${hostName}/configuration.nix") ]
++ nixosModules
++ extraModules
++ [
{
home-manager.users.alisceon.imports =
[ ./home/profiles/base.nix ]
++ hmModules;
home-manager.users.root.imports = [
./home/users/root/default.nix
];
}
];
};
workstationModules = [
./nixos/modules/profiles/workstation.nix
./nixos/modules/wm/sway.nix
./nixos/modules/theme/stylix.nix
];
workstationHomeModules = [
./home/profiles/workstation.nix
./home/modules/wm/sway/default.nix
];
serverModules = [
./nixos/modules/profiles/server.nix
];
2026-03-10 21:58:35 +01:00
serverHomeModules = [ ];
2025-07-21 20:58:31 +02:00
in
{
2025-07-21 19:53:17 +02:00
nixosConfigurations = {
2026-03-10 21:50:51 +01:00
electra = mkHost {
hostName = "electra";
nixosModules = workstationModules;
hmModules = workstationHomeModules ++ [
./home/hosts/alisceon/electra.nix
];
};
tower = mkHost {
hostName = "tower";
nixosModules = workstationModules;
hmModules = workstationHomeModules ++ [
./home/hosts/alisceon/tower.nix
];
};
tesla-nixos = mkHost {
hostName = "tesla-nixos";
nixosModules = serverModules;
hmModules = serverHomeModules;
extraModules = [
2026-02-01 15:53:16 +01:00
nix-minecraft.nixosModules.minecraft-servers
2026-02-01 16:54:28 +01:00
{ nixpkgs.overlays = [ inputs.nix-minecraft.overlay ]; }
2026-03-10 21:50:51 +01:00
];
};
nuc = mkHost {
hostName = "nuc";
nixosModules = serverModules;
hmModules = serverHomeModules;
};
};
};
}