now using flake-parts; refactored nixosConfigurations; using hm standalone

This commit is contained in:
William 2025-10-14 15:43:12 -03:00
parent 7f64d49052
commit 816496fbab
104 changed files with 1414 additions and 1910 deletions

152
flake.nix
View file

@ -5,6 +5,8 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05";
flake-parts.url = "github:hercules-ci/flake-parts";
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
@ -37,151 +39,19 @@
};
outputs =
inputs@{
self,
nixpkgs,
nixpkgs-stable,
home-manager,
home-manager-stable,
disko,
dms,
agenix,
nixos-cli,
nix-flatpak,
impermanence,
...
}:
let
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
forAllSystemsWithPkgs =
f:
forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
f system pkgs
);
in
{
nixosConfigurations =
let
mkHost =
{
hostname,
type, # workstation|server
system ? "x86_64-linux",
extraModules ? [ ],
}:
let
pkgs = if type == "server" then nixpkgs-stable else nixpkgs;
hm = if type == "server" then home-manager-stable else home-manager;
hostTypeFlags = {
isServer = type == "server";
isWorkstation = type == "workstation";
};
defaultModules = [
./hosts/${hostname}.nix
agenix.nixosModules.default
disko.nixosModules.default
dms.nixosModules.greeter
hm.nixosModules.default
impermanence.nixosModules.impermanence
nix-flatpak.nixosModules.nix-flatpak
nixos-cli.nixosModules.nixos-cli
{
nixpkgs.overlays = [
agenix.overlays.default
];
}
];
workstationModules = [
{
nixpkgs.overlays = [
self.overlays.workstationOverlay
];
}
];
serverModules = [
{
nixpkgs.overlays = [
self.overlays.serverOverlay
];
}
];
typeModules = if type == "server" then serverModules else workstationModules;
allModules = defaultModules ++ typeModules ++ extraModules;
in
pkgs.lib.nixosSystem {
inherit system;
specialArgs = {
inherit inputs;
hostType = hostTypeFlags;
};
modules = allModules;
};
in
{
rotterdam = mkHost {
hostname = "rotterdam";
type = "workstation";
};
io = mkHost {
hostname = "io";
type = "workstation";
};
alexandria = mkHost {
hostname = "alexandria";
type = "server";
extraModules = [
self.nixosModules.qbittorrent
];
};
trantor = mkHost {
hostname = "trantor";
type = "server";
system = "aarch64-linux";
};
};
devShells = forAllSystemsWithPkgs (
system: pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
nil
nixfmt-rfc-style
];
};
}
);
packages = forAllSystemsWithPkgs (
system: pkgs:
{
toggleaudiosink = pkgs.callPackage ./packages/toggleaudiosink.nix { };
}
// nixpkgs.lib.optionalAttrs (system == "x86_64-linux") {
# plasticity = pkgs.callPackage ./packages/plasticity.nix { };
}
);
overlays = {
overlay = final: prev: {
};
workstationOverlay = final: prev: {
# plasticity = self.packages.${final.system}.plasticity;
toggleaudiosink = self.packages.${final.system}.toggleaudiosink;
};
serverOverlay = final: prev: {
};
};
nixosModules = {
qbittorrent = import ./modules/qbittorrent.nix;
};
imports = [
./devShells.nix
./homeConfigurations.nix
./nixosConfigurations.nix
./overlays.nix
./packages.nix
];
};
}