Skip to content

Commit fdeb5b3

Browse files
authored
Add nix flake (#30)
* an attempt * fix build
1 parent 83af1bb commit fdeb5b3

File tree

4 files changed

+178
-1
lines changed

4 files changed

+178
-1
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,4 +353,7 @@ MigrationBackup/
353353
/target
354354

355355
# vscode
356-
/.vscode
356+
/.vscode
357+
358+
# nix
359+
/result

flake.lock

Lines changed: 82 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: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
4+
utils.url = "github:numtide/flake-utils";
5+
rust-overlay = {
6+
url = "github:oxalica/rust-overlay";
7+
inputs.nixpkgs.follows = "nixpkgs";
8+
};
9+
};
10+
outputs =
11+
{
12+
self,
13+
nixpkgs,
14+
utils,
15+
rust-overlay,
16+
}:
17+
utils.lib.eachDefaultSystem (
18+
system:
19+
let
20+
pkgs = import nixpkgs {
21+
inherit system;
22+
overlays = [ (import rust-overlay) ];
23+
crossSystem = {
24+
config = "x86_64-w64-mingw32";
25+
libc = "msvcrt";
26+
};
27+
config.allowUnsupportedSystem = true;
28+
};
29+
30+
toolchain = (pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml);
31+
in
32+
{
33+
formatter = (import nixpkgs { inherit system; }).nixfmt-rfc-style;
34+
35+
packages = {
36+
discordrpc =
37+
pkgs.callPackage
38+
(
39+
{
40+
lib,
41+
rustPlatform,
42+
rust-bin,
43+
}:
44+
rustPlatform.buildRustPackage (final: {
45+
name = "DiscordRPC";
46+
version = "13.0.0";
47+
48+
rustToolchain = rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
49+
nativeBuildInputs = [
50+
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
51+
];
52+
53+
src = ./.;
54+
55+
meta = {
56+
description = "discord rpc impl for northstar";
57+
homepage = "https://github.com/R2Northstar/NorthstarDiscordRPC";
58+
license = lib.licenses.unlicense;
59+
maintainers = [ "cat_or_not" ];
60+
};
61+
62+
cargoLock = {
63+
lockFile = ./Cargo.lock;
64+
};
65+
})
66+
)
67+
{
68+
rust-bin = rust-overlay.lib.mkRustBin { } pkgs.buildPackages;
69+
};
70+
71+
default = self.packages.${system}.discordrpc;
72+
};
73+
74+
devShell = pkgs.mkShell {
75+
buildInputs = with pkgs; [
76+
windows.mingw_w64_headers
77+
# windows.mcfgthreads
78+
windows.pthreads
79+
toolchain
80+
];
81+
82+
nativeBuildInputs = [
83+
toolchain
84+
];
85+
};
86+
}
87+
);
88+
}

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "stable"
3+
components = [ "rustfmt", "rust-analyzer", "clippy", "rust-src", "rust-std", "rust-docs", "rustc" ]
4+
targets = [ "x86_64-pc-windows-gnu" ]

0 commit comments

Comments
 (0)