build(nix): add a flake
nix run github:michel/soulseek-rs/master builds the release branch and /develop the nightly. The lock is not optional: without one nix refuses a github: reference outright and hides the commit from the build, so the version stamp read +dirty.
This commit is contained in:
@@ -3,6 +3,8 @@ name: Packaging
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'flake.nix'
|
||||
- 'flake.lock'
|
||||
- 'Cargo.lock'
|
||||
- 'Cargo.toml'
|
||||
- 'packaging/**'
|
||||
@@ -65,3 +67,21 @@ jobs:
|
||||
rpm -ql soulseek-rs | grep -Fx /usr/share/man/man1/soulseek-rs.1.gz
|
||||
rpm -ql soulseek-rs | grep -Fx /usr/share/zsh/site-functions/_soulseek-rs
|
||||
"
|
||||
|
||||
flake:
|
||||
name: Nix flake
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- uses: cachix/install-nix-action@v31
|
||||
|
||||
- name: Build and run
|
||||
run: |
|
||||
nix build --print-build-logs
|
||||
./result/bin/soulseek-rs --version | grep -E '\+git[0-9]{12}\.[0-9a-f]{7}$'
|
||||
test -s result/share/man/man1/soulseek-rs.1.gz
|
||||
test -s result/share/fish/vendor_completions.d/soulseek-rs.fish
|
||||
|
||||
Generated
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1789785513,
|
||||
"narHash": "sha256-B44WL6h0XoLjJ41bUPJk0X5SDinLCII//6EcBLXKiJ0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "20b1ddd1aa5ace70c9468305030aa4f9ef79671b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
description = "Soulseek client for the terminal, with a scriptable CLI and daemon";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
version = (lib.importTOML ./Cargo.toml).workspace.package.version;
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
in
|
||||
{
|
||||
packages = lib.genAttrs systems (system: {
|
||||
default = nixpkgs.legacyPackages.${system}.callPackage (
|
||||
{ rustPlatform, installShellFiles }:
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "soulseek-rs";
|
||||
inherit version;
|
||||
src = self;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
cargoBuildFlags = [
|
||||
"--package"
|
||||
"soulseek-rs"
|
||||
];
|
||||
doCheck = false;
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
env.SOULSEEK_RS_VERSION = "${version}+git${lib.substring 0 12 self.lastModifiedDate}.${self.shortRev or "dirty"}";
|
||||
postInstall = ''
|
||||
installShellCompletion --cmd soulseek-rs \
|
||||
--bash <($out/bin/soulseek-rs completions print bash) \
|
||||
--zsh <($out/bin/soulseek-rs completions print zsh) \
|
||||
--fish <($out/bin/soulseek-rs completions print fish)
|
||||
$out/bin/soulseek-rs man > soulseek-rs.1
|
||||
installManPage soulseek-rs.1
|
||||
'';
|
||||
meta = {
|
||||
description = "Soulseek client for the terminal, with a scriptable CLI and daemon";
|
||||
homepage = "https://re-invention.nl/soulseek-rs/";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "soulseek-rs";
|
||||
};
|
||||
}
|
||||
) { };
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user