Skip to content

Commit 207eea0

Browse files
committed
feat: nix packaging
1 parent 0f46e8e commit 207eea0

File tree

5 files changed

+108
-0
lines changed

5 files changed

+108
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/target
22
**/*.rs.bk
33
.vscode
4+
# nix build artifacts
5+
result/

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
3+
4+
outputs = {
5+
self,
6+
nixpkgs,
7+
}: let
8+
systems = ["x86_64-linux" "aarch64-linux"];
9+
forEachSystem = nixpkgs.lib.genAttrs systems;
10+
pkgsForEach = nixpkgs.legacyPackages;
11+
in {
12+
packages = forEachSystem (system: {
13+
default = pkgsForEach.${system}.callPackage ./nix/package.nix {};
14+
});
15+
16+
devShells = forEachSystem (system: {
17+
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {};
18+
});
19+
20+
hydraJobs = self.packages;
21+
};
22+
}

nix/package.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
lib,
3+
rustPlatform,
4+
pkg-config,
5+
openssl,
6+
}: let
7+
fs = lib.fileset;
8+
in
9+
rustPlatform.buildRustPackage (finalAttrs: {
10+
pname = "mpd-discord-rpc";
11+
version = (builtins.fromTOML (builtins.readFile ../Cargo.toml)).package.version;
12+
13+
src = fs.toSource {
14+
root = ../.;
15+
fileset = fs.unions [
16+
(fs.fileFilter (file: builtins.any file.hasExt ["rs"]) ../src)
17+
../Cargo.lock
18+
../Cargo.toml
19+
];
20+
};
21+
22+
nativeBuildInputs = [pkg-config];
23+
buildInputs = [openssl];
24+
25+
cargoLock.lockFile = "${finalAttrs.src}/Cargo.lock";
26+
enableParallelBuilding = true;
27+
28+
meta = {
29+
description = "Displays your currently playing song / album / artist from MPD in Discord";
30+
homepage = "https://github.com/JakeStanger/mpd-discord-rpc";
31+
license = lib.licenses.mit;
32+
platforms = lib.platforms.linux;
33+
maintainers = lib.maintainers.fazzi;
34+
mainProgram = "mpd-discord-rpc";
35+
};
36+
})

nix/shell.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
mkShell,
3+
rust-analyzer,
4+
rustfmt,
5+
rustc,
6+
clippy,
7+
cargo,
8+
rustPlatform,
9+
}:
10+
mkShell {
11+
name = "rust";
12+
packages = [
13+
rust-analyzer
14+
rustfmt
15+
clippy
16+
cargo
17+
rustc
18+
];
19+
20+
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
21+
}

0 commit comments

Comments
 (0)