1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-29 11:07:44 +00:00

Start refactor

This commit is contained in:
RGBCube 2025-01-11 15:51:21 +03:00
parent 99b7ccfadb
commit 06cce18e72
155 changed files with 2139 additions and 3738 deletions

160
flake.nix
View file

@ -1,5 +1,5 @@
{
description = "RGBCube's NixOS Configuration Collection";
description = "RGBCube's Configuration Collection";
nixConfig = {
extra-substituters = [
@ -13,46 +13,51 @@
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
experimental-features = [
"cgroups"
"flakes"
"nix-command"
"pipe-operators"
];
accept-flake-config = true;
builders-use-substitutes = true;
flake-registry = "";
http-connections = 50;
show-trace = true;
trusted-users = [ "root" "@wheel" "@admin" ];
use-cgroups = true;
warn-dirty = false;
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs.url = "github:NixOS/nixpkgs";
hardware.url = "github:NixOS/nixos-hardware";
nix-darwin = {
url = "github:LnL7/nix-darwin";
homeManager = {
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
ageNix = {
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "homeManager";
};
simpleMail = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
inputs.nixpkgs.follows = "nixpkgs";
inputs.darwin.follows = "nix-darwin";
inputs.home-manager.follows = "home-manager";
};
fenix.url = "github:nix-community/fenix";
hyprland = {
url = "github:hyprwm/Hyprland";
inputs.nixpkgs.follows = "nixpkgs";
};
# hyprcursors = {
# url = "github:VirtCode/hypr-dynamic-cursors";
# inputs.hyprland.follows = "hyprland";
# inputs.nixpkgs.follows = "hyprland/nixpkgs";
# };
nix.url = "github:NixOS/nix";
nil.url = "github:oxalica/nil";
crash = {
url = "github:RGBCube/crash";
@ -60,98 +65,27 @@
inputs.nixpkgs.follows = "nixpkgs";
};
github2forgejo = {
url = "github:RGBCube/GitHub2Forgejo";
inputs.nixpkgs.follows = "nixpkgs";
};
themes.url = "github:RGBCube/ThemeNix";
};
outputs = { self, nixpkgs, ... } @ inputs: let
lib0 = nixpkgs.lib;
keys = import ./keys.nix;
outputs = inputs @ { nixpkgs, nix-darwin, ... }: let
inherit (builtins) readDir;
inherit (nixpkgs.lib) attrsToList const groupBy listToAttrs mapAttrs;
collectNixFiles = directory: with lib0; pipe (filesystem.listFilesRecursive directory) [
(filter (hasSuffix ".nix"))
(filter (name: !hasPrefix "_" (builtins.baseNameOf name)))
];
lib'' = nixpkgs.lib.extend (_: _: nix-darwin.lib);
lib' = lib''.extend (_: _: builtins);
lib = lib'.extend <| import ./lib inputs;
lib1 = with lib0; extend (const (const (pipe (collectNixFiles ./lib) [
(map (file: import file lib0))
(filter (thunk: !isFunction thunk))
(foldl' recursiveUpdate {})
])));
nixpkgsOverlayModule = with lib1; {
nixpkgs.overlays = [(final: prev: {
# hyprcursors = inputs.hyprcursors.packages.${prev.system}.default;
})] ++ pipe inputs [
attrValues
(filter (value: value ? overlays.default))
(map (value: value.overlays.default))
];
nixpkgs.config.allowUnfree = true; # IDGAF anymore.
};
homeManagerModule = { lib, ... }: with lib; {
home-manager.users = genAttrs allNormalUsers (const {});
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.sharedModules = pipe inputs [
attrValues
(filter (value: value ? homeModules.default))
(map (value: value.homeModules.default))
];
};
optionModules = with lib1; [
(lib1.mkAliasOptionModule [ "secrets" ] [ "age" "secrets" ])
] ++ collectNixFiles ./options ++ pipe inputs [
attrValues
(filter (value: value ? nixosModules.default))
(map (value: value.nixosModules.default))
];
optionUsageModules = [
nixpkgsOverlayModule
homeManagerModule
] ++ collectNixFiles ./modules;
specialArgs = inputs // { inherit inputs keys; };
hosts = lib1.pipe (builtins.readDir ./hosts) [
(lib1.filterAttrs (name: type: type == "regular" -> lib1.hasSuffix ".nix" name))
lib1.attrNames
];
lib2s = with lib1; genAttrs hosts (name: let
hostStub = nixosSystem {
inherit specialArgs;
modules = [ ./hosts/${name} ] ++ optionModules;
};
in extend (const (const (pipe (collectNixFiles ./lib) [
(map (file: import file lib1))
(filter (isFunction))
(map (func: func hostStub.config))
(foldl' recursiveUpdate {})
]))));
configurations = lib1.genAttrs hosts (name: lib2s.${name}.nixosSystem {
inherit specialArgs;
modules = [{
networking.hostName = name;
}] ++ optionModules ++ optionUsageModules ++ collectNixFiles ./hosts/${name};
});
in {
nixosConfigurations = configurations;
# This is here so we can do self.<whatever> instead of self.nixosConfigurations.<whatever>.config.
} // lib1.mapAttrs (lib1.const (value: value.config)) configurations;
hostsByType = readDir ./hosts
|> mapAttrs (name: const <| import ./hosts/${name} lib)
|> attrsToList
|> groupBy ({ name, value }:
if value ? class && value.class == "nixos" then
"nixosConfigurations"
else
"darwinConfigurations")
|> mapAttrs (const listToAttrs);
in hostsByType // {
inherit lib;
};
}