treewide: add mkSystem function for hosts and inject custom lib through _module.args

This commit is contained in:
Anthony Rodriguez 2024-11-06 16:27:40 +01:00
parent a9b8cc60e0
commit 4c06bbd772
Signed by: nezia
GPG key ID: EE3BE97C040A86CE
3 changed files with 33 additions and 18 deletions

View file

@ -25,7 +25,10 @@
});
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
nixosModules = import ./modules;
nixosConfigurations = import ./hosts {inherit self inputs;};
nixosConfigurations = let
lib' = import ./lib {inherit inputs lib';};
in
import ./hosts {inherit inputs lib';};
packages = eachSystem (pkgs: import ./pkgs pkgs);
deploy.nodes = import ./nodes {inherit self inputs;};
};

View file

@ -1,37 +1,31 @@
{
self,
inputs,
lib',
...
}: let
inherit (inputs.nixpkgs.lib) nixosSystem;
specialArgs = {
inherit inputs self;
};
inherit (lib') mkSystem;
in {
vamos = nixosSystem {
vamos = mkSystem {
system = "x86_64-linux";
inherit specialArgs;
modules = [
./vamos
self.nixosModules.theme
inputs.self.nixosModules.theme
inputs.nixos-hardware.nixosModules.framework-13-7040-amd
];
};
solaire = nixosSystem {
solaire = mkSystem {
system = "x86_64-linux";
inherit specialArgs;
modules = [
./solaire
self.nixosModules.theme
inputs.self.nixosModules.theme
];
};
anastacia = nixosSystem {
anastacia = mkSystem {
system = "x86_64-linux";
inherit specialArgs;
modules = [
./anastacia
];

View file

@ -1,8 +1,9 @@
{
pkgs,
lib,
inputs,
lib',
...
}: let
inherit (inputs.nixpkgs) lib;
# convert rrggbb hex to rgba(r, g, b, a)
rgba = c: let
r = toString (hexToDec (builtins.substring 0 2 c));
@ -86,8 +87,25 @@
];
# Create a KDE konsole color scheme from base16 colors
mkKonsoleColorScheme = scheme:
mkKonsoleColorScheme = pkgs: scheme:
pkgs.writeText "${scheme.name}.colorscheme" (schemeToKonsole scheme);
# https://github.com/diniamo/niqs/blob/caf396bb470619fa06936a379eec6e283c3c3d95/lib/default.nix#L13-L35C7
mkSystem = {system, ...} @ args:
lib.nixosSystem {
system = null;
specialArgs = {inherit inputs;};
modules =
[
{
_module.args = {
inherit system lib';
};
nixpkgs = {inherit system;};
}
]
++ args.modules or [];
};
in {
inherit mkKonsoleColorScheme rgba;
inherit mkKonsoleColorScheme rgba mkSystem;
}