default: add unit packages (#26)
This commit is contained in:
		
							
								
								
									
										10
									
								
								callUnitRoot.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								callUnitRoot.nix
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | { pkgs, lib ? pkgs.lib, unitDir ? "unit", packageFun ? "package.nix", root ? "${./pkgs}/${unitDir}" }: | ||||||
|  | let | ||||||
|  |   shards = lib.attrNames (builtins.readDir root); | ||||||
|  |   namesForShard = shard: lib.mapAttrs' | ||||||
|  |     (name: _: { inherit name; value = "${root}/${shard}/${name}"; }) | ||||||
|  |     (builtins.readDir "${root}/${shard}"); | ||||||
|  |   namesToPath = lib.foldl' lib.recursiveUpdate { } (map namesForShard shards); | ||||||
|  |   units = lib.mapAttrs (_: path: pkgs.callPackage "${path}/${packageFun}" { }) namesToPath; | ||||||
|  | in | ||||||
|  | units | ||||||
| @@ -9,9 +9,9 @@ | |||||||
| { pkgs ? import <nixpkgs> { } }: | { pkgs ? import <nixpkgs> { } }: | ||||||
|  |  | ||||||
| import ./pkgs/top-level/all-packages.nix { inherit pkgs; } | import ./pkgs/top-level/all-packages.nix { inherit pkgs; } | ||||||
|   // { | // { | ||||||
|   # The `lib`, `modules`, and `overlay` names are special |   # The `lib`, `modules`, and `overlay` names are special | ||||||
|   lib = import ./lib { inherit pkgs; }; # functions |   lib = import ./lib { inherit pkgs; }; # functions | ||||||
|   modules = import ./modules; # NixOS modules |   modules = import ./modules; # NixOS modules | ||||||
|   overlays = import ./overlays; # nixpkgs overlays |   overlays = import ./overlays; # nixpkgs overlays | ||||||
| } | } // import ./callUnitRoot.nix { inherit pkgs; } | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								flake.nix
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								flake.nix
									
									
									
									
									
								
							| @@ -20,23 +20,11 @@ | |||||||
|           # Unstable names are variables. |           # Unstable names are variables. | ||||||
|           packages = |           packages = | ||||||
|             let |             let | ||||||
|               unitDir = "unit"; |  | ||||||
|               packageFun = "package.nix"; |  | ||||||
|  |  | ||||||
|               callUnitRoot = root: |  | ||||||
|                 let |  | ||||||
|                   shards = lib.attrNames (builtins.readDir root); |  | ||||||
|                   namesForShard = shard: lib.mapAttrs' |  | ||||||
|                     (name: _: { inherit name; value = "${root}/${shard}/${name}"; }) |  | ||||||
|                     (builtins.readDir "${root}/${shard}"); |  | ||||||
|                   namesToPath = lib.foldl' lib.recursiveUpdate { } (map namesForShard shards); |  | ||||||
|                   units = lib.mapAttrs (_: path: pkgs.callPackage "${path}/${packageFun}" { }) namesToPath; |  | ||||||
|                 in |  | ||||||
|                 units; |  | ||||||
|               legacyPackages = import ./pkgs/top-level/all-packages.nix { inherit pkgs; }; |               legacyPackages = import ./pkgs/top-level/all-packages.nix { inherit pkgs; }; | ||||||
|               onlyAvailable = lib.filterAttrs (_: drv: builtins.elem system (drv.meta.platforms or [ ])); |               onlyAvailable = lib.filterAttrs (_: drv: builtins.elem system (drv.meta.platforms or [ ])); | ||||||
|             in |             in | ||||||
|             onlyAvailable (legacyPackages // callUnitRoot "${./pkgs}/${unitDir}"); |             onlyAvailable (legacyPackages // import ./callUnitRoot.nix { inherit pkgs; }); | ||||||
|  |  | ||||||
|           checks = { |           checks = { | ||||||
|             nixpkgs-fmt = pkgs.writeShellScriptBin "nixpkgs-fmt-check" '' |             nixpkgs-fmt = pkgs.writeShellScriptBin "nixpkgs-fmt-check" '' | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user