1
0
Fork 0
mirror of https://codeberg.org/icewind/shelve.git synced 2026-06-03 20:14:08 +02:00

flake reorg + updates

This commit is contained in:
Robin Appelman 2024-12-01 17:29:24 +01:00
commit bde8457b34
12 changed files with 483 additions and 630 deletions

View file

@ -1,104 +1,17 @@
on: [push, pull_request] name: "CI"
on:
name: Continuous integration pull_request:
push:
jobs: jobs:
check: checks:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: cachix/install-nix-action@v20 - uses: cachix/install-nix-action@v26
- uses: icewind1991/attic-action@v1 - uses: icewind1991/attic-action@v1
with: with:
name: ci name: ci
instance: https://cache.icewind.me instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}' authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix build .#check - run: nix flake check --keep-going
clippy:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#clippy
msrv:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#msrv
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- id: set-matrix
run: echo "matrix=$(nix eval --json ".#matrix.x86_64-linux")" | tee $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: [check, matrix]
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#${{ matrix.target }}
- uses: actions/upload-artifact@v3
with:
name: shelve-${{ matrix.target }}
path: result/bin/shelve${{ matrix.artifactSuffix }}
build-nixpkgs:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#shelve
docker:
runs-on: ubuntu-latest
needs: build-nixpkgs
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#docker
- name: Push image
if: github.ref == 'refs/heads/master'
run: |
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://icewind1991/shelve"

677
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,17 +4,17 @@ version = "0.1.0"
authors = ["Robin Appelman <robin@icewind.nl>"] authors = ["Robin Appelman <robin@icewind.nl>"]
edition = "2018" edition = "2018"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
rust-version = "1.69.0" rust-version = "1.70.0"
[dependencies] [dependencies]
rocket = "0.5.0" rocket = "0.5.1"
priority-queue = "1.3.2" priority-queue = "2.1.1"
dotenvy = "0.15.7" dotenvy = "0.15.7"
thiserror = "1.0.51" thiserror = "2.0.3"
rand = "0.8.5" rand = "0.8.5"
uuid = { version = "1.6.1", features = ["serde", "v4"] } uuid = { version = "1.11.0", features = ["serde", "v4"] }
rust-embed = "8.1.0" rust-embed = "8.4.0"
serde = "1.0.193" serde = "1.0.215"
serde_json = "1.0.108" serde_json = "1.0.133"
async-trait = "0.1.75" async-trait = "0.1.83"
futures-util = "0.3.30" futures-util = "0.3.31"

View file

@ -12,8 +12,8 @@ Upload tokens are configured by setting the `TOKENS` environment variable to a c
Licensed under either of Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) - Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) - MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
at your option. at your option.

View file

@ -1,6 +1,6 @@
{ { dockerTools
dockerTools, , shelve
shelve, ,
}: }:
dockerTools.buildLayeredImage { dockerTools.buildLayeredImage {
name = "icewind1991/shelve"; name = "icewind1991/shelve";

136
flake.lock generated
View file

@ -1,105 +1,98 @@
{ {
"nodes": { "nodes": {
"cross-naersk": { "crane": {
"locked": {
"lastModified": 1730060262,
"narHash": "sha256-RMgSVkZ9H03sxC+Vh4jxtLTCzSjPq18UWpiM0gq6shQ=",
"owner": "ipetkov",
"repo": "crane",
"rev": "498d9f122c413ee1154e8131ace5a35a80d8fa76",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flakelight": {
"inputs": { "inputs": {
"naersk": [ "nixpkgs": [
"naersk" "nixpkgs"
]
},
"locked": {
"lastModified": 1732697024,
"narHash": "sha256-GcLauDQQI4xO4vy3e2QxPneR86FsJ1ubAbFDlTyEZ9s=",
"owner": "nix-community",
"repo": "flakelight",
"rev": "1af817b5987e78b7a260dff6d62793716b98d794",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "flakelight",
"type": "github"
}
},
"mill-scale": {
"inputs": {
"crane": "crane",
"flakelight": [
"flakelight"
], ],
"nixpkgs": [ "rust-overlay": "rust-overlay"
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1689107909, "lastModified": 1732306573,
"narHash": "sha256-fb+zxf7AWesECHx1foXOM3NcKHLrdeXzGb6s2AhT6pE=", "narHash": "sha256-wE12kIIE0qb9V9y0JiVm5RsRrMNX+KeeMwkzwefdHhY=",
"owner": "icewind1991", "owner": "icewind1991",
"repo": "cross-naersk", "repo": "mill-scale",
"rev": "51de54599de569e6faa2ee33dd659c5c028d9911", "rev": "8b4cbf174a9728d7e58bbfde5b5a6685dcbf1015",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "icewind1991", "owner": "icewind1991",
"repo": "cross-naersk", "repo": "mill-scale",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1698420672,
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
"owner": "nix-community",
"repo": "naersk",
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1704420045, "lastModified": 1732981179,
"narHash": "sha256-C36QmoJd5tdQ5R9MC1jM7fBkZW9zBUqbUCsgwS6j4QU=", "narHash": "sha256-F7thesZPvAMSwjRu0K8uFshTk3ZZSNAsXTIFvXBT+34=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c1be43e8e837b8dbee2b3665a007e761680f0c3d", "rev": "62c435d93bf046a5396f3016472e8f7c8e2aed65",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "nixos-23.11", "ref": "nixos-24.11",
"type": "indirect" "type": "indirect"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"cross-naersk": "cross-naersk", "flakelight": "flakelight",
"flake-utils": "flake-utils", "mill-scale": "mill-scale",
"naersk": "naersk", "nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [ "nixpkgs": [
"mill-scale",
"flakelight",
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1704507282, "lastModified": 1731897198,
"narHash": "sha256-PDfS8fj40mm2QWpbd/aiocgwcI/WHzqLKERRJkoEvXU=", "narHash": "sha256-Ou7vLETSKwmE/HRQz4cImXXJBr/k9gp4J4z/PF8LzTE=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "a127cccf7943beae944953963ba118d643299c3b", "rev": "0be641045af6d8666c11c2c40e45ffc9667839b5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -107,21 +100,6 @@
"repo": "rust-overlay", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

128
flake.nix
View file

@ -1,118 +1,32 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-23.11"; nixpkgs.url = "nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils"; flakelight = {
naersk.url = "github:nix-community/naersk"; url = "github:nix-community/flakelight";
naersk.inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.inputs.flake-utils.follows = "flake-utils";
cross-naersk.url = "github:icewind1991/cross-naersk";
cross-naersk.inputs.nixpkgs.follows = "nixpkgs";
cross-naersk.inputs.naersk.follows = "naersk";
}; };
mill-scale = {
outputs = { url = "github:icewind1991/mill-scale";
self, inputs.flakelight.follows = "flakelight";
nixpkgs, };
flake-utils, };
naersk, outputs = { mill-scale, ... }: mill-scale ./. {
rust-overlay, extraPaths = [
cross-naersk, ./templates
}:
flake-utils.lib.eachDefaultSystem (
system: let
overlays = [
(import rust-overlay)
(import ./overlay.nix)
]; ];
pkgs = (import nixpkgs) { nixosModules = { outputs, ... }: {
inherit system overlays; default =
}; { pkgs
inherit (pkgs) lib callPackage rust-bin mkShell; , config
inherit (lib.sources) sourceByRegex; , lib
inherit (builtins) fromTOML readFile map; , ...
msrv = (fromTOML (readFile ./Cargo.toml)).package.rust-version;
toolchain = rust-bin.stable.latest.default;
msrvToolchain = rust-bin.stable."${msrv}".default;
naersk' = callPackage naersk {
rustc = toolchain;
cargo = toolchain;
};
msrvNaersk = callPackage naersk {
rustc = msrvToolchain;
cargo = msrvToolchain;
};
cross-naersk' = pkgs.callPackage cross-naersk {inherit naersk;};
buildMatrix = targets: {
include =
map (target: {
inherit target;
artifactSuffix = cross-naersk'.execSufficForTarget target;
})
targets;
};
hostTarget = pkgs.hostPlatform.config;
targets = [
"x86_64-unknown-linux-musl"
"x86_64-pc-windows-gnu"
hostTarget
];
releaseTargets = lib.lists.remove hostTarget targets;
src = sourceByRegex ./. ["Cargo.*" "(src|templates)(/.*)?"];
nearskOpt = {
pname = "shelve";
root = src;
};
in rec {
packages =
lib.attrsets.genAttrs targets (target:
(cross-naersk'.buildPackage target) nearskOpt)
// {
shelve = pkgs.shelve;
check = naersk'.buildPackage (nearskOpt
// {
mode = "check";
});
clippy = naersk'.buildPackage (nearskOpt
// {
mode = "clippy";
});
msrv = msrvNaersk.buildPackage (nearskOpt
// {
mode = "check";
});
docker = callPackage ./docker.nix {};
default = pkgs.shelve;
};
apps.default = packages.default;
matrix = buildMatrix targets;
releaseMatrix = buildMatrix releaseTargets;
devShells.default = mkShell {
nativeBuildInputs = with pkgs; [toolchain bacon cargo-msrv];
};
}
)
// {
overlays.default = import ./overlay.nix;
nixosModules.default = {
pkgs,
config,
lib,
...
}: { }: {
imports = [./module.nix]; imports = [ ./nix/module.nix ];
config = lib.mkIf config.services.shelve.enable { config = lib.mkIf config.services.shelve.enable {
nixpkgs.overlays = [self.overlays.default]; nixpkgs.overlays = [ outputs.overlays.default ];
services.shelve.package = lib.mkDefault pkgs.shelve; services.shelve.package = lib.mkDefault pkgs.shelve;
}; };
}; };
}; };
};
} }

View file

@ -1,12 +1,12 @@
{ { config
config, , lib
lib, , pkgs
pkgs, , ...
...
}: }:
with lib; let with lib; let
cfg = config.services.shelve; cfg = config.services.shelve;
in { in
{
options.services.shelve = { options.services.shelve = {
enable = mkEnableOption "Enables the shelve service"; enable = mkEnableOption "Enables the shelve service";

3
nix/overlay.nix Normal file
View file

@ -0,0 +1,3 @@
final: prev: {
shelve = final.callPackage ./package.nix { };
}

21
nix/package.nix Normal file
View file

@ -0,0 +1,21 @@
{ stdenv
, rustPlatform
, lib
,
}:
let
inherit (lib.sources) sourceByRegex;
inherit (builtins) fromTOML readFile;
src = sourceByRegex ../. [ "Cargo.*" "(src|templates)(/.*)?" ];
cargoPackage = (fromTOML (readFile ../Cargo.toml)).package;
in
rustPlatform.buildRustPackage rec {
pname = cargoPackage.name;
inherit (cargoPackage) version;
inherit src;
cargoLock = {
lockFile = ../Cargo.lock;
};
}

View file

@ -1,3 +0,0 @@
final: prev: {
shelve = final.callPackage ./package.nix {};
}

View file

@ -1,18 +0,0 @@
{
stdenv,
rustPlatform,
lib,
}: let
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. ["Cargo.*" "(src|templates)(/.*)?"];
in
rustPlatform.buildRustPackage rec {
pname = "shelve";
version = "0.1.0";
inherit src;
cargoLock = {
lockFile = ./Cargo.lock;
};
}