-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
80 lines (73 loc) · 2.44 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{
description = "Good old-fashioned AI search for a variation of Lights out game implemented in rust";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
crate2nix = {
url = "github:kolloch/crate2nix";
flake = false;
};
};
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix, ... }:
let
# If you change the name here, you must also do it in Cargo.toml
name = "jade-swarm";
rustChannel = "stable";
in
utils.lib.eachSystem ["x86_64-linux"]
(system:
let
# Imports
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlay
(self: super: {
# Because rust-overlay bundles multiple rust packages into one
# derivation, specify that mega-bundle here, so that crate2nix
# will use them automatically.
rustc = self.rust-bin.${rustChannel}.latest.default;
cargo = self.rust-bin.${rustChannel}.latest.default;
})
];
};
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; }) generatedCargoNix;
# Create the cargo2nix project
project = import (generatedCargoNix {
inherit name;
src = ./.;
})
{
inherit pkgs;
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
${name} = oldAttrs: {
inherit buildInputs nativeBuildInputs;
};
};
};
# Configuration for the non-Rust dependencies
buildInputs = with pkgs; [ ];
nativeBuildInputs = with pkgs; [ rustc cargo ];
in
rec {
packages.${name} = project.rootCrate.build;
# `nix build`
defaultPackage = packages.${name};
# `nix run`
apps.${name} = utils.lib.mkApp {
inherit name;
drv = packages.${name};
};
defaultApp = apps.${name};
# `nix develop`
devShell = pkgs.mkShell {
inputsFrom = builtins.attrValues self.packages.${system};
buildInputs = buildInputs ++ (with pkgs;
# Tools you need for development go here.
[
]);
RUST_SRC_PATH = "${pkgs.rust-bin.${rustChannel}.latest.rust-src}/lib/rustlib/src/rust/library";
};
});
}