Cache nix store between builds
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is failing
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	continuous-integration/drone/push Build is failing
				
			This commit is contained in:
		| @@ -1,8 +1,45 @@ | ||||
| local Cache(name, settings) = { | ||||
|   name: name, | ||||
|   image: "meltwater/drone-cache", | ||||
|   pull: true, | ||||
|   settings: { | ||||
|     backend: "filesystem", | ||||
|     cache_key: "{{ .Repo.Name }}", | ||||
|     archive_format: "gzip", | ||||
|     mount: [ | ||||
|       "/nix/store" | ||||
|     ] | ||||
|   } + settings, | ||||
|   volumes: [ | ||||
|     { | ||||
|       name: "cache", | ||||
|       path: "/tmp/cache" | ||||
|     } | ||||
|   ] | ||||
| }; | ||||
|  | ||||
| local Pipeline(channel) = { | ||||
|   kind: "pipeline", | ||||
|   type: "docker", | ||||
|   name: channel, | ||||
|   // This is ignored by the drone-cli YAML translator, so unfortunately, it has | ||||
|   // to be copy-pasted into relevant steps. | ||||
|   environment: { | ||||
|     NIXPKGS_ALLOW_UNFREE: 1, | ||||
|     NUR_REPO: "xeals", | ||||
|     CACHIX_CACHE: "xeals", | ||||
|     CACHIX_SIGNING_KEY: { from_secret: "cachix_key" }, | ||||
|   }, | ||||
|   volumes: [ | ||||
|     { | ||||
|       name: "cache", | ||||
|       temp: {} | ||||
|     } | ||||
|   ], | ||||
|   steps: [ | ||||
|     Cache("restore-nix-store", { | ||||
|       restore: true | ||||
|     }), | ||||
|     { | ||||
|       name: "build", | ||||
|       image: "nixos/nix", | ||||
| @@ -32,7 +69,12 @@ local Pipeline(channel) = { | ||||
|         CACHIX_CACHE: "xeals", | ||||
|         CACHIX_SIGNING_KEY: { from_secret: "cachix_key" }, | ||||
|       }, | ||||
|     } | ||||
|     }, | ||||
|     Cache("save-nix-store", { | ||||
|       rebuild: true | ||||
|     }) + { | ||||
|       when: { status: [ "success", "failure" ] } | ||||
|     }, | ||||
|   ] | ||||
| }; | ||||
|  | ||||
|   | ||||
							
								
								
									
										108
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										108
									
								
								.drone.yml
									
									
									
									
									
								
							| @@ -8,6 +8,20 @@ platform: | ||||
|   arch: amd64 | ||||
|  | ||||
| steps: | ||||
| - name: restore-nix-store | ||||
|   pull: true | ||||
|   image: meltwater/drone-cache | ||||
|   settings: | ||||
|     archive_format: gzip | ||||
|     backend: filesystem | ||||
|     cache_key: "{{ .Repo.Name }}" | ||||
|     mount: | ||||
|     - /nix/store | ||||
|     restore: true | ||||
|   volumes: | ||||
|   - name: cache | ||||
|     path: /tmp/cache | ||||
|  | ||||
| - name: build | ||||
|   image: nixos/nix | ||||
|   commands: | ||||
| @@ -31,6 +45,28 @@ steps: | ||||
|     NIXPKGS_ALLOW_UNFREE: 1 | ||||
|     NUR_REPO: xeals | ||||
|  | ||||
| - name: save-nix-store | ||||
|   pull: true | ||||
|   image: meltwater/drone-cache | ||||
|   settings: | ||||
|     archive_format: gzip | ||||
|     backend: filesystem | ||||
|     cache_key: "{{ .Repo.Name }}" | ||||
|     mount: | ||||
|     - /nix/store | ||||
|     rebuild: true | ||||
|   volumes: | ||||
|   - name: cache | ||||
|     path: /tmp/cache | ||||
|   when: | ||||
|     status: | ||||
|     - success | ||||
|     - failure | ||||
|  | ||||
| volumes: | ||||
| - name: cache | ||||
|   temp: {} | ||||
|  | ||||
| --- | ||||
| kind: pipeline | ||||
| type: docker | ||||
| @@ -41,6 +77,20 @@ platform: | ||||
|   arch: amd64 | ||||
|  | ||||
| steps: | ||||
| - name: restore-nix-store | ||||
|   pull: true | ||||
|   image: meltwater/drone-cache | ||||
|   settings: | ||||
|     archive_format: gzip | ||||
|     backend: filesystem | ||||
|     cache_key: "{{ .Repo.Name }}" | ||||
|     mount: | ||||
|     - /nix/store | ||||
|     restore: true | ||||
|   volumes: | ||||
|   - name: cache | ||||
|     path: /tmp/cache | ||||
|  | ||||
| - name: build | ||||
|   image: nixos/nix | ||||
|   commands: | ||||
| @@ -64,6 +114,28 @@ steps: | ||||
|     NIXPKGS_ALLOW_UNFREE: 1 | ||||
|     NUR_REPO: xeals | ||||
|  | ||||
| - name: save-nix-store | ||||
|   pull: true | ||||
|   image: meltwater/drone-cache | ||||
|   settings: | ||||
|     archive_format: gzip | ||||
|     backend: filesystem | ||||
|     cache_key: "{{ .Repo.Name }}" | ||||
|     mount: | ||||
|     - /nix/store | ||||
|     rebuild: true | ||||
|   volumes: | ||||
|   - name: cache | ||||
|     path: /tmp/cache | ||||
|   when: | ||||
|     status: | ||||
|     - success | ||||
|     - failure | ||||
|  | ||||
| volumes: | ||||
| - name: cache | ||||
|   temp: {} | ||||
|  | ||||
| --- | ||||
| kind: pipeline | ||||
| type: docker | ||||
| @@ -74,6 +146,20 @@ platform: | ||||
|   arch: amd64 | ||||
|  | ||||
| steps: | ||||
| - name: restore-nix-store | ||||
|   pull: true | ||||
|   image: meltwater/drone-cache | ||||
|   settings: | ||||
|     archive_format: gzip | ||||
|     backend: filesystem | ||||
|     cache_key: "{{ .Repo.Name }}" | ||||
|     mount: | ||||
|     - /nix/store | ||||
|     restore: true | ||||
|   volumes: | ||||
|   - name: cache | ||||
|     path: /tmp/cache | ||||
|  | ||||
| - name: build | ||||
|   image: nixos/nix | ||||
|   commands: | ||||
| @@ -97,4 +183,26 @@ steps: | ||||
|     NIXPKGS_ALLOW_UNFREE: 1 | ||||
|     NUR_REPO: xeals | ||||
|  | ||||
| - name: save-nix-store | ||||
|   pull: true | ||||
|   image: meltwater/drone-cache | ||||
|   settings: | ||||
|     archive_format: gzip | ||||
|     backend: filesystem | ||||
|     cache_key: "{{ .Repo.Name }}" | ||||
|     mount: | ||||
|     - /nix/store | ||||
|     rebuild: true | ||||
|   volumes: | ||||
|   - name: cache | ||||
|     path: /tmp/cache | ||||
|   when: | ||||
|     status: | ||||
|     - success | ||||
|     - failure | ||||
|  | ||||
| volumes: | ||||
| - name: cache | ||||
|   temp: {} | ||||
|  | ||||
| ... | ||||
|   | ||||
		Reference in New Issue
	
	Block a user