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.

Merge pull request #165 from zhaofengli/flake-parts

Migrate to flake-parts

authored by

Zhaofeng Li and committed by
GitHub
f74cee00 c2354f65

+507 -200
+1
.ci/.gitignore
··· 1 + /cached-shell
+5
.ci/cache-shell.sh
··· 1 + #!/usr/bin/env bash 2 + source "$(dirname "${BASH_SOURCE[0]}")/common.sh" 3 + 4 + >&2 echo "Caching dev shell" 5 + nix print-dev-env "${base}#" >"${cached_shell}"
+7
.ci/common.sh
··· 1 + # Use as: 2 + # 3 + # source "$(dirname "${BASH_SOURCE[0]}")/common.sh" 4 + 5 + set -euo pipefail 6 + base="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" 7 + cached_shell="${base}/.ci/cached-shell"
+10
.ci/run
··· 1 + #!/usr/bin/env bash 2 + source "$(dirname "${BASH_SOURCE[0]}")/common.sh" 3 + 4 + if [[ ! -f "${cached_shell}" ]]; then 5 + >&2 echo "No cached shell in ${cached_shell}" 6 + exit 1 7 + fi 8 + 9 + . "${cached_shell}" 10 + exec "$@"
+12 -12
.github/workflows/build.yml
··· 23 23 steps: 24 24 - uses: actions/checkout@v4.1.1 25 25 26 + - name: Install current Bash on macOS 27 + if: runner.os == 'macOS' 28 + run: | 29 + command -v brew && brew install bash || true 30 + 26 31 - uses: DeterminateSystems/nix-installer-action@v9 27 32 continue-on-error: true # Self-hosted runners already have Nix installed 28 33 ··· 45 50 ATTIC_CACHE: ${{ secrets.ATTIC_CACHE }} 46 51 ATTIC_TOKEN: ${{ secrets.ATTIC_TOKEN }} 47 52 48 - - name: Build and run tests 53 + - name: Cache dev shell 49 54 run: | 55 + .ci/cache-shell.sh 50 56 system=$(nix-instantiate --eval -E 'builtins.currentSystem') 51 57 echo system=$system >>$GITHUB_ENV 52 - tests=$(nix build .#internalMatrix."$system".\"${{ matrix.nix }}\".attic-tests --no-link --print-out-paths -L) 53 - find "$tests/bin" -exec {} \; 58 + 59 + - name: Run unit tests 60 + run: | 61 + .ci/run just ci-unit-tests ${{ matrix.nix }} 54 62 55 63 - name: Build WebAssembly crates 56 64 if: runner.os == 'Linux' 57 65 run: | 58 - # https://github.com/rust-lang/rust/issues/122357 59 - export RUST_MIN_STACK=16777216 60 - 61 - pushd attic 62 - nix develop .# --command -- cargo build --target wasm32-unknown-unknown --no-default-features -F chunking -F stream 63 - popd 64 - pushd token 65 - nix develop .# --command -- cargo build --target wasm32-unknown-unknown 66 - popd 66 + .ci/run just ci-build-wasm 67 67 68 68 # TODO: Just take a diff of the list of store paths, also abstract all of this out 69 69 - name: Push build artifacts
+28 -7
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" ··· 56 76 }, 57 77 "nixpkgs": { 58 78 "locked": { 59 - "lastModified": 1723827930, 60 - "narHash": "sha256-EU+W5F6y2CVNxGrGIMpY7nSVYq72WRChYxF4zpjx0y4=", 79 + "lastModified": 1724999960, 80 + "narHash": "sha256-LB3jqSGW5u1ZcUcX6vO/qBOq5oXHlmOCxsTXGMEitp4=", 61 81 "owner": "NixOS", 62 82 "repo": "nixpkgs", 63 - "rev": "d4a7a4d0e066278bfb0d77bd2a7adde1c0ec9e3d", 83 + "rev": "b96f849e725333eb2b1c7f1cb84ff102062468ba", 64 84 "type": "github" 65 85 }, 66 86 "original": { ··· 72 92 }, 73 93 "nixpkgs-stable": { 74 94 "locked": { 75 - "lastModified": 1720535198, 76 - "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", 95 + "lastModified": 1724316499, 96 + "narHash": "sha256-Qb9MhKBUTCfWg/wqqaxt89Xfi6qTD3XpTzQ9eXi3JmE=", 77 97 "owner": "NixOS", 78 98 "repo": "nixpkgs", 79 - "rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5", 99 + "rev": "797f7dc49e0bc7fab4b57c021cdf68f595e47841", 80 100 "type": "github" 81 101 }, 82 102 "original": { 83 103 "owner": "NixOS", 84 - "ref": "nixos-23.11", 104 + "ref": "nixos-24.05", 85 105 "repo": "nixpkgs", 86 106 "type": "github" 87 107 } ··· 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"
+22 -181
flake.nix
··· 3 3 4 4 inputs = { 5 5 nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 6 - nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.11"; 6 + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05"; 7 7 flake-utils.url = "github:numtide/flake-utils"; 8 + 9 + flake-parts = { 10 + url = "github:hercules-ci/flake-parts"; 11 + inputs.nixpkgs-lib.follows = "nixpkgs"; 12 + }; 8 13 9 14 crane = { 10 15 url = "github:ipetkov/crane"; ··· 17 22 }; 18 23 }; 19 24 20 - outputs = { self, nixpkgs, nixpkgs-stable, flake-utils, crane, ... }: let 21 - supportedSystems = flake-utils.lib.defaultSystems ++ [ "riscv64-linux" ]; 22 - 23 - makeCranePkgs = pkgs: let 24 - craneLib = crane.mkLib pkgs; 25 - 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 - 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 - }; 42 - 43 - pkgsStable = import nixpkgs-stable { 44 - inherit system; 45 - overlays = []; 46 - }; 47 - cranePkgsStable = makeCranePkgs pkgsStable; 48 - 49 - inherit (pkgs) lib; 50 - in rec { 51 - inherit internalMatrix; 52 - 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; 62 - }; 63 - 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 - ]; 25 + outputs = inputs @ { self, flake-parts, ... }: let 26 + supportedSystems = inputs.flake-utils.lib.defaultSystems ++ [ "riscv64-linux" ]; 84 27 85 - # Read by pkg_config crate (do some autodetection in build.rs?) 86 - PKG_CONFIG_ALL_STATIC = "1"; 28 + inherit (inputs.nixpkgs) lib; 87 29 88 - "NIX_CFLAGS_LINK_${pkgs.pkgsStatic.stdenv.cc.suffixSalt}" = "-lc"; 89 - RUSTFLAGS = "-C relocation-model=static"; 30 + modules = builtins.foldl' (acc: f: f acc) ./flake [ 31 + builtins.readDir 32 + (lib.filterAttrs (name: type: 33 + type == "regular" && lib.hasSuffix ".nix" name 34 + )) 35 + (lib.mapAttrsToList (name: _: 36 + lib.path.append ./flake name 37 + )) 38 + ]; 90 39 91 - postFixup = (old.postFixup or "") + '' 92 - rm -f $out/nix-support/propagated-build-inputs 93 - nuke-refs $out/bin/attic 94 - ''; 95 - }); 40 + in flake-parts.lib.mkFlake { inherit inputs; } { 41 + imports = modules; 42 + systems = supportedSystems; 96 43 97 - attic-client-static = packages.attic-static.override { 98 - clientOnly = true; 99 - }; 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 - 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 - }; 118 - }; 119 - }); 120 - 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 133 - 134 - sqlite-interactive 135 - 136 - editorconfig-checker 137 - 138 - flyctl 139 - 140 - wrk 141 - 142 - llvmPackages_latest.bintools 143 - wrangler worker-build wasm-pack wasm-bindgen-cli 144 - ] ++ (lib.optionals pkgs.stdenv.isLinux [ 145 - linuxPackages.perf 146 - ]); 147 - 148 - NIX_PATH = "nixpkgs=${pkgs.path}"; 149 - RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library"; 150 - 151 - # See comment in `attic/build.rs` 152 - NIX_INCLUDE_PATH = "${lib.getDev pkgs.nix}/include"; 153 - 154 - ATTIC_DISTRIBUTOR = "dev"; 155 - }; 156 - 157 - demo = pkgs.mkShell { 158 - nativeBuildInputs = [ 159 - packages.default 160 - ]; 161 - 162 - shellHook = '' 163 - >&2 echo 164 - >&2 echo '🚀 Run `atticd` to get started!' 165 - >&2 echo 166 - ''; 167 - }; 168 - }; 169 - devShell = devShells.default; 170 - 171 - checks = let 172 - makeIntegrationTests = pkgs: import ./integration-tests { 173 - pkgs = import nixpkgs { 174 - inherit system; 175 - overlays = [ self.overlays.default ]; 176 - }; 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; 188 - }; 189 - }; 190 - 191 - nixosModules = { 192 - atticd = { 193 - imports = [ 194 - ./nixos/atticd.nix 195 - ]; 196 - 197 - services.atticd.useFlakeCompatOverlay = false; 198 - 199 - nixpkgs.overlays = [ 200 - self.overlays.default 201 - ]; 202 - }; 203 - }; 44 + debug = true; 204 45 }; 205 46 }
+114
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 + cargo-outdated 43 + cargo-edit 44 + tokio-console 45 + ]; 46 + 47 + linters = [ 48 + clippy 49 + rustfmt 50 + 51 + editorconfig-checker 52 + ]; 53 + 54 + utils = [ 55 + jq 56 + just 57 + ]; 58 + 59 + ops = [ 60 + postgresql 61 + sqlite-interactive 62 + 63 + flyctl 64 + ] ++ lib.optionals pkgs.stdenv.isLinux [ 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 + # Used by `just with-nix` to build/test with alternative Nix versions. 99 + NIX_VERSIONS = config.attic.nix-versions.manifestFile; 100 + }; 101 + } cfg.extraArgs); 102 + 103 + devShells.demo = pkgs.mkShell { 104 + packages = [ self'.packages.default ]; 105 + 106 + shellHook = '' 107 + >&2 echo 108 + >&2 echo '🚀 Run `atticd` to get started!' 109 + >&2 echo 110 + ''; 111 + }; 112 + }; 113 + }; 114 + }
+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 + }
+60
flake/integration-tests.nix
··· 1 + { lib, flake-parts-lib, inputs, self, ... }: 2 + let 3 + inherit (lib) 4 + mkOption 5 + types 6 + ; 7 + inherit (flake-parts-lib) 8 + mkPerSystemOption 9 + ; 10 + in 11 + { 12 + options = { 13 + perSystem = mkPerSystemOption { 14 + options.attic.integration-tests = { 15 + nixpkgsArgs = mkOption { 16 + type = types.attrsOf types.anything; 17 + default = {}; 18 + }; 19 + tests = mkOption { 20 + type = types.attrsOf types.package; 21 + default = {}; 22 + }; 23 + stableTests = mkOption { 24 + type = types.attrsOf types.package; 25 + default = {}; 26 + }; 27 + }; 28 + }; 29 + }; 30 + 31 + config = { 32 + perSystem = { self', pkgs, config, system, ... }: let 33 + cfg = config.attic.integration-tests; 34 + 35 + vmPkgs = import inputs.nixpkgs ({ 36 + inherit system; 37 + overlays = [ self.overlays.default ]; 38 + } // cfg.nixpkgsArgs); 39 + vmPkgsStable = import inputs.nixpkgs-stable ({ 40 + inherit system; 41 + overlays = [ self.overlays.default ]; 42 + } // cfg.nixpkgsArgs); 43 + 44 + makeIntegrationTests = pkgs: import ../integration-tests { 45 + inherit pkgs; 46 + flake = self; 47 + }; 48 + in { 49 + attic.integration-tests = { 50 + tests = makeIntegrationTests vmPkgs; 51 + stableTests = makeIntegrationTests vmPkgsStable; 52 + }; 53 + 54 + checks = let 55 + tests = cfg.tests; 56 + stableTests = lib.mapAttrs' (name: lib.nameValuePair "stable-${name}") cfg.stableTests; 57 + in lib.optionalAttrs pkgs.stdenv.isLinux (tests // stableTests); 58 + }; 59 + }; 60 + }
+64
flake/nix-versions.nix
··· 1 + { lib, flake-parts-lib, config, ... }: 2 + let 3 + inherit (lib) 4 + mkOption 5 + types 6 + ; 7 + inherit (flake-parts-lib) 8 + mkPerSystemOption 9 + ; 10 + in 11 + { 12 + options = { 13 + perSystem = mkPerSystemOption { 14 + options.attic.nix-versions = { 15 + versions = mkOption { 16 + type = types.attrsOf types.package; 17 + default = {}; 18 + }; 19 + manifestFile = mkOption { 20 + type = types.package; 21 + }; 22 + }; 23 + 24 + options.internalMatrix = mkOption { 25 + type = types.attrsOf (types.attrsOf types.package); 26 + }; 27 + }; 28 + }; 29 + 30 + config = { 31 + flake.internalMatrix = lib.mapAttrs (system: ps: ps.internalMatrix) config.allSystems; 32 + 33 + perSystem = { self', pkgs, config, cranePkgs, ... }: let 34 + cfg = config.attic.nix-versions; 35 + in { 36 + attic.nix-versions = { 37 + versions = { 38 + default = pkgs.nix; 39 + "2.20" = pkgs.nixVersions.nix_2_20; 40 + "2.24" = pkgs.nixVersions.nix_2_24; 41 + }; 42 + 43 + manifestFile = let 44 + manifest = lib.mapAttrs (_: nix: { 45 + inherit nix; 46 + shellHook = '' 47 + export NIX_INCLUDE_PATH="${lib.getDev nix}/include" 48 + export NIX_CFLAGS_COMPILE="-isystem $NIX_INCLUDE_PATH $NIX_CFLAGS_COMPILE" 49 + export NIX_LDFLAGS="-L${nix}/lib $NIX_LDFLAGS" 50 + export PKG_CONFIG_PATH="${lib.getDev nix}/lib/pkgconfig:$PKG_CONFIG_PATH" 51 + export PATH="${lib.getBin nix}/bin:$PATH" 52 + ''; 53 + }) cfg.versions; 54 + in pkgs.writeText "nix-versions.json" (builtins.toJSON manifest); 55 + }; 56 + 57 + internalMatrix = lib.mapAttrs (_: nix: let 58 + cranePkgs' = cranePkgs.override { inherit nix; }; 59 + in { 60 + inherit (cranePkgs') attic-tests cargoArtifacts; 61 + }) cfg.versions; 62 + }; 63 + }; 64 + }
+16
flake/nixos.nix
··· 1 + { config, ... }: 2 + { 3 + flake.nixosModules = { 4 + atticd = { 5 + imports = [ 6 + ../nixos/atticd.nix 7 + ]; 8 + 9 + services.atticd.useFlakeCompatOverlay = false; 10 + 11 + nixpkgs.overlays = [ 12 + config.flake.overlays.default 13 + ]; 14 + }; 15 + }; 16 + }
+14
flake/overlays.nix
··· 1 + { makeCranePkgs, ... }: 2 + { 3 + flake.overlays = { 4 + default = final: prev: let 5 + cranePkgs = makeCranePkgs final; 6 + in { 7 + inherit (cranePkgs) 8 + attic 9 + attic-client 10 + attic-server 11 + ; 12 + }; 13 + }; 14 + }
+96
flake/packages.nix
··· 1 + { self, inputs, lib, ... }: 2 + let 3 + makeCranePkgs = pkgs: let 4 + craneLib = inputs.crane.mkLib pkgs; 5 + in pkgs.callPackage ../crane.nix { inherit craneLib; }; 6 + in 7 + { 8 + _module.args.makeCranePkgs = makeCranePkgs; 9 + 10 + perSystem = { self', pkgs, cranePkgs, ... }: (lib.mkMerge [ 11 + { 12 + _module.args.cranePkgs = makeCranePkgs pkgs; 13 + 14 + packages = { 15 + default = self'.packages.attic; 16 + 17 + inherit (cranePkgs) 18 + attic 19 + attic-client 20 + attic-server 21 + ; 22 + 23 + attic-nixpkgs = pkgs.callPackage ../package.nix { }; 24 + 25 + attic-ci-installer = pkgs.callPackage ../ci-installer.nix { 26 + inherit self; 27 + }; 28 + 29 + book = pkgs.callPackage ../book { 30 + attic = self'.packages.attic; 31 + }; 32 + }; 33 + } 34 + 35 + (lib.mkIf pkgs.stdenv.isLinux { 36 + packages = { 37 + attic-server-image = pkgs.dockerTools.buildImage { 38 + name = "attic-server"; 39 + tag = "main"; 40 + copyToRoot = [ 41 + self'.packages.attic-server 42 + 43 + # Debugging utilities for `fly ssh console` 44 + pkgs.busybox 45 + 46 + # Now required by the fly.io sshd 47 + pkgs.dockerTools.fakeNss 48 + ]; 49 + config = { 50 + Entrypoint = [ "${self'.packages.attic-server}/bin/atticd" ]; 51 + Env = [ 52 + "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" 53 + ]; 54 + }; 55 + }; 56 + }; 57 + }) 58 + 59 + # Unfortunately, x86_64-darwin fails to evaluate static builds 60 + (lib.mkIf (pkgs.system != "x86_64-darwin") { 61 + packages = { 62 + # TODO: Make this work with Crane 63 + attic-static = (pkgs.pkgsStatic.callPackage ../package.nix { 64 + nix = pkgs.pkgsStatic.nix.overrideAttrs (old: { 65 + patches = (old.patches or []) ++ [ 66 + # To be submitted 67 + (pkgs.fetchpatch { 68 + url = "https://github.com/NixOS/nix/compare/3172c51baff5c81362fcdafa2e28773c2949c660...6b09a02536d5946458b537dfc36b7d268c9ce823.diff"; 69 + hash = "sha256-LFLq++J2XitEWQ0o57ihuuUlYk2PgUr11h7mMMAEe3c="; 70 + }) 71 + ]; 72 + }); 73 + }).overrideAttrs (old: { 74 + nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ 75 + pkgs.nukeReferences 76 + ]; 77 + 78 + # Read by pkg_config crate (do some autodetection in build.rs?) 79 + PKG_CONFIG_ALL_STATIC = "1"; 80 + 81 + "NIX_CFLAGS_LINK_${pkgs.pkgsStatic.stdenv.cc.suffixSalt}" = "-lc"; 82 + RUSTFLAGS = "-C relocation-model=static"; 83 + 84 + postFixup = (old.postFixup or "") + '' 85 + rm -f $out/nix-support/propagated-build-inputs 86 + nuke-refs $out/bin/attic 87 + ''; 88 + }); 89 + 90 + attic-client-static = self'.packages.attic-static.override { 91 + clientOnly = true; 92 + }; 93 + }; 94 + }) 95 + ]); 96 + }
+43
justfile
··· 1 + set positional-arguments 2 + 3 + here := env_var_or_default("JUST_INVOCATION_DIR", invocation_directory()) 4 + base := `pwd` 5 + 6 + #@echo "here: {{ here }}" 7 + #@echo "base: {{ base }}" 8 + 9 + # List available targets 10 + list: 11 + @just --list --unsorted 12 + 13 + # Run a command with an alternative Nix version 14 + with-nix version *command: 15 + set -e; \ 16 + hook="$(jq -e -r '.[$version].shellHook' --arg version "{{ version }}" < "$NIX_VERSIONS" || (>&2 echo "Version {{ version }} doesn't exist"; exit 1))"; \ 17 + eval "$hook"; \ 18 + CARGO_TARGET_DIR="{{ base }}/target/nix-{{ version }}" \ 19 + {{ command }} 20 + 21 + # (CI) Build WebAssembly crates 22 + ci-build-wasm: 23 + #!/usr/bin/env bash 24 + set -euxo pipefail 25 + 26 + # https://github.com/rust-lang/rust/issues/122357 27 + export RUST_MIN_STACK=16777216 28 + 29 + pushd attic 30 + cargo build --target wasm32-unknown-unknown --no-default-features -F chunking -F stream 31 + popd 32 + pushd token 33 + cargo build --target wasm32-unknown-unknown 34 + popd 35 + 36 + # (CI) Run unit tests 37 + ci-unit-tests matrix: 38 + #!/usr/bin/env bash 39 + set -euxo pipefail 40 + 41 + system=$(nix-instantiate --eval -E 'builtins.currentSystem') 42 + tests=$(nix build .#internalMatrix."$system".\"{{ matrix }}\".attic-tests --no-link --print-out-paths -L) 43 + find "$tests/bin" -exec {} \;