summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorSeth Flynn <[email protected]>2025-01-28 07:23:40 -0500
committerSeth Flynn <[email protected]>2025-01-28 07:58:44 -0500
commit943dc8b295ca1a333c15a5c0fe5bd90cb5a980af (patch)
treea23ac93782732e4d239c2aa9c5b1539717e463cc /flake.nix
parent988962c3fda908905892ebd452f1b85680ed2b99 (diff)
treewide: simplify package calling logic
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix68
1 files changed, 23 insertions, 45 deletions
diff --git a/flake.nix b/flake.nix
index 7bb62bd..7ca0e0c 100644
--- a/flake.nix
+++ b/flake.nix
@@ -9,38 +9,21 @@
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs =
- {
- self,
- nixpkgs,
- }:
+ { self, nixpkgs }:
+
let
inherit (nixpkgs) lib;
# Support all systems exported by Nixpkgs
systems = lib.systems.flakeExposed;
# But separate our primarily supported systems
- tier1Systems = with lib.platforms; lib.intersectLists (aarch64 ++ aarch64) (darwin ++ linux);
+ tier1Systems = with lib.platforms; lib.intersectLists (aarch64 ++ x86_64) (darwin ++ linux);
forAllSystems = lib.genAttrs systems;
forTier1Systems = lib.genAttrs tier1Systems;
nixpkgsFor = nixpkgs.legacyPackages;
-
- mkModule =
- {
- name,
- type,
- imports,
- ...
- }@args:
- {
- _file = "${self.outPath}/flake.nix#${type}Modules.${name}";
- inherit imports;
- }
- // lib.removeAttrs args [
- "name"
- "type"
- ];
in
+
{
checks = forTier1Systems (
system:
@@ -60,39 +43,34 @@
packages = forAllSystems (
system:
+
let
pkgs = nixpkgsFor.${system};
- isAvailable = lib.meta.availableOn { inherit system; };
- pkgs' = lib.filterAttrs (lib.const isAvailable) (import ./default.nix { inherit pkgs; });
+ getchpkgs = import ./default.nix { inherit pkgs; };
+
+ getchpkgs' = lib.filterAttrs (lib.const (
+ deriv:
+ let
+ isCross = deriv.stdenv.buildPlatform != deriv.stdenv.hostPlatform;
+ availableOnHost = lib.meta.availableOn pkgs.stdenv.hostPlatform deriv;
+ # `nix flake check` doesn't like broken packages
+ isBroken = deriv.meta.broken or false;
+ in
+ isCross || availableOnHost && (!isBroken)
+ )) getchpkgs;
in
- pkgs' // { default = pkgs'.treefetch or pkgs.emptyFile; }
+
+ getchpkgs' // { default = getchpkgs'.treefetch or pkgs.emptyFile; }
);
flakeModules = {
- checks = mkModule {
- name = "checks";
- type = "flake";
- imports = [ ./modules/flake/checks.nix ];
- key = "${self.outPath}/flake.nix#flakeModules.checks";
- _class = "flake";
- };
-
- configs = mkModule {
- name = "configs";
- type = "flake";
- imports = [ ./modules/flake/configs.nix ];
- key = "${self.outPath}/flake.nix#flakeModules.configs";
- _class = "flake";
- };
+ checks = self + "./modules/flake/checks.nix";
+ configs = self + "./modules/flake/configs.nix";
};
homeModules = {
- riff = mkModule {
- name = "riff";
- type = "home";
- imports = [ ./modules/home/riff.nix ];
- };
+ riff = self + "/modules/home/riff.nix";
};
formatter = forTier1Systems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
@@ -100,7 +78,7 @@
templates =
let
toTemplate = name: description: {
- path = ./templates + "/${name}";
+ path = self + "/templates/${name}";
inherit description;
};
in