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); formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
nixosModules = import ./modules; 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); packages = eachSystem (pkgs: import ./pkgs pkgs);
deploy.nodes = import ./nodes {inherit self inputs;}; deploy.nodes = import ./nodes {inherit self inputs;};
}; };

View file

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

View file

@ -1,8 +1,9 @@
{ {
pkgs, inputs,
lib, lib',
... ...
}: let }: let
inherit (inputs.nixpkgs) lib;
# convert rrggbb hex to rgba(r, g, b, a) # convert rrggbb hex to rgba(r, g, b, a)
rgba = c: let rgba = c: let
r = toString (hexToDec (builtins.substring 0 2 c)); r = toString (hexToDec (builtins.substring 0 2 c));
@ -86,8 +87,25 @@
]; ];
# Create a KDE konsole color scheme from base16 colors # Create a KDE konsole color scheme from base16 colors
mkKonsoleColorScheme = scheme: mkKonsoleColorScheme = pkgs: scheme:
pkgs.writeText "${scheme.name}.colorscheme" (schemeToKonsole scheme); pkgs.writeText "${scheme.name}.colorscheme" (schemeToKonsole scheme);
in {
inherit mkKonsoleColorScheme rgba; # 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 mkSystem;
} }