Compare commits

...
This repository has been archived on 2024-10-13. You can view files and clone it, but cannot push or open issues or pull requests.

8 commits

9 changed files with 13822 additions and 75 deletions

4764
attic/Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

8903
attic/Cargo.nix Normal file

File diff suppressed because it is too large Load diff

11
attic/attic-client.nix Normal file
View file

@ -0,0 +1,11 @@
{
callPackage,
lib,
}:
((callPackage ./common.nix {}).workspace.attic-client {}).overrideAttrs (super: {
meta = with lib; {
description = "nix cache server client";
homepage = "https://docs.attic.rs/";
license = licenses.asl20;
};
})

21
attic/attic-server.nix Normal file
View file

@ -0,0 +1,21 @@
{
callPackage,
lib,
writeScript,
jq,
}:
((callPackage ./common.nix {}).workspace.attic-server {}).overrideAttrs (super: {
meta = with lib; {
attic-client = pkgs.callPackage ./attic/attic-client.nix {};
description = "nix cache server";
homepage = "https://docs.attic.rs/";
license = licenses.asl20;
};
passthru.updateScript = writeScript "update-attic" ''
${../scripts/update-git.sh} https://github.com/zhaofengli/attic attic/source.json
if [ "$(git diff -- attic/source.json)" ]; then
SRC_PATH=$(${jq} -r '.source' attic/source.json)
${../scripts/update-cargo.sh} $SRC_PATH attic/
fi
'';
})

59
attic/common.nix Normal file
View file

@ -0,0 +1,59 @@
{
stdenvNoCC,
rustBuilder,
fetchFromGitHub,
fetchzip,
}: let
sourceJson = builtins.fromJSON (builtins.readFile ./source.json);
source = stdenvNoCC.mkDerivation {
pname = "attic-source";
version = sourceJson.date;
src = fetchFromGitHub {
owner = "zhaofengli";
repo = "attic";
inherit (sourceJson) rev sha256;
};
buildPhase = "true";
installPhase = ''
cp -rv $src $out
chmod -R +w $out
cp ${./Cargo.lock} $out
'';
};
rustCxxHeader = stdenvNoCC.mkDerivation {
pname = "cxx-headers";
version = "1.0.93";
src = fetchzip {
extension = "tar.gz";
url = "https://crates.io/api/v1/crates/cxx/1.0.93/download";
sha256 = "sha256-YRmV+d9EwX5D68paAMgl+nUVPdLtoh2uiAlQB5idUy4=";
};
buildPhase = "";
installPhase = ''
mkdir -p $out/include/rust
cp include/cxx.h $out/include/rust
'';
};
in
rustBuilder.makePackageSet {
rustChannel = "stable";
rustVersion = "latest";
packageOverrides = pkgs: pkgs.rustBuilder.overrides.all ++ [
(pkgs.rustBuilder.rustLib.makeOverride {
name = "attic";
overrideAttrs = drv: {
propagatedBuildInputs = drv.propagatedBuildInputs or [] ++ [
pkgs.nix.dev
pkgs.boost.dev
rustCxxHeader
pkgs.libclang.lib
];
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.nix.dev}/include -I${pkgs.gcc-unwrapped}/include/c++/${pkgs.gcc.version} -I${pkgs.gcc-unwrapped}/include/c++/${pkgs.gcc.version}/${pkgs.targetPlatform.config} -I${pkgs.glibc.dev}/include -I${pkgs.boost.dev}/include -I${pkgs.nlohmann_json}/include -I${pkgs.gcc-unwrapped}/lib/gcc/${pkgs.targetPlatform.config}/${pkgs.gcc.version}/include -I${pkgs.gcc-unwrapped}/lib/gcc/${pkgs.targetPlatform.config}/${pkgs.gcc.version}/include-fixed";
};
})
];
packageFun = import ./Cargo.nix;
workspaceSrc = source;
}

11
attic/source.json Normal file
View file

@ -0,0 +1,11 @@
{
"url": "https://github.com/zhaofengli/attic",
"rev": "4d92e69fc1b279676f997e6b99d2cacc4d0a3e87",
"date": "2023-03-21T18:45:45-06:00",
"path": "/nix/store/wg5x0vm9vcqhxq01a4qll0nh03wb0ynm-attic",
"sha256": "1j3168hfrvblzfsgmn7vzaiah10bw7nghk375qk8kzj02hhm79si",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": false,
"leaveDotGit": false
}

View file

@ -1,8 +1,7 @@
{
"nodes": {
"attic": {
"cargo2nix": {
"inputs": {
"crane": "crane",
"flake-compat": "flake-compat",
"flake-utils": [
"flake-utils"
@ -10,60 +9,33 @@
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
"rust-overlay": [
"rust-overlay"
]
},
"locked": {
"lastModified": 1678041467,
"narHash": "sha256-qqHbiN0ZfEuZ2guMAW5T011TqgrPqGqNWlHtd8AXtQA=",
"owner": "zhaofengli",
"repo": "attic",
"rev": "1a3b6513b02202198bb497608d0cedc45119799b",
"lastModified": 1678094756,
"narHash": "sha256-FoVmeU9ITOhKO/wQt76JMZsIDxfNmzgkqHud6hrHB18=",
"owner": "DarkKirb",
"repo": "cargo2nix",
"rev": "a2c22af726db8fca367865d6631b3f321eadc647",
"type": "github"
},
"original": {
"owner": "zhaofengli",
"repo": "attic",
"type": "github"
}
},
"crane": {
"inputs": {
"flake-compat": [
"attic",
"flake-compat"
],
"flake-utils": [
"attic",
"flake-utils"
],
"nixpkgs": [
"attic",
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1677892403,
"narHash": "sha256-/Wi0L1spSWLFj+UQxN3j0mPYMoc7ZoAujpUF/juFVII=",
"owner": "ipetkov",
"repo": "crane",
"rev": "105e27adb70a9890986b6d543a67761cbc1964a2",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"owner": "DarkKirb",
"ref": "release-0.11.0",
"repo": "cargo2nix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
@ -141,50 +113,31 @@
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1675327819,
"narHash": "sha256-Fd2BUNUsTO7wmoU1fbOC4HNkl370dYdkfKgWPretuj0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "21efc622b939884db3c92f49d638ca89f12f22f8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"attic": "attic",
"cargo2nix": "cargo2nix",
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils",
"mautrix-cleanup": "mautrix-cleanup",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"attic",
"crane",
"flake-utils"
],
"nixpkgs": [
"attic",
"crane",
"nixpkgs"
]
},
"locked": {
"lastModified": 1675391458,
"narHash": "sha256-ukDKZw922BnK5ohL9LhwtaDAdCsJL7L6ScNEyF1lO9w=",
"lastModified": 1679624450,
"narHash": "sha256-wiDqUaklmc31E1+wz5sv52sMcWvZKsL1FBeGJCxz628=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "383a4acfd11d778d5c2efcf28376cbd845eeaedf",
"rev": "afbdcf305fd6f05f708fe76d52f24d37d066c251",
"type": "github"
},
"original": {

View file

@ -2,13 +2,13 @@
description = "Lottes nix packages";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:DarkKirb/flake-utils";
attic = {
url = "github:zhaofengli/attic";
cargo2nix = {
url = "github:DarkKirb/cargo2nix/release-0.11.0";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
};
flake-utils.url = "github:DarkKirb/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
@ -18,6 +18,12 @@
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
nixpkgs.url = "github:NixOS/nixpkgs";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
@ -32,10 +38,9 @@
inherit system;
config.allowUnfree = true;
config.allowUnsupportedSystem = true;
overlays = [inputs.cargo2nix.overlays.default];
};
inherit (pkgs) lib;
nur = import ./default.nix {inherit pkgs;};
packages = lib.filterAttrs (n: _: n != "overlays" && n != "modules" && n != "lib") nur;
in rec {
formatter = pkgs.alejandra;
@ -92,7 +97,8 @@
miifox-net = pkgs.python3Packages.callPackage ./web/miifox-net.nix {};
old-homepage = pkgs.callPackage ./web/old-homepage.nix {};
python-instagram = pkgs.python3Packages.callPackage ./python/instagram.nix {};
inherit (inputs.attic.packages.${pkgs.system}) attic attic-client attic-server;
attic-client = pkgs.callPackage ./attic/attic-client.nix {};
attic-server = pkgs.callPackage ./attic/attic-server.nix {};
element-web = pkgs.callPackage ./matrix/element-web {};
mautrix-cleanup = inputs.mautrix-cleanup.packages.${pkgs.system}.default;
}

19
scripts/update-cargo.sh Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p cargo rustc
SOURCE=$1
WRITE_PATH=$(realpath $2)
SOURCE_EXTRACTED=$(mktemp -du)
cp -r $SOURCE $SOURCE_EXTRACTED
chmod -R +w $SOURCE_EXTRACTED
cd $SOURCE_EXTRACTED
cargo update
yes yes | nix run 'github:DarkKirb/cargo2nix/release-0.11.0'
cp Cargo.lock $WRITE_PATH/Cargo.lock
cp Cargo.nix $WRITE_PATH/Cargo.nix
rm -rf $SOURCE_EXTRACTED