A fork of attic a self-hostable Nix Binary Cache server
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Start migration to flake-parts

+276 -153
+21
flake.lock
··· 36 36 "type": "github" 37 37 } 38 38 }, 39 + "flake-parts": { 40 + "inputs": { 41 + "nixpkgs-lib": [ 42 + "nixpkgs" 43 + ] 44 + }, 45 + "locked": { 46 + "lastModified": 1722555600, 47 + "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", 48 + "owner": "hercules-ci", 49 + "repo": "flake-parts", 50 + "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", 51 + "type": "github" 52 + }, 53 + "original": { 54 + "owner": "hercules-ci", 55 + "repo": "flake-parts", 56 + "type": "github" 57 + } 58 + }, 39 59 "flake-utils": { 40 60 "inputs": { 41 61 "systems": "systems" ··· 90 110 "inputs": { 91 111 "crane": "crane", 92 112 "flake-compat": "flake-compat", 113 + "flake-parts": "flake-parts", 93 114 "flake-utils": "flake-utils", 94 115 "nixpkgs": "nixpkgs", 95 116 "nixpkgs-stable": "nixpkgs-stable"
+129 -153
flake.nix
··· 6 6 nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05"; 7 7 flake-utils.url = "github:numtide/flake-utils"; 8 8 9 + flake-parts = { 10 + url = "github:hercules-ci/flake-parts"; 11 + inputs.nixpkgs-lib.follows = "nixpkgs"; 12 + }; 13 + 9 14 crane = { 10 15 url = "github:ipetkov/crane"; 11 16 inputs.nixpkgs.follows = "nixpkgs"; ··· 17 22 }; 18 23 }; 19 24 20 - outputs = { self, nixpkgs, nixpkgs-stable, flake-utils, crane, ... }: let 21 - supportedSystems = flake-utils.lib.defaultSystems ++ [ "riscv64-linux" ]; 25 + outputs = inputs @ { self, flake-parts, ... }: let 26 + supportedSystems = inputs.flake-utils.lib.defaultSystems ++ [ "riscv64-linux" ]; 27 + 28 + inherit (inputs.nixpkgs) lib; 22 29 23 30 makeCranePkgs = pkgs: let 24 - craneLib = crane.mkLib pkgs; 31 + craneLib = inputs.crane.mkLib pkgs; 25 32 in pkgs.callPackage ./crane.nix { inherit craneLib; }; 26 - in flake-utils.lib.eachSystem supportedSystems (system: let 27 - pkgs = import nixpkgs { 28 - inherit system; 29 - overlays = []; 30 - }; 31 - cranePkgs = makeCranePkgs pkgs; 32 33 33 - internalMatrix = lib.mapAttrs (_: nix: let 34 - cranePkgs' = cranePkgs.override { inherit nix; }; 35 - in { 36 - inherit (cranePkgs') attic-tests cargoArtifacts; 37 - }) { 38 - "2.20" = pkgs.nixVersions.nix_2_20; 39 - "2.24" = pkgs.nixVersions.nix_2_24; 40 - "default" = pkgs.nix; 41 - }; 34 + modules = builtins.foldl' (acc: f: f acc) ./flake [ 35 + builtins.readDir 36 + (lib.filterAttrs (name: type: 37 + type == "regular" && lib.hasSuffix ".nix" name 38 + )) 39 + (lib.mapAttrsToList (name: _: 40 + lib.path.append ./flake name 41 + )) 42 + ]; 42 43 43 - pkgsStable = import nixpkgs-stable { 44 - inherit system; 45 - overlays = []; 46 - }; 47 - cranePkgsStable = makeCranePkgs pkgsStable; 44 + in flake-parts.lib.mkFlake { inherit inputs; } { 45 + imports = modules; 46 + systems = supportedSystems; 48 47 49 - inherit (pkgs) lib; 50 - in rec { 51 - inherit internalMatrix; 48 + debug = true; 52 49 53 - packages = { 54 - default = packages.attic; 55 - 56 - inherit (cranePkgs) attic attic-client attic-server; 57 - 58 - attic-nixpkgs = pkgs.callPackage ./package.nix { }; 59 - 60 - attic-ci-installer = pkgs.callPackage ./ci-installer.nix { 61 - inherit self; 50 + # old flake 51 + flake = inputs.flake-utils.lib.eachSystem supportedSystems (system: let 52 + pkgs = import inputs.nixpkgs { 53 + inherit system; 54 + overlays = []; 62 55 }; 56 + cranePkgs = makeCranePkgs pkgs; 63 57 64 - book = pkgs.callPackage ./book { 65 - attic = packages.attic; 66 - }; 67 - } // (lib.optionalAttrs (system != "x86_64-darwin") { 68 - # Unfortunately, x86_64-darwin fails to evaluate static builds 69 - # TODO: Make this work with Crane 70 - attic-static = (pkgs.pkgsStatic.callPackage ./package.nix { 71 - nix = pkgs.pkgsStatic.nix.overrideAttrs (old: { 72 - patches = (old.patches or []) ++ [ 73 - # To be submitted 74 - (pkgs.fetchpatch { 75 - url = "https://github.com/NixOS/nix/compare/3172c51baff5c81362fcdafa2e28773c2949c660...6b09a02536d5946458b537dfc36b7d268c9ce823.diff"; 76 - hash = "sha256-LFLq++J2XitEWQ0o57ihuuUlYk2PgUr11h7mMMAEe3c="; 77 - }) 78 - ]; 79 - }); 80 - }).overrideAttrs (old: { 81 - nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ 82 - pkgs.nukeReferences 83 - ]; 84 - 85 - # Read by pkg_config crate (do some autodetection in build.rs?) 86 - PKG_CONFIG_ALL_STATIC = "1"; 87 - 88 - "NIX_CFLAGS_LINK_${pkgs.pkgsStatic.stdenv.cc.suffixSalt}" = "-lc"; 89 - RUSTFLAGS = "-C relocation-model=static"; 90 - 91 - postFixup = (old.postFixup or "") + '' 92 - rm -f $out/nix-support/propagated-build-inputs 93 - nuke-refs $out/bin/attic 94 - ''; 95 - }); 96 - 97 - attic-client-static = packages.attic-static.override { 98 - clientOnly = true; 58 + internalMatrix = lib.mapAttrs (_: nix: let 59 + cranePkgs' = cranePkgs.override { inherit nix; }; 60 + in { 61 + inherit (cranePkgs') attic-tests cargoArtifacts; 62 + }) { 63 + "2.20" = pkgs.nixVersions.nix_2_20; 64 + "2.24" = pkgs.nixVersions.nix_2_24; 65 + "default" = pkgs.nix; 99 66 }; 100 - }) // (lib.optionalAttrs pkgs.stdenv.isLinux { 101 - attic-server-image = pkgs.dockerTools.buildImage { 102 - name = "attic-server"; 103 - tag = "main"; 104 - copyToRoot = [ 105 - # Debugging utilities for `fly ssh console` 106 - pkgs.busybox 107 - packages.attic-server 108 67 109 - # Now required by the fly.io sshd 110 - pkgs.dockerTools.fakeNss 111 - ]; 112 - config = { 113 - Entrypoint = [ "${packages.attic-server}/bin/atticd" ]; 114 - Env = [ 115 - "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" 116 - ]; 117 - }; 68 + pkgsStable = import inputs.nixpkgs-stable { 69 + inherit system; 70 + overlays = []; 118 71 }; 119 - }); 72 + cranePkgsStable = makeCranePkgs pkgsStable; 120 73 121 - devShells = { 122 - default = pkgs.mkShell { 123 - inputsFrom = with packages; [ attic book ]; 124 - nativeBuildInputs = with pkgs; [ 125 - rustc 126 - 127 - rustfmt clippy 128 - cargo-expand 129 - # Temporary broken: https://github.com/NixOS/nixpkgs/pull/335152 130 - # cargo-outdated 131 - cargo-edit 132 - tokio-console 74 + inherit (pkgs) lib; 75 + in rec { 76 + inherit internalMatrix; 133 77 134 - sqlite-interactive 78 + packages = { 79 + default = packages.attic; 135 80 136 - editorconfig-checker 81 + inherit (cranePkgs) attic attic-client attic-server; 137 82 138 - flyctl 83 + attic-nixpkgs = pkgs.callPackage ./package.nix { }; 139 84 140 - wrk 85 + attic-ci-installer = pkgs.callPackage ./ci-installer.nix { 86 + inherit self; 87 + }; 141 88 142 - llvmPackages_latest.bintools 143 - wrangler worker-build wasm-pack wasm-bindgen-cli 144 - ] ++ (lib.optionals pkgs.stdenv.isLinux [ 145 - linuxPackages.perf 146 - ]); 89 + book = pkgs.callPackage ./book { 90 + attic = packages.attic; 91 + }; 92 + } // (lib.optionalAttrs (system != "x86_64-darwin") { 93 + # Unfortunately, x86_64-darwin fails to evaluate static builds 94 + # TODO: Make this work with Crane 95 + attic-static = (pkgs.pkgsStatic.callPackage ./package.nix { 96 + nix = pkgs.pkgsStatic.nix.overrideAttrs (old: { 97 + patches = (old.patches or []) ++ [ 98 + # To be submitted 99 + (pkgs.fetchpatch { 100 + url = "https://github.com/NixOS/nix/compare/3172c51baff5c81362fcdafa2e28773c2949c660...6b09a02536d5946458b537dfc36b7d268c9ce823.diff"; 101 + hash = "sha256-LFLq++J2XitEWQ0o57ihuuUlYk2PgUr11h7mMMAEe3c="; 102 + }) 103 + ]; 104 + }); 105 + }).overrideAttrs (old: { 106 + nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ 107 + pkgs.nukeReferences 108 + ]; 147 109 148 - NIX_PATH = "nixpkgs=${pkgs.path}"; 149 - RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library"; 110 + # Read by pkg_config crate (do some autodetection in build.rs?) 111 + PKG_CONFIG_ALL_STATIC = "1"; 150 112 151 - # See comment in `attic/build.rs` 152 - NIX_INCLUDE_PATH = "${lib.getDev pkgs.nix}/include"; 113 + "NIX_CFLAGS_LINK_${pkgs.pkgsStatic.stdenv.cc.suffixSalt}" = "-lc"; 114 + RUSTFLAGS = "-C relocation-model=static"; 153 115 154 - ATTIC_DISTRIBUTOR = "dev"; 155 - }; 116 + postFixup = (old.postFixup or "") + '' 117 + rm -f $out/nix-support/propagated-build-inputs 118 + nuke-refs $out/bin/attic 119 + ''; 120 + }); 156 121 157 - demo = pkgs.mkShell { 158 - nativeBuildInputs = [ 159 - packages.default 160 - ]; 122 + attic-client-static = packages.attic-static.override { 123 + clientOnly = true; 124 + }; 125 + }) // (lib.optionalAttrs pkgs.stdenv.isLinux { 126 + attic-server-image = pkgs.dockerTools.buildImage { 127 + name = "attic-server"; 128 + tag = "main"; 129 + copyToRoot = [ 130 + # Debugging utilities for `fly ssh console` 131 + pkgs.busybox 132 + packages.attic-server 161 133 162 - shellHook = '' 163 - >&2 echo 164 - >&2 echo '🚀 Run `atticd` to get started!' 165 - >&2 echo 166 - ''; 167 - }; 168 - }; 169 - devShell = devShells.default; 134 + # Now required by the fly.io sshd 135 + pkgs.dockerTools.fakeNss 136 + ]; 137 + config = { 138 + Entrypoint = [ "${packages.attic-server}/bin/atticd" ]; 139 + Env = [ 140 + "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" 141 + ]; 142 + }; 143 + }; 144 + }); 170 145 171 - checks = let 172 - makeIntegrationTests = pkgs: import ./integration-tests { 173 - pkgs = import nixpkgs { 174 - inherit system; 175 - overlays = [ self.overlays.default ]; 146 + checks = let 147 + makeIntegrationTests = pkgs: import ./integration-tests { 148 + pkgs = import inputs.nixpkgs { 149 + inherit system; 150 + overlays = [ self.overlays.default ]; 151 + }; 152 + flake = self; 176 153 }; 177 - flake = self; 178 - }; 179 - unstableTests = makeIntegrationTests pkgs; 180 - stableTests = lib.mapAttrs' (name: lib.nameValuePair "stable-${name}") (makeIntegrationTests pkgsStable); 181 - in lib.optionalAttrs pkgs.stdenv.isLinux (unstableTests // stableTests); 182 - }) // { 183 - overlays = { 184 - default = final: prev: let 185 - cranePkgs = makeCranePkgs final; 186 - in { 187 - inherit (cranePkgs) attic attic-client attic-server; 154 + unstableTests = makeIntegrationTests pkgs; 155 + stableTests = lib.mapAttrs' (name: lib.nameValuePair "stable-${name}") (makeIntegrationTests pkgsStable); 156 + in lib.optionalAttrs pkgs.stdenv.isLinux (unstableTests // stableTests); 157 + }) // { 158 + overlays = { 159 + default = final: prev: let 160 + cranePkgs = makeCranePkgs final; 161 + in { 162 + inherit (cranePkgs) attic attic-client attic-server; 163 + }; 188 164 }; 189 - }; 190 165 191 - nixosModules = { 192 - atticd = { 193 - imports = [ 194 - ./nixos/atticd.nix 195 - ]; 166 + nixosModules = { 167 + atticd = { 168 + imports = [ 169 + ./nixos/atticd.nix 170 + ]; 196 171 197 - services.atticd.useFlakeCompatOverlay = false; 172 + services.atticd.useFlakeCompatOverlay = false; 198 173 199 - nixpkgs.overlays = [ 200 - self.overlays.default 201 - ]; 174 + nixpkgs.overlays = [ 175 + self.overlays.default 176 + ]; 177 + }; 202 178 }; 203 179 }; 204 180 };
+111
flake/devshells.nix
··· 1 + # Development shells 2 + 3 + toplevel @ { lib, flake-parts-lib, ... }: 4 + let 5 + inherit (lib) 6 + mkOption 7 + types 8 + ; 9 + inherit (flake-parts-lib) 10 + mkPerSystemOption 11 + ; 12 + in 13 + { 14 + options = { 15 + perSystem = mkPerSystemOption { 16 + options.attic.devshell = { 17 + packageSets = mkOption { 18 + type = types.attrsOf (types.listOf types.package); 19 + default = {}; 20 + }; 21 + extraPackages = mkOption { 22 + type = types.listOf types.package; 23 + default = []; 24 + }; 25 + extraArgs = mkOption { 26 + type = types.attrsOf types.unspecified; 27 + default = {}; 28 + }; 29 + }; 30 + }; 31 + }; 32 + 33 + config = { 34 + perSystem = { self', pkgs, config, ... }: let 35 + cfg = config.attic.devshell; 36 + in { 37 + attic.devshell.packageSets = with pkgs; { 38 + rust = [ 39 + rustc 40 + 41 + cargo-expand 42 + # Temporary broken: https://github.com/NixOS/nixpkgs/pull/335152 43 + # cargo-outdated 44 + cargo-edit 45 + tokio-console 46 + ]; 47 + 48 + linters = [ 49 + clippy 50 + rustfmt 51 + 52 + editorconfig-checker 53 + ]; 54 + 55 + utils = [ 56 + jq 57 + just 58 + ]; 59 + 60 + ops = [ 61 + postgresql 62 + sqlite-interactive 63 + 64 + flyctl 65 + wrangler 66 + ]; 67 + 68 + bench = [ 69 + wrk 70 + ] ++ lib.optionals pkgs.stdenv.isLinux [ 71 + linuxPackages.perf 72 + ]; 73 + 74 + wasm = [ 75 + llvmPackages_latest.bintools 76 + worker-build wasm-pack wasm-bindgen-cli 77 + ]; 78 + }; 79 + 80 + devShells.default = pkgs.mkShell (lib.recursiveUpdate { 81 + inputsFrom = [ 82 + self'.packages.attic 83 + self'.packages.book 84 + ]; 85 + 86 + packages = lib.flatten (lib.attrValues cfg.packageSets); 87 + 88 + env = { 89 + ATTIC_DISTRIBUTOR = toplevel.config.attic.distributor; 90 + 91 + RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library"; 92 + 93 + NIX_PATH = "nixpkgs=${pkgs.path}"; 94 + 95 + # See comment in `attic/build.rs` 96 + NIX_INCLUDE_PATH = "${lib.getDev pkgs.nixVersions.nix_2_24}/include"; 97 + }; 98 + } cfg.extraArgs); 99 + 100 + devShells.demo = pkgs.mkShell { 101 + packages = [ self'.packages.default ]; 102 + 103 + shellHook = '' 104 + >&2 echo 105 + >&2 echo '🚀 Run `atticd` to get started!' 106 + >&2 echo 107 + ''; 108 + }; 109 + }; 110 + }; 111 + }
+15
flake/distributor.nix
··· 1 + { lib, flake-parts-lib, ... }: 2 + let 3 + inherit (lib) 4 + mkOption 5 + types 6 + ; 7 + in 8 + { 9 + options = { 10 + attic.distributor = mkOption { 11 + type = types.str; 12 + default = "dev"; 13 + }; 14 + }; 15 + }