mirror of
https://github.com/NotAShelf/stash.git
synced 2026-04-12 22:17:41 +00:00
Merge pull request #11 from Rexcrazy804/nix-incremental
nix: incremental builds with crane
This commit is contained in:
commit
dd1c3b22da
4 changed files with 84 additions and 18 deletions
19
.github/workflows/nix-cache.yaml
vendored
Normal file
19
.github/workflows/nix-cache.yaml
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
name: "Populate cachix cache"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [ master ]
|
||||
paths: [ 'src/**.rs', 'Cargo.toml', 'Cargo.lock', 'nix/package.nix' ]
|
||||
jobs:
|
||||
populate-cache:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
- uses: cachix/cachix-action@v14
|
||||
with:
|
||||
name: nyx
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
- run: nix build
|
||||
16
flake.lock
generated
16
flake.lock
generated
|
|
@ -1,5 +1,20 @@
|
|||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1754269165,
|
||||
"narHash": "sha256-0tcS8FHd4QjbCVoxN9jI+PjHgA4vc/IjkUSp+N3zy0U=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "444e81206df3f7d92780680e45858e31d2f07a08",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1754725699,
|
||||
|
|
@ -18,6 +33,7 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,20 @@
|
|||
{
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
||||
inputs.crane.url = "github:ipetkov/crane";
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
crane,
|
||||
}: let
|
||||
systems = ["x86_64-linux" "aarch64-linux"];
|
||||
forEachSystem = nixpkgs.lib.genAttrs systems;
|
||||
pkgsForEach = nixpkgs.legacyPackages;
|
||||
in {
|
||||
packages = forEachSystem (system: {
|
||||
default = pkgsForEach.${system}.callPackage ./nix/package.nix {};
|
||||
default = pkgsForEach.${system}.callPackage ./nix/package.nix {
|
||||
craneLib = crane.mkLib pkgsForEach.${system};
|
||||
};
|
||||
});
|
||||
|
||||
devShells = forEachSystem (system: {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
{
|
||||
lib,
|
||||
rustPlatform,
|
||||
}:
|
||||
rustPlatform.buildRustPackage (finalAttrs: {
|
||||
craneLib,
|
||||
runCommandNoCCLocal,
|
||||
}: let
|
||||
inherit (craneLib) buildDepsOnly buildPackage mkDummySrc;
|
||||
|
||||
pname = "stash";
|
||||
version = (builtins.fromTOML (builtins.readFile ../Cargo.toml)).package.version;
|
||||
|
||||
src = let
|
||||
fs = lib.fileset;
|
||||
s = ../.;
|
||||
|
|
@ -19,18 +20,44 @@ rustPlatform.buildRustPackage (finalAttrs: {
|
|||
];
|
||||
};
|
||||
|
||||
cargoLock.lockFile = "${finalAttrs.src}/Cargo.lock";
|
||||
enableParallelBuilding = true;
|
||||
# basically avoid crane rebuilding everything
|
||||
# when the package version changes
|
||||
replacedSrc = let
|
||||
rgxIn = ''
|
||||
name = "${pname}"
|
||||
version = "${version}"
|
||||
'';
|
||||
rgxOut = ''
|
||||
name = "${pname}"
|
||||
version = "0.9.6"
|
||||
'';
|
||||
in
|
||||
runCommandNoCCLocal "bakaSrc" {} ''
|
||||
cp -r ${src} $out
|
||||
substituteInPlace $out/Cargo.toml \
|
||||
--replace-fail '${rgxIn}' '${rgxOut}'
|
||||
substituteInPlace $out/Cargo.lock \
|
||||
--replace-fail '${rgxIn}' '${rgxOut}'
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out
|
||||
install -Dm755 ${../vendor/stash.service} $out/share/stash.service
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Wayland clipboard manager with fast persistent history and multi-media support";
|
||||
maintainers = [lib.maintainers.NotAShelf];
|
||||
license = lib.licenses.mpl20;
|
||||
mainProgram = "stash";
|
||||
cargoArtifacts = buildDepsOnly {
|
||||
name = "${pname}-deps";
|
||||
strictDeps = true;
|
||||
dummySrc = mkDummySrc {src = replacedSrc;};
|
||||
};
|
||||
})
|
||||
in
|
||||
buildPackage {
|
||||
inherit cargoArtifacts pname src version;
|
||||
strictDeps = true;
|
||||
postInstall = ''
|
||||
mkdir -p $out
|
||||
install -Dm755 ${../vendor/stash.service} $out/share/stash.service
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Wayland clipboard manager with fast persistent history and multi-media support";
|
||||
maintainers = [lib.maintainers.NotAShelf];
|
||||
license = lib.licenses.mpl20;
|
||||
mainProgram = "stash";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue