Skip to content

Commit

Permalink
treewide: reduce number of evaluations by re-using pkgs
Browse files Browse the repository at this point in the history
This means:
- For home-manager standalone, we will re-use the
  `self.outputs.legacyPackages`
- For NixOS, we will still eval its own pkgs, but we will pass
  `useGlobalPkgs` option to Home-Manager
  • Loading branch information
thiagokokada committed Jan 1, 2024
1 parent 663b4f9 commit a11ab72
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
4 changes: 1 addition & 3 deletions home-manager/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, lib, flake, osConfig, ... }:
{ pkgs, lib, osConfig, ... }:

{
imports = [
Expand All @@ -15,8 +15,6 @@
# Inherit config from NixOS or homeConfigurations
inherit (osConfig) device mainUser;

nixpkgs.overlays = [ (import ../overlays { inherit flake; }) ];

# Assume that this is a non-NixOS system
targets.genericLinux.enable = lib.mkIf pkgs.stdenv.isLinux (lib.mkDefault true);
}
6 changes: 2 additions & 4 deletions home-manager/meta/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
];
};

# Set custom nixpkgs config (e.g.: allowUnfree), both for this
# config and for ad-hoc nix commands invocation
nixpkgs.config = import ./nixpkgs-config.nix;
# Config for ad-hoc nix commands invocation
xdg.configFile."nixpkgs/config.nix".source = ./nixpkgs-config.nix;

programs = {
# Let Home Manager install and manage itself.
# Let Home Manager install and manage itself
home-manager.enable = true;
# Without git we may be unable to build this config
git.enable = true;
Expand Down
6 changes: 3 additions & 3 deletions lib/flake-helpers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ in
mkGHActionsYAMLs = names: eachDefaultSystem (system:
let
inherit (nixpkgs) lib;
pkgs = nixpkgs.legacyPackages.${system};
pkgs = self.outputs.legacyPackages.${system};
mkGHActionsYAML = name:
let
file = import (../actions/${name}.nix);
Expand Down Expand Up @@ -38,7 +38,7 @@ in
, deps ? pkgs: [ ]
}: eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
pkgs = self.outputs.legacyPackages.${system};
in
{
apps.${name} = mkApp {
Expand Down Expand Up @@ -102,7 +102,7 @@ in
}:
{
homeConfigurations.${hostname} = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
pkgs = self.outputs.legacyPackages.${system};
modules = [
({ ... }: {
home = { inherit username homeDirectory; };
Expand Down
1 change: 1 addition & 0 deletions nixos/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ in

home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
users.${config.mainUser.username} = {
inherit (config.nixos.home) imports;
};
Expand Down

0 comments on commit a11ab72

Please sign in to comment.