packages: apply overlays to output packages

Apply overlays to output packages so we can easily use a modified
package.
This commit is contained in:
Timothy DeHerrera 2021-01-18 02:23:49 -07:00
parent 4248b2d1a5
commit f8f67d2dcb
No known key found for this signature in database
GPG Key ID: 8985725DB5B0C122
3 changed files with 36 additions and 52 deletions

View File

@ -26,26 +26,29 @@
externOverlays = [ nur.overlay devshell.overlay ]; externOverlays = [ nur.overlay devshell.overlay ];
externModules = [ home.nixosModules.home-manager ]; externModules = [ home.nixosModules.home-manager ];
pkgs' = unstable:
let
override = import ./pkgs/override.nix;
overlays = (attrValues self.overlays)
++ externOverlays
++ [ self.overlay (override unstable) ];
in
pkgImport nixos overlays;
unstable' = pkgImport master [ ];
osSystem = "x86_64-linux"; osSystem = "x86_64-linux";
outputs = outputs =
let let
system = osSystem; system = osSystem;
pkgset = unstablePkgs = unstable' system;
let osPkgs = pkgs' unstablePkgs system;
overlays =
(attrValues self.overlays)
++ externOverlays
++ [ self.overlay ];
in
genPkgset {
inherit master nixos overlays system;
};
in in
{ {
nixosConfigurations = nixosConfigurations =
import ./hosts (recursiveUpdate inputs { import ./hosts (recursiveUpdate inputs {
inherit lib pkgset utils externModules system; inherit lib osPkgs unstablePkgs utils externModules system;
}); });
overlay = import ./pkgs; overlay = import ./pkgs;
@ -65,11 +68,8 @@
(eachDefaultSystem (eachDefaultSystem
(system: (system:
let let
pkgs = pkgImport { unstablePkgs = unstable' system;
inherit system; pkgs = pkgs' unstablePkgs system;
pkgs = nixos;
overlays = [ devshell.overlay ];
};
packages = flattenTreeSystem system packages = flattenTreeSystem system
(genPackages { (genPackages {

View File

@ -2,9 +2,10 @@
, lib , lib
, nixos , nixos
, master , master
, pkgset , osPkgs
, self , self
, system , system
, unstablePkgs
, utils , utils
, externModules , externModules
, ... , ...
@ -12,7 +13,6 @@
let let
inherit (utils) recImport; inherit (utils) recImport;
inherit (builtins) attrValues removeAttrs; inherit (builtins) attrValues removeAttrs;
inherit (pkgset) osPkgs unstablePkgs;
unstableModules = [ ]; unstableModules = [ ];
addToDisabledModules = [ ]; addToDisabledModules = [ ];
@ -65,14 +65,6 @@ let
system.configurationRevision = lib.mkIf (self ? rev) self.rev; system.configurationRevision = lib.mkIf (self ? rev) self.rev;
}; };
overrides = {
nixpkgs.overlays =
let
override = import ../pkgs/override.nix unstablePkgs;
in
[ override ];
};
local = import "${toString ./.}/${hostName}.nix"; local = import "${toString ./.}/${hostName}.nix";
# Everything in `./modules/list.nix`. # Everything in `./modules/list.nix`.
@ -84,7 +76,6 @@ let
core core
global global
local local
overrides
modOverrides modOverrides
] ++ externModules; ] ++ externModules;

View File

@ -1,8 +1,8 @@
{ lib, ... }: { lib, ... }:
let let
inherit (builtins) attrNames isAttrs readDir listToAttrs; inherit (builtins) attrNames attrValues isAttrs readDir listToAttrs mapAttrs;
inherit (lib) filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix inherit (lib) fold filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix
recursiveUpdate genAttrs; recursiveUpdate genAttrs;
# mapFilterAttrs :: # mapFilterAttrs ::
@ -14,8 +14,8 @@ let
# Generate an attribute set by mapping a function over a list of values. # Generate an attribute set by mapping a function over a list of values.
genAttrs' = values: f: listToAttrs (map f values); genAttrs' = values: f: listToAttrs (map f values);
pkgImport = { pkgs, system, overlays }: pkgImport = nixpkgs: overlays: system:
import pkgs { import nixpkgs {
inherit system overlays; inherit system overlays;
config = { allowUnfree = true; }; config = { allowUnfree = true; };
}; };
@ -33,20 +33,6 @@ in
{ {
inherit mapFilterAttrs genAttrs' pkgImport pathsToImportedAttrs; inherit mapFilterAttrs genAttrs' pkgImport pathsToImportedAttrs;
genPkgset = { master, nixos, overlays, system }:
{
osPkgs = pkgImport {
inherit system overlays;
pkgs = nixos;
};
unstablePkgs = pkgImport {
inherit system;
overlays = [];
pkgs = master;
};
};
overlayPaths = overlayPaths =
let let
overlayDir = ../overlays; overlayDir = ../overlays;
@ -86,12 +72,19 @@ in
genPackages = { self, pkgs }: genPackages = { self, pkgs }:
let let
inherit (self) overlay overlays; inherit (self) overlay overlays;
packages = overlay pkgs pkgs; packagesNames = attrNames (overlay null null)
overlayPkgs = ++ attrNames (fold
genAttrs (attr: sum: recursiveUpdate sum attr)
(attrNames overlays) { }
(name: (overlays."${name}" pkgs pkgs)."${name}"); (attrValues
(mapAttrs (_: v: v null null) overlays)
)
);
in in
recursiveUpdate packages overlayPkgs; fold
(key: sum: recursiveUpdate sum {
${key} = pkgs.${key};
})
{ }
packagesNames;
} }