forked from fediversity/fediversity
		
	
		
			
				
	
	
		
			56 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			56 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
| ## This file contains a tweak of flake-parts's `mkFlake` function to splice in
 | |
| ## sources taken from npins.
 | |
| 
 | |
| ## NOTE: Much of the logic in this file feels like it should be not super
 | |
| ## specific to fediversity. Could it make sense to extract the core of this to
 | |
| ## another place it feels closer to in spirit, such as @fricklerhandwerk's
 | |
| ## flake-inputs (which this code already depends on anyway, and which already
 | |
| ## contained two distinct helpers for migrating away from flakes)? cf
 | |
| ## https://git.fediversity.eu/Fediversity/Fediversity/pulls/447#issuecomment-8671
 | |
| 
 | |
| inputs@{ self, ... }:
 | |
| 
 | |
| let
 | |
|   sources = import ./npins;
 | |
|   inherit (import sources.flake-inputs) import-flake;
 | |
| 
 | |
|   # XXX(@fricklerhandwerk): this atrocity is required to splice in a foreign Nixpkgs via flake-parts
 | |
|   # XXX - this is just importing a flake
 | |
|   nixpkgs = import-flake { src = sources.nixpkgs; };
 | |
| 
 | |
|   # XXX - this overrides the inputs attached to `self`
 | |
|   inputs' = self.inputs // {
 | |
|     nixpkgs = nixpkgs;
 | |
|   };
 | |
|   self' = self // {
 | |
|     inputs = inputs';
 | |
|   };
 | |
| 
 | |
|   inherit (nixpkgs) lib outPath;
 | |
|   flake-parts-lib = import "${sources.flake-parts}/lib.nix" { inherit lib; };
 | |
| in
 | |
| 
 | |
| flakeModule:
 | |
| 
 | |
| flake-parts-lib.mkFlake
 | |
|   {
 | |
|     # XXX - finally we override the overall set of `inputs` -- we need both:
 | |
|     #       `flake-parts obtains `nixpkgs` from `self.inputs` and not from `inputs`.
 | |
|     inputs = inputs // {
 | |
|       inherit nixpkgs;
 | |
|     };
 | |
|     self = self';
 | |
|     specialArgs = {
 | |
|       inherit sources;
 | |
|       modulesPath = "${builtins.toString outPath}/nixos/modules";
 | |
|     };
 | |
|   }
 | |
|   {
 | |
|     systems = [
 | |
|       "x86_64-linux"
 | |
|       "aarch64-linux"
 | |
|       "x86_64-darwin"
 | |
|       "aarch64-darwin"
 | |
|     ];
 | |
|     imports = [ flakeModule ];
 | |
|   }
 |