more polish for hm nixos module integration

still, it makes system config eval too slow so i'd like to avoid using
it
This commit is contained in:
chayleaf 2023-05-25 11:34:27 +07:00
parent ac312dec98
commit febfcb416b
3 changed files with 50 additions and 33 deletions

View file

@ -81,31 +81,12 @@
}; };
nixmsi = rec { nixmsi = rec {
system = "x86_64-linux"; system = "x86_64-linux";
nixpkgs.config.allowUnfreePredicate = pkg: (lib.getName pkg) == "steam-original";
modules = [ modules = [
nix-gaming.nixosModules.pipewireLowLatency nix-gaming.nixosModules.pipewireLowLatency
./system/hardware/msi_delta_15.nix ./system/hardware/msi_delta_15.nix
./system/hosts/nixmsi.nix ./system/hosts/nixmsi.nix
]; ];
home.common.pkgs = mkPkgs { home.common.enableNixosModule = false;
inherit system;
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"steam-run"
"steam"
"steam-original"
"steam-runtime"
"steamcmd"
"osu-lazer-bin"
];
binaryCachePublicKeys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
# "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
];
binaryCaches = [
"https://cache.nixos.org"
# "https://nixpkgs-wayland.cachix.org"
];
};
home.common.extraSpecialArgs = { home.common.extraSpecialArgs = {
notlua = notlua.lib.${system}; notlua = notlua.lib.${system};
}; };
@ -125,9 +106,6 @@
nixosConfigurations = builtins.mapAttrs (hostname: args @ { system ? "x86_64-linux", modules, nixpkgs ? {}, home ? {}, ... }: nixosConfigurations = builtins.mapAttrs (hostname: args @ { system ? "x86_64-linux", modules, nixpkgs ? {}, home ? {}, ... }:
lib.nixosSystem ({ lib.nixosSystem ({
inherit system; inherit system;
pkgs = mkPkgs ({
inherit system;
} // nixpkgs);
modules = modules ++ [ modules = modules ++ [
{ networking.hostName = hostname; } { networking.hostName = hostname; }
./system/modules/vfio.nix ./system/modules/vfio.nix
@ -137,6 +115,8 @@
impermanence.nixosModule impermanence.nixosModule
(getPrivSys hostname) (getPrivSys hostname)
{ {
nixpkgs.overlays = [ overlay ];
nix.registry = nix.registry =
builtins.mapAttrs builtins.mapAttrs
(_: v: { flake = v; }) (_: v: { flake = v; })
@ -151,20 +131,27 @@
(lib.filterAttrs (_: v: builtins.pathExists "${v}/default.nix") inputs); (lib.filterAttrs (_: v: builtins.pathExists "${v}/default.nix") inputs);
nix.nixPath = [ "/etc/nix/inputs" ]; nix.nixPath = [ "/etc/nix/inputs" ];
} }
] ++ (lib.optionals (home != {} && (!(home?common) || !(home.common?pkgs))) [ ] ++ (lib.optionals (home != {} && (getOr true "enableNixosModule" (getOr {} "common" home))) [
# only use NixOS HM module if same nixpkgs as system nixpkgs is used for user # only use NixOS HM module if same nixpkgs as system nixpkgs is used for user
# why? because it seems that HM lacks the option to override pkgs, only change nixpkgs.* settings # why? because it seems that HM lacks the option to override pkgs, only change nixpkgs.* settings
home-manager.nixosModules.home-manager home-manager.nixosModules.home-manager
{ {
home-manager = builtins.removeAttrs (getOr { } "common" home) [ "nixpkgs" ]; home-manager = builtins.removeAttrs (getOr { } "common" home) [ "nixpkgs" "nix" "enableNixosModule" ];
} }
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = false;
home-manager.useUserPackages = true; home-manager.useUserPackages = false;
home-manager.users = builtins.mapAttrs (k: v: { home-manager.users = builtins.mapAttrs (username: modules: {
imports = v ++ [ { imports = modules ++ [
{
nixpkgs = getOr { } "nixpkgs" (getOr { } "common" home); nixpkgs = getOr { } "nixpkgs" (getOr { } "common" home);
} ]; nix = getOr { } "nix" (getOr { } "common" home);
}
({ pkgs, ...}: {
nixpkgs.overlays = [ overlay ];
})
(getPrivUser hostname username)
];
}) (builtins.removeAttrs home [ "common" ]); }) (builtins.removeAttrs home [ "common" ]);
} }
]); ]);
@ -182,13 +169,21 @@
(builtins.concatLists (builtins.concatLists
(lib.mapAttrsToList (lib.mapAttrsToList
(hostname: sysConfig: (hostname: sysConfig:
let common = builtins.removeAttrs (getOr { } "common" sysConfig.home) [ "nixpkgs" ]; in let
common = builtins.removeAttrs (getOr { } "common" sysConfig.home) [ "nixpkgs" "enableNixosModule" ];
pkgs = getOr (mkPkgs { system = if sysConfig?system then sysConfig.system else "x86_64-linux"; }) "pkgs" common;
common' = common // { inherit pkgs; };
in
lib.mapAttrsToList lib.mapAttrsToList
# this is where actual config takes place # this is where actual config takes place
(user: homeConfig: { (user: homeConfig: {
"${user}@${hostname}" = home-manager.lib.homeManagerConfiguration (common // { "${user}@${hostname}" = home-manager.lib.homeManagerConfiguration (common' // {
modules = homeConfig ++ [ modules = homeConfig ++ [
(getPrivUser hostname user) (getPrivUser hostname user)
({ pkgs, ... }: {
nixpkgs.overlays = [ overlay ];
nix.package = pkgs.nixFlakes;
})
]; ];
}); });
}) })

View file

@ -8,6 +8,27 @@
../common/helix.nix ../common/helix.nix
../common/kakoune.nix ../common/kakoune.nix
]; ];
nix.settings = {
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
# "nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA="
];
trusted-substituters = [
"https://cache.nixos.org"
# "https://nixpkgs-wayland.cachix.org"
];
};
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"steam-run"
"steam"
"steam-original"
"steam-runtime"
"steamcmd"
"osu-lazer-bin"
];
home.stateVersion = "22.11"; home.stateVersion = "22.11";
home.username = "user"; home.username = "user";
home.homeDirectory = "/home/user"; home.homeDirectory = "/home/user";

View file

@ -93,6 +93,7 @@ in {
# zen619.configuration.boot.kernelPackages = zenKernelPackages "6.1.9" "0fsmcjsawxr32fxhpp6sgwfwwj8kqymy0rc6vh4qli42fqmwdjgv"; # zen619.configuration.boot.kernelPackages = zenKernelPackages "6.1.9" "0fsmcjsawxr32fxhpp6sgwfwwj8kqymy0rc6vh4qli42fqmwdjgv";
# }; # };
nixpkgs.config.allowUnfreePredicate = pkg: (lib.getName pkg) == "steam-original";
hardware = { hardware = {
steam-hardware.enable = true; steam-hardware.enable = true;
opengl.driSupport32Bit = true; opengl.driSupport32Bit = true;