From 4c06bbd772c6f81a5a58300517e659355ea4d2b2 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Wed, 6 Nov 2024 16:27:40 +0100 Subject: [PATCH] treewide: add mkSystem function for hosts and inject custom lib through _module.args --- flake.nix | 5 ++++- hosts/default.nix | 20 +++++++------------- lib/default.nix | 26 ++++++++++++++++++++++---- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index 028b60f..59f9f73 100644 --- a/flake.nix +++ b/flake.nix @@ -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;}; }; diff --git a/hosts/default.nix b/hosts/default.nix index 6433749..a788fdc 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -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 ]; diff --git a/lib/default.nix b/lib/default.nix index 09d44fd..3b78a1c 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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; }