Rewrite some flake functions

This commit is contained in:
NullBite 2024-01-15 10:43:05 +01:00
parent f15cfcf16b
commit f05904f953
Signed by: nullbite
GPG Key ID: 6C4D545385D4925A

View File

@ -21,7 +21,6 @@
let let
inherit (self) outputs; inherit (self) outputs;
# inputs is already defined # inputs is already defined
lib = nixpkgs.lib; lib = nixpkgs.lib;
systems = [ "x86_64-linux" "aarch64-linux" ]; systems = [ "x86_64-linux" "aarch64-linux" ];
@ -31,15 +30,22 @@
# My current timezone for any mobile devices (i.e., my laptop) # My current timezone for any mobile devices (i.e., my laptop)
mobileTimeZone = "Europe/Amsterdam"; mobileTimeZone = "Europe/Amsterdam";
# define extra packages here
mkExtraPkgs = system: {
# android-tools = inputs.pkg-android-tools.legacyPackages.${system}.android-tools;
inherit (inputs.pkg-android-tools.legacyPackages.${system}) android-tools;
};
# Variables to be passed to NixOS modules in the vars attrset # Variables to be passed to NixOS modules in the vars attrset
vars = { vars = {
inherit username mobileTimeZone; inherit username mobileTimeZone;
}; };
# This function produces a module that adds the home-manager module to the # This function produces a module that adds the home-manager module to the
# system and configures the given module to the user's Home Manager # system and configures the given module to the user's Home Manager
# configuration # configuration
homeManagerInit = user: module: { config, lib, pkgs, ... }: { homeManagerInit = {system, username ? username , module}: { config, lib, pkgs, ... }: {
imports = [ imports = [
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
]; ];
@ -47,26 +53,29 @@
home-manager = { home-manager = {
useGlobalPkgs = true; useGlobalPkgs = true;
useUserPackages = true; useUserPackages = true;
users.${user} = module; users.${username} = module;
}; extraSpecialArgs = {
}; inherit inputs outputs vars;
mkExtraPkgs = system: {
android-tools = inputs.pkg-android-tools.legacyPackages.${system}.android-tools;
};
mkSystem = system: hostname:
let
extraPkgs = mkExtraPkgs system; extraPkgs = mkExtraPkgs system;
in };
};
};
# This function produces a nixosSystem which imports configuration.nix and
# a Home Manager home.nix for the given user from ./hosts/${hostname}/
mkSystem = {system, hostname, username ? username}:
lib.nixosSystem { lib.nixosSystem {
inherit system; inherit system;
modules = [ modules = [
./hosts/${hostname}/configuration.nix ./hosts/${hostname}/configuration.nix
(homeManagerInit username (import ./hosts/${hostname}/home.nix)) (homeManagerInit {
module = import ./hosts/${hostname}/home.nix;
inherit username system;
})
]; ];
specialArgs = { specialArgs = {
inherit inputs outputs vars extraPkgs; inherit inputs outputs vars;
extraPkgs = mkExtraPkgs system;
}; };
}; };
@ -88,7 +97,7 @@
./system/fragments/opengl.nix ./system/fragments/opengl.nix
./system/gaming.nix ./system/gaming.nix
# ./system/hyprland.nix # ./system/hyprland.nix
(homeManagerInit username (import ./hosts/slab/home.nix)) (homeManagerInit {module = import ./hosts/slab/home.nix;})
]; ];
}; };
nullbox = lib.nixosSystem { nullbox = lib.nixosSystem {
@ -99,7 +108,7 @@
./system/plasma.nix ./system/plasma.nix
./system/fragments/hardware/nvidia-modeset.nix ./system/fragments/hardware/nvidia-modeset.nix
./system/gaming.nix ./system/gaming.nix
(homeManagerInit username (import ./hosts/nullbox/home.nix)) (homeManagerInit {module = import ./hosts/nullbox/home.nix;})
]; ];
}; };
}; };