forked from cccb-website-team/www
		
	flake lib.mkWwwContent
This commit is contained in:
		
							parent
							
								
									7a32bd5efd
								
							
						
					
					
						commit
						9b0da1e267
					
				
					 2 changed files with 54 additions and 42 deletions
				
			
		
							
								
								
									
										42
									
								
								flake.nix
									
										
									
									
									
								
							
							
						
						
									
										42
									
								
								flake.nix
									
										
									
									
									
								
							|  | @ -25,7 +25,7 @@ | |||
|             inherit system; | ||||
|             pkgs = nixpkgs.legacyPackages.${system}; | ||||
|             selfPkgs = self.packages.${system}; | ||||
|             lib = pkgs.lib; | ||||
|             lib = pkgs.lib // self.lib; | ||||
|           } | ||||
|         ); | ||||
|     in | ||||
|  | @ -35,5 +35,45 @@ | |||
|       devShells = forAllSystems (import ./devShells.nix); | ||||
| 
 | ||||
|       formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style); | ||||
| 
 | ||||
|       lib.mkWwwContent = | ||||
|         { domain, system }: | ||||
|         let | ||||
|           pkgs = nixpkgs.legacyPackages.${system}; | ||||
|         in | ||||
|         pkgs.stdenvNoCC.mkDerivation { | ||||
|           pname = "www-content"; | ||||
|           version = domain; | ||||
|           src = ./.; | ||||
| 
 | ||||
|           # Build dependencies | ||||
|           nativeBuildInputs = [ | ||||
|             pkgs.hugo | ||||
|             pkgs.glibcLocales | ||||
|             (pkgs.python3.withPackages (python-pkgs: [ | ||||
|               python-pkgs.icalendar | ||||
|               python-pkgs.pytz | ||||
|             ])) | ||||
|           ]; | ||||
| 
 | ||||
|           LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive"; | ||||
| 
 | ||||
|           # Build phase - run Hugo to generate the site | ||||
|           buildPhase = '' | ||||
|             mkdir -p public | ||||
|             hugo --baseURL=https://${domain}/ | ||||
| 
 | ||||
|             python3 ./tools/merge_cals.py | ||||
|             upcoming="$(python3 tools/gen_upcoming.py static/all.ics 20 5 | tr '\n' ' ')" | ||||
|             cp static/all.ics public/all.ics | ||||
|             sed -i "s#CALENDAR#$upcoming#g" public/index.html | ||||
|           ''; | ||||
| 
 | ||||
|           # Install phase - copy the public directory to the output | ||||
|           installPhase = '' | ||||
|             mkdir -p $out | ||||
|             cp -r public/* $out/ | ||||
|           ''; | ||||
|         }; | ||||
|     }; | ||||
| } | ||||
|  |  | |||
							
								
								
									
										54
									
								
								packages.nix
									
										
									
									
									
								
							
							
						
						
									
										54
									
								
								packages.nix
									
										
									
									
									
								
							|  | @ -1,47 +1,19 @@ | |||
| { | ||||
|   pkgs, | ||||
|   lib, | ||||
|   ... | ||||
| }: | ||||
| let | ||||
|   mkWwwContent = | ||||
|     { domain }: | ||||
|     pkgs.stdenvNoCC.mkDerivation { | ||||
|       pname = "www-content"; | ||||
|       version = domain; | ||||
|       src = ./.; | ||||
| 
 | ||||
|       # Build dependencies | ||||
|       nativeBuildInputs = [ | ||||
|         pkgs.hugo | ||||
|         pkgs.glibcLocales | ||||
|         (pkgs.python3.withPackages (python-pkgs: [ | ||||
|           python-pkgs.icalendar | ||||
|           python-pkgs.pytz | ||||
|         ])) | ||||
|       ]; | ||||
| 
 | ||||
|       LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive"; | ||||
| 
 | ||||
|       # Build phase - run Hugo to generate the site | ||||
|       buildPhase = '' | ||||
|         mkdir -p public | ||||
|         hugo --baseURL=https://${domain}/ | ||||
| 
 | ||||
|         python3 ./tools/merge_cals.py | ||||
|         upcoming="$(python3 tools/gen_upcoming.py static/all.ics 20 5 | tr '\n' ' ')" | ||||
|         cp static/all.ics public/all.ics | ||||
|         sed -i "s#CALENDAR#$upcoming#g" public/index.html | ||||
|       ''; | ||||
| 
 | ||||
|       # Install phase - copy the public directory to the output | ||||
|       installPhase = '' | ||||
|         mkdir -p $out | ||||
|         cp -r public/* $out/ | ||||
|       ''; | ||||
|     }; | ||||
| in | ||||
| { | ||||
|   production-content = mkWwwContent { domain = "berlin.ccc.de"; }; | ||||
|   staging-content = mkWwwContent { domain = "staging.berlin.ccc.de"; }; | ||||
|   local-content = mkWwwContent { domain = "localhost"; }; | ||||
|   production-content = lib.mkWwwContent { | ||||
|     domain = "berlin.ccc.de"; | ||||
|     inherit (pkgs) system; | ||||
|   }; | ||||
|   staging-content = lib.mkWwwContent { | ||||
|     domain = "staging.berlin.ccc.de"; | ||||
|     inherit (pkgs) system; | ||||
|   }; | ||||
|   local-content = lib.mkWwwContent { | ||||
|     domain = "localhost"; | ||||
|     inherit (pkgs) system; | ||||
|   }; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter