From b08e97efead72402741b8a5faffa0ebe464520ae Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Thu, 18 Jan 2024 07:38:51 -0800 Subject: [PATCH 1/3] Don't rely on cache.nixos.org Users can substitute from it the first time they encounter a path it has, but otherwise they should re-substitute from us. --- magic-nix-cache/src/flakehub.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/magic-nix-cache/src/flakehub.rs b/magic-nix-cache/src/flakehub.rs index d1ad39c..8697a98 100644 --- a/magic-nix-cache/src/flakehub.rs +++ b/magic-nix-cache/src/flakehub.rs @@ -134,7 +134,7 @@ pub async fn init_cache( is_public: false, priority: 39, store_dir: "/nix/store".to_owned(), - upstream_cache_key_names: vec!["cache.nixos.org-1".to_owned()], // FIXME: do we want this? + upstream_cache_key_names: vec![], }; if let Err(err) = api.create_cache(&cache, request).await { From e8efa56401790164aceab8d97ff28b2758729dea Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Thu, 18 Jan 2024 11:06:00 -0800 Subject: [PATCH 2/3] flake: don't include cross in default devshell --- flake.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ab044a1..6923cac 100644 --- a/flake.nix +++ b/flake.nix @@ -47,7 +47,22 @@ }); devShells = forEachSupportedSystem ({ pkgs, cranePkgs, lib }: { - default = pkgs.mkShell ({ + default = pkgs.mkShell { + inputsFrom = [ cranePkgs.magic-nix-cache ]; + packages = with pkgs; [ + bashInteractive + cranePkgs.rustNightly + + cargo-bloat + cargo-edit + cargo-udeps + cargo-watch + + age + ]; + }; + + cross = pkgs.mkShell ({ inputsFrom = [ cranePkgs.magic-nix-cache ]; packages = with pkgs; [ bashInteractive From 28eca6460d808eda35da59872c24bd47e86f62b1 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Thu, 18 Jan 2024 11:06:19 -0800 Subject: [PATCH 3/3] Don't create the cache attic-priv has functionality to getsert caches as they are requested. --- magic-nix-cache/src/flakehub.rs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/magic-nix-cache/src/flakehub.rs b/magic-nix-cache/src/flakehub.rs index 8697a98..6361102 100644 --- a/magic-nix-cache/src/flakehub.rs +++ b/magic-nix-cache/src/flakehub.rs @@ -1,10 +1,9 @@ use crate::error::{Error, Result}; -use attic::api::v1::cache_config::{CreateCacheRequest, KeypairConfig}; use attic::cache::CacheSliceIdentifier; use attic::nix_store::{NixStore, StorePath}; use attic_client::push::{PushSession, PushSessionConfig}; use attic_client::{ - api::{ApiClient, ApiError}, + api::ApiClient, config::ServerConfig, push::{PushConfig, Pusher}, }; @@ -119,37 +118,15 @@ pub async fn init_cache( ) }; - tracing::info!("Using cache {:?}.", cache_name); + tracing::info!("Using cache {:?}", cache_name); let cache = CacheSliceIdentifier::from_str(&cache_name)?; - // Create the cache. let api = ApiClient::from_server_config(ServerConfig { endpoint: flakehub_cache_server.to_string(), token: netrc_entry.password.as_ref().cloned(), })?; - let request = CreateCacheRequest { - keypair: KeypairConfig::Generate, - is_public: false, - priority: 39, - store_dir: "/nix/store".to_owned(), - upstream_cache_key_names: vec![], - }; - - if let Err(err) = api.create_cache(&cache, request).await { - match err.downcast_ref::() { - Some(ApiError::Structured(x)) if x.error == "CacheAlreadyExists" => { - tracing::info!("Cache {} already exists.", cache_name); - } - _ => { - return Err(Error::FlakeHub(err)); - } - } - } else { - tracing::info!("Created cache {} on {}.", cache_name, flakehub_cache_server); - } - let cache_config = api.get_cache_config(&cache).await?; let push_config = PushConfig {