zhaofengli / attic

Multi-tenant Nix Binary Cache
https://docs.attic.rs
Other
1.03k stars 78 forks source link

could not compile `attic-server` Error #77

Closed hmajid2301 closed 1 year ago

hmajid2301 commented 1 year ago

Hi :wave:,

I am trying to setup atticd server on my nixos machine and I am getting the following error when it is trying to compile the package:

nix log /nix/store/v851smxr2dk9nbfan2ivvjc5lgifghvh-attic-server-0.1.0.drv
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/v851smxr2dk9nbfan2ivvjc5lgifghvh-attic-server-0.1.0.drv^*'
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/r1gk8n3y212hf5r34mdx6jsx42w69msf-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
Executing configureCargoCommonVars
decompressing cargo artifacts from /nix/store/sw95889ymy8m65c72z20k55jycr2f>
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase>
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
will append /build/source/.cargo-home/config.toml with contents of /nix/sto>
default configurePhase, nothing to do
@nix { "action": "setPhase", "phase": "buildPhase" }
building
++ command cargo --version
cargo 1.71.1
++ command cargo build --profile release --message-format json-render-diagn>
   Compiling attic v0.1.0 (/build/source/attic)
   Compiling attic-token v0.1.0 (/build/source/token)
   Compiling attic-server v0.1.0 (/build/source/server)
error: variable does not need to be mutable
  --> server/src/oobe.rs:70:13
   |
70 |         let mut perm = token.get_or_insert_permission_mut(any_cache);
   |             ----^^^^
   |             |
   |             help: remove this `mut`
   |
note: the lint level is defined here
  --> server/src/lib.rs:13:26
   |
13 |     deny(unused_imports, unused_mut, unused_variables,)
   |                          ^^^^^^^^^^

error: could not compile `attic-server` (lib) due to previous error

Where my attic.nix files looks like:

  sops.secrets.attic_env = {
    sopsFile = ../secrets.yaml;
  };

  services.atticd = {
    enable = true;
    credentialsFile = config.sops.secrets.attic_env.path;
    settings = {
      storage = {
        type = "s3";
        region = "us-west-004";
        bucket = "majiy00-nix-cache";
        endpoint = "https://s3.us-west-004.backblazeb2.com";
      };

      listen = "127.0.0.1:8083";
      database.url = "postgresql:///atticd?host=/run/postgresql";
      require-proof-of-possession = false;
      garbage-collection = {
        interval = "3 days";
        default-retention-period = "1 month";
      };
      chunking = {
        nar-size-threshold = 64 * 1024; # 64 KiB
        min-size = 16 * 1024; # 16 KiB
        avg-size = 64 * 1024; # 64 KiB
        max-size = 256 * 1024; # 256 KiB
      };
    };
  };

  services.postgresql = {
    enable = true;
    ensureUsers = [{
      name = "atticd";
      ensurePermissions = {
        "DATABASE atticd" = "ALL PRIVILEGES";
      };
    }];
    ensureDatabases = [ "atticd" ];
  };
}

Any help would be greatly appreciated thanks! :pray:

My dotfiles: https://gitlab.com/hmajid2301/dotfiles/-/blob/90067c774a157c94a598e699c0fad0e4def8c209/nixos/optional/attic.nix

shimunn commented 1 year ago

Rustc bug? perm is definitely being mutated.

zhaofengli commented 1 year ago

(Thanks for the bump - My inbox is swamped 😢)

The lint is correct because get_or_insert_permission_mut returns a mut reference. Appreciate the report!