This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

5pkgs: move autoimport to flake-module, support package.nix

- Extract package autoimport logic into 5pkgs/flake-module.nix
- Support both package.nix (preferred) and default.nix
- Show deprecation warning when using default.nix

+25 -3
+2 -3
flake.nix
··· 127 127 imports = 128 128 [ 129 129 ./formatter.nix 130 + ./5pkgs/flake-module.nix 130 131 ] 131 132 ++ ( 132 133 # Auto-import all flake-module.nix files from tools subdirectories ··· 148 149 ... 149 150 }: 150 151 { 151 - packages = 152 - (lib.mapAttrs (name: _v_: pkgs.callPackage ./5pkgs/${name} { }) (builtins.readDir ./5pkgs)) 153 - // { 152 + packages = { 154 153 default = inputs.le_menu.lib.buildMenu { 155 154 inherit pkgs; 156 155 menuConfig = {
+23
5pkgs/flake-module.nix
··· 1 + { ... }: 2 + { 3 + perSystem = 4 + { lib, pkgs, ... }: 5 + { 6 + packages = lib.mapAttrs ( 7 + name: _: 8 + let 9 + pkgDir = ./. + "/${name}"; 10 + hasPackageNix = builtins.pathExists (pkgDir + "/package.nix"); 11 + hasDefaultNix = builtins.pathExists (pkgDir + "/default.nix"); 12 + in 13 + if hasPackageNix then 14 + pkgs.callPackage (pkgDir + "/package.nix") { } 15 + else if hasDefaultNix then 16 + builtins.trace "Warning: ${name} is using deprecated default.nix, please rename to package.nix" ( 17 + pkgs.callPackage pkgDir { } 18 + ) 19 + else 20 + throw "Package ${name} has neither package.nix nor default.nix" 21 + ) (lib.filterAttrs (_n: v: v == "directory") (builtins.readDir ./.)); 22 + }; 23 + }