Merge pull request #67 from nrdxp/flatten-tree
use `flattenTreeSystem` for `packages` output
This commit is contained in:
commit
d0fe508da2
116
flake.nix
116
flake.nix
|
@ -6,100 +6,102 @@
|
||||||
master.url = "nixpkgs/master";
|
master.url = "nixpkgs/master";
|
||||||
nixos.url = "nixpkgs/release-20.09";
|
nixos.url = "nixpkgs/release-20.09";
|
||||||
home.url = "github:nix-community/home-manager/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";
|
devshell.url = "github:numtide/devshell";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ self, home, nixos, master, flake-utils, nur, devshell }:
|
outputs = inputs@{ self, home, nixos, master, flake-utils, nur, devshell }:
|
||||||
let
|
let
|
||||||
inherit (builtins) attrNames attrValues readDir elem pathExists filter;
|
inherit (builtins) attrNames attrValues elem pathExists;
|
||||||
inherit (flake-utils.lib) eachDefaultSystem mkApp;
|
inherit (flake-utils.lib) eachDefaultSystem mkApp flattenTreeSystem;
|
||||||
inherit (nixos) lib;
|
inherit (nixos) lib;
|
||||||
inherit (lib) all removeSuffix recursiveUpdate genAttrs filterAttrs
|
inherit (lib) recursiveUpdate filterAttrs mapAttrs;
|
||||||
mapAttrs;
|
|
||||||
inherit (utils) pathsToImportedAttrs genPkgset overlayPaths modules
|
inherit (utils) pathsToImportedAttrs genPkgset overlayPaths modules
|
||||||
genPackages pkgImport;
|
genPackages pkgImport;
|
||||||
|
|
||||||
utils = import ./lib/utils.nix { inherit lib; };
|
utils = import ./lib/utils.nix { inherit lib; };
|
||||||
|
|
||||||
system = "x86_64-linux";
|
|
||||||
|
|
||||||
externOverlays = [ nur.overlay devshell.overlay ];
|
externOverlays = [ nur.overlay devshell.overlay ];
|
||||||
externModules = [ home.nixosModules.home-manager ];
|
externModules = [ home.nixosModules.home-manager ];
|
||||||
|
|
||||||
pkgset =
|
osSystem = "x86_64-linux";
|
||||||
let overlays =
|
|
||||||
(attrValues self.overlays)
|
outputs =
|
||||||
++ externOverlays
|
let
|
||||||
++ [ self.overlay ];
|
system = osSystem;
|
||||||
|
pkgset =
|
||||||
|
let
|
||||||
|
overlays =
|
||||||
|
(attrValues self.overlays)
|
||||||
|
++ externOverlays
|
||||||
|
++ [ self.overlay ];
|
||||||
|
in
|
||||||
|
genPkgset {
|
||||||
|
inherit master nixos overlays system;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
genPkgset {
|
{
|
||||||
inherit master nixos overlays system;
|
nixosConfigurations =
|
||||||
|
import ./hosts (recursiveUpdate inputs {
|
||||||
|
inherit lib pkgset utils externModules system;
|
||||||
|
});
|
||||||
|
|
||||||
|
overlay = import ./pkgs;
|
||||||
|
|
||||||
|
overlays = pathsToImportedAttrs overlayPaths;
|
||||||
|
|
||||||
|
nixosModules = modules;
|
||||||
|
|
||||||
|
templates.flk.path = ./.;
|
||||||
|
|
||||||
|
templates.flk.description = "flk template";
|
||||||
|
|
||||||
|
defaultTemplate = self.templates.flk;
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
|
||||||
nixosConfigurations =
|
|
||||||
import ./hosts (recursiveUpdate inputs {
|
|
||||||
inherit lib pkgset system utils externModules;
|
|
||||||
});
|
|
||||||
|
|
||||||
overlay = import ./pkgs;
|
|
||||||
|
|
||||||
overlays = pathsToImportedAttrs overlayPaths;
|
|
||||||
|
|
||||||
nixosModules = modules;
|
|
||||||
|
|
||||||
templates.flk.path = ./.;
|
|
||||||
|
|
||||||
templates.flk.description = "flk template";
|
|
||||||
|
|
||||||
defaultTemplate = self.templates.flk;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
(eachDefaultSystem
|
(eachDefaultSystem
|
||||||
(system':
|
(system:
|
||||||
let
|
let
|
||||||
pkgs' = pkgImport {
|
pkgs = pkgImport {
|
||||||
|
inherit system;
|
||||||
pkgs = master;
|
pkgs = master;
|
||||||
system = system';
|
|
||||||
overlays = [ devshell.overlay ];
|
overlays = [ devshell.overlay ];
|
||||||
};
|
};
|
||||||
|
|
||||||
packages' = genPackages {
|
packages = filterAttrs
|
||||||
overlay = self.overlay;
|
(_: drv: drv.meta.broken != true)
|
||||||
overlays = self.overlays;
|
(flattenTreeSystem system
|
||||||
pkgs = pkgs';
|
(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
|
in
|
||||||
{
|
{
|
||||||
|
inherit packages;
|
||||||
|
|
||||||
devShell = import ./shell.nix {
|
devShell = import ./shell.nix {
|
||||||
pkgs = pkgs';
|
inherit pkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
apps =
|
apps =
|
||||||
let
|
let
|
||||||
validApps = attrNames (filterAttrs (_: drv: pathExists "${drv}/bin")
|
validApps = attrNames (filterAttrs
|
||||||
self.packages."${system}");
|
(_: drv:
|
||||||
|
drv.meta.broken != true
|
||||||
|
&& pathExists "${drv}/bin"
|
||||||
|
)
|
||||||
|
self.packages."${osSystem}"
|
||||||
|
);
|
||||||
|
|
||||||
validSystems = attrNames filtered;
|
validSystems = attrNames packages;
|
||||||
|
|
||||||
filterBins = filterAttrs
|
filterBins = filterAttrs
|
||||||
(n: _: elem n validSystems && elem n validApps)
|
(n: _: elem n validSystems && elem n validApps)
|
||||||
filtered;
|
packages;
|
||||||
in
|
in
|
||||||
mapAttrs (_: drv: mkApp { inherit drv; }) filterBins;
|
mapAttrs (_: drv: mkApp { inherit drv; }) filterBins;
|
||||||
|
|
||||||
packages =
|
|
||||||
filtered;
|
|
||||||
})) // outputs;
|
})) // outputs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,9 @@ in
|
||||||
(recursiveUpdate cachixAttrs modulesAttrs)
|
(recursiveUpdate cachixAttrs modulesAttrs)
|
||||||
profilesAttrs;
|
profilesAttrs;
|
||||||
|
|
||||||
genPackages = { overlay, overlays, pkgs }:
|
genPackages = { self, pkgs }:
|
||||||
let
|
let
|
||||||
|
inherit (self) overlay overlays;
|
||||||
packages = overlay pkgs pkgs;
|
packages = overlay pkgs pkgs;
|
||||||
overlayPkgs =
|
overlayPkgs =
|
||||||
genAttrs
|
genAttrs
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
final: prev: {
|
final: prev: {
|
||||||
# with sway/wayland support
|
# with sway/wayland support
|
||||||
redshift = prev.redshift.overrideAttrs (o: {
|
redshift = (prev.redshift.overrideAttrs (o: {
|
||||||
src = prev.fetchFromGitHub {
|
src = prev.fetchFromGitHub {
|
||||||
owner = "minus7";
|
owner = "minus7";
|
||||||
repo = "redshift";
|
repo = "redshift";
|
||||||
rev = "wayland";
|
rev = "wayland";
|
||||||
hash = "sha256-pyR7xNdi/83NSoC2WIrX8U+A6nU+vZBlePLXrQZnc1k=";
|
hash = "sha256-pyR7xNdi/83NSoC2WIrX8U+A6nU+vZBlePLXrQZnc1k=";
|
||||||
};
|
};
|
||||||
});
|
})).override { withAppIndicator = prev.stdenv.isLinux; };
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,14 @@ final: prev: {
|
||||||
hash = "sha256-dzPOuT+v1JtYzvAtqZ/eVWQSYQLAWX3TyS3jXdBmDdg=";
|
hash = "sha256-dzPOuT+v1JtYzvAtqZ/eVWQSYQLAWX3TyS3jXdBmDdg=";
|
||||||
rev = "v${version}";
|
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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,5 +99,6 @@ stdenv.mkDerivation rec {
|
||||||
license = licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = with maintainers; [ nrdxp ];
|
maintainers = with maintainers; [ nrdxp ];
|
||||||
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
|
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
|
||||||
|
broken = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue