Merge pull request #67 from nrdxp/flatten-tree

use `flattenTreeSystem` for `packages` output
This commit is contained in:
Timothy DeHerrera 2021-01-03 00:15:42 -07:00 committed by GitHub
commit d0fe508da2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 73 additions and 60 deletions

View File

@ -6,29 +6,32 @@
master.url = "nixpkgs/master";
nixos.url = "nixpkgs/release-20.09";
home.url = "github:nix-community/home-manager/release-20.09";
flake-utils.url = "github:numtide/flake-utils";
flake-utils.url = "github:numtide/flake-utils/flatten-tree-system";
devshell.url = "github:numtide/devshell";
};
outputs = inputs@{ self, home, nixos, master, flake-utils, nur, devshell }:
let
inherit (builtins) attrNames attrValues readDir elem pathExists filter;
inherit (flake-utils.lib) eachDefaultSystem mkApp;
inherit (builtins) attrNames attrValues elem pathExists;
inherit (flake-utils.lib) eachDefaultSystem mkApp flattenTreeSystem;
inherit (nixos) lib;
inherit (lib) all removeSuffix recursiveUpdate genAttrs filterAttrs
mapAttrs;
inherit (lib) recursiveUpdate filterAttrs mapAttrs;
inherit (utils) pathsToImportedAttrs genPkgset overlayPaths modules
genPackages pkgImport;
utils = import ./lib/utils.nix { inherit lib; };
system = "x86_64-linux";
externOverlays = [ nur.overlay devshell.overlay ];
externModules = [ home.nixosModules.home-manager ];
osSystem = "x86_64-linux";
outputs =
let
system = osSystem;
pkgset =
let overlays =
let
overlays =
(attrValues self.overlays)
++ externOverlays
++ [ self.overlay ];
@ -36,11 +39,11 @@
genPkgset {
inherit master nixos overlays system;
};
outputs = {
in
{
nixosConfigurations =
import ./hosts (recursiveUpdate inputs {
inherit lib pkgset system utils externModules;
inherit lib pkgset utils externModules system;
});
overlay = import ./pkgs;
@ -57,49 +60,48 @@
};
in
(eachDefaultSystem
(system':
(system:
let
pkgs' = pkgImport {
pkgs = pkgImport {
inherit system;
pkgs = master;
system = system';
overlays = [ devshell.overlay ];
};
packages' = genPackages {
overlay = self.overlay;
overlays = self.overlays;
pkgs = pkgs';
};
packages = filterAttrs
(_: drv: drv.meta.broken != true)
(flattenTreeSystem system
(genPackages {
inherit self pkgs;
})
);
filtered = filterAttrs
(_: v:
(v.meta ? platforms)
&& (elem system' v.meta.platforms)
&& (
(all (dev: dev.meta ? platforms) v.buildInputs)
&& (all (dev: elem system' dev.meta.platforms) v.buildInputs)
))
packages';
in
{
inherit packages;
devShell = import ./shell.nix {
pkgs = pkgs';
inherit pkgs;
};
apps =
let
validApps = attrNames (filterAttrs (_: drv: pathExists "${drv}/bin")
self.packages."${system}");
validApps = attrNames (filterAttrs
(_: drv:
drv.meta.broken != true
&& pathExists "${drv}/bin"
)
self.packages."${osSystem}"
);
validSystems = attrNames filtered;
validSystems = attrNames packages;
filterBins = filterAttrs
(n: _: elem n validSystems && elem n validApps)
filtered;
packages;
in
mapAttrs (_: drv: mkApp { inherit drv; }) filterBins;
packages =
filtered;
})) // outputs;
}

View File

@ -82,8 +82,9 @@ in
(recursiveUpdate cachixAttrs modulesAttrs)
profilesAttrs;
genPackages = { overlay, overlays, pkgs }:
genPackages = { self, pkgs }:
let
inherit (self) overlay overlays;
packages = overlay pkgs pkgs;
overlayPkgs =
genAttrs

View File

@ -1,11 +1,11 @@
final: prev: {
# with sway/wayland support
redshift = prev.redshift.overrideAttrs (o: {
redshift = (prev.redshift.overrideAttrs (o: {
src = prev.fetchFromGitHub {
owner = "minus7";
repo = "redshift";
rev = "wayland";
hash = "sha256-pyR7xNdi/83NSoC2WIrX8U+A6nU+vZBlePLXrQZnc1k=";
};
});
})).override { withAppIndicator = prev.stdenv.isLinux; };
}

View File

@ -10,5 +10,14 @@ final: prev: {
hash = "sha256-dzPOuT+v1JtYzvAtqZ/eVWQSYQLAWX3TyS3jXdBmDdg=";
rev = "v${version}";
};
# fix darwin builds
nativeBuildInputs =
if ! prev.stdenv.isLinux then
prev.lib.filter
(drv: ! prev.lib.hasPrefix "wayland" drv.name)
o.nativeBuildInputs
else
o.nativeBuildInputs;
});
}

View File

@ -99,5 +99,6 @@ stdenv.mkDerivation rec {
license = licenses.mit;
maintainers = with maintainers; [ nrdxp ];
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
broken = true;
};
}