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": {
|
"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": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1754725699,
|
"lastModified": 1754725699,
|
||||||
|
|
@ -18,6 +33,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,20 @@
|
||||||
{
|
{
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
||||||
|
inputs.crane.url = "github:ipetkov/crane";
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
self,
|
self,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
|
crane,
|
||||||
}: let
|
}: let
|
||||||
systems = ["x86_64-linux" "aarch64-linux"];
|
systems = ["x86_64-linux" "aarch64-linux"];
|
||||||
forEachSystem = nixpkgs.lib.genAttrs systems;
|
forEachSystem = nixpkgs.lib.genAttrs systems;
|
||||||
pkgsForEach = nixpkgs.legacyPackages;
|
pkgsForEach = nixpkgs.legacyPackages;
|
||||||
in {
|
in {
|
||||||
packages = forEachSystem (system: {
|
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: {
|
devShells = forEachSystem (system: {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
rustPlatform,
|
craneLib,
|
||||||
}:
|
runCommandNoCCLocal,
|
||||||
rustPlatform.buildRustPackage (finalAttrs: {
|
}: let
|
||||||
|
inherit (craneLib) buildDepsOnly buildPackage mkDummySrc;
|
||||||
|
|
||||||
pname = "stash";
|
pname = "stash";
|
||||||
version = (builtins.fromTOML (builtins.readFile ../Cargo.toml)).package.version;
|
version = (builtins.fromTOML (builtins.readFile ../Cargo.toml)).package.version;
|
||||||
|
|
||||||
src = let
|
src = let
|
||||||
fs = lib.fileset;
|
fs = lib.fileset;
|
||||||
s = ../.;
|
s = ../.;
|
||||||
|
|
@ -19,18 +20,44 @@ rustPlatform.buildRustPackage (finalAttrs: {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoLock.lockFile = "${finalAttrs.src}/Cargo.lock";
|
# basically avoid crane rebuilding everything
|
||||||
enableParallelBuilding = true;
|
# 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 = ''
|
cargoArtifacts = buildDepsOnly {
|
||||||
mkdir -p $out
|
name = "${pname}-deps";
|
||||||
install -Dm755 ${../vendor/stash.service} $out/share/stash.service
|
strictDeps = true;
|
||||||
'';
|
dummySrc = mkDummySrc {src = replacedSrc;};
|
||||||
|
|
||||||
meta = {
|
|
||||||
description = "Wayland clipboard manager with fast persistent history and multi-media support";
|
|
||||||
maintainers = [lib.maintainers.NotAShelf];
|
|
||||||
license = lib.licenses.mpl20;
|
|
||||||
mainProgram = "stash";
|
|
||||||
};
|
};
|
||||||
})
|
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