-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
103 lines (90 loc) · 2.89 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
description = "Minecraft server in Nix";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
import-cargo.url = github:edolstra/import-cargo;
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, import-cargo, flake-utils }:
{
overlays = rec {
mineflake = final: prev: {
mineflake = import ./pkgs {
pkgs = prev;
lib = prev.lib;
inherit (import-cargo.builders) importCargo;
};
};
mineflakeWithCustomAttrs = attrs: final: prev: {
mineflake = import ./pkgs ({
pkgs = prev;
lib = prev.lib;
inherit (import-cargo.builders) importCargo;
} // attrs);
};
default = mineflake;
};
templates = rec {
docker = {
path = ./templates/docker;
description = "An example of a mineflake docker container";
welcomeText = ''
This is an example of a mineflake docker container.
You can use it to deploy your own minecraft server
on any machine that supports Docker.
To use it, run:
$ nix build .
$ docker load < result
$ docker run --rm -it -p 25565:25565 mineflake
Then, edit the docker.nix file to your liking.
'';
};
default = docker;
};
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
overlay = (self.overlays.default pkgs pkgs).mineflake;
in
{
devShells.default = import ./shell.nix { inherit pkgs; };
packages =
let
buildInputs = builtins.filter (p: p ? outPath) (builtins.attrValues overlay);
namedInputs =
builtins.listToAttrs
(builtins.map
(p:
{
name = p;
value = builtins.getAttr p overlay;
})
(builtins.filter
(p: (builtins.getAttr p overlay) ? outPath)
(builtins.attrNames overlay)
)
);
in
(overlay // {
# This is a hack to get the buildInputs of the overlay
# Used for caching on cachix
default = pkgs.stdenv.mkDerivation {
name = "all";
src = ./.;
buildInputs = buildInputs;
installPhase = "mkdir -p $out; cp ${pkgs.writeText "packages" (builtins.toJSON namedInputs)} $out/buildInputs";
};
});
apps = rec {
mineflake = {
type = "app";
program = "${overlay.mineflake}/bin/mineflake";
};
default = mineflake;
};
}
);
}