92 lines
2.4 KiB
Nix
92 lines
2.4 KiB
Nix
|
{
|
||
|
description = "Amethyst - Experimental Minecraft server in Elixir";
|
||
|
|
||
|
inputs = {
|
||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||
|
|
||
|
nix-github-actions.url = "github:nix-community/nix-github-actions";
|
||
|
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
|
||
|
|
||
|
systems.url = "github:nix-systems/default";
|
||
|
};
|
||
|
|
||
|
outputs = {
|
||
|
self,
|
||
|
nixpkgs,
|
||
|
systems,
|
||
|
nix-github-actions,
|
||
|
...
|
||
|
} @ inputs: let
|
||
|
inherit (nixpkgs) lib;
|
||
|
|
||
|
# Set the Erlang version
|
||
|
erlangVersion = "erlang_25";
|
||
|
# Set the Elixir version
|
||
|
elixirVersion = "elixir_1_17";
|
||
|
|
||
|
eachSystem = f:
|
||
|
nixpkgs.lib.genAttrs (import systems) (
|
||
|
system:
|
||
|
f (import nixpkgs {
|
||
|
inherit system;
|
||
|
overlays = [
|
||
|
(final: _: let
|
||
|
erlang = final.beam.interpreters.${erlangVersion};
|
||
|
beamPackages = final.beam.packages.${erlangVersion};
|
||
|
elixir = beamPackages.${elixirVersion};
|
||
|
in {
|
||
|
inherit erlang elixir;
|
||
|
inherit (beamPackages) elixir-ls hex;
|
||
|
inherit (beamPackages) mixRelease;
|
||
|
})
|
||
|
];
|
||
|
})
|
||
|
);
|
||
|
|
||
|
#secrets = import ./secrets.nix;
|
||
|
|
||
|
package = env: pkgs: (pkgs.beamPackages.mixRelease {
|
||
|
pname = "amethyst";
|
||
|
version = "0.1.0";
|
||
|
src = ./.;
|
||
|
elixir = pkgs.elixir;
|
||
|
mixEnv = env;
|
||
|
erlangDeterministicBuilds = false; # Technically less pure but allows doctests
|
||
|
removeCookie = false; # Insecure; Access to the file system can allow the cookie to be read and provides remote control of the Erlang VM
|
||
|
mixNixDeps = import ./mix.nix {inherit lib; beamPackages = pkgs.beamPackages;};
|
||
|
}).overrideAttrs (old: {
|
||
|
preInstall = ''
|
||
|
# Run automated tests
|
||
|
mix test --no-deps-check --no-start --color
|
||
|
'';
|
||
|
});
|
||
|
|
||
|
in {
|
||
|
packages = eachSystem (pkgs:
|
||
|
{
|
||
|
default = package "prod" pkgs;
|
||
|
dev = package "dev" pkgs;
|
||
|
}
|
||
|
);
|
||
|
|
||
|
checks = self.packages;
|
||
|
|
||
|
githubActions = nix-github-actions.lib.mkGithubMatrix {
|
||
|
checks = nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.packages;
|
||
|
};
|
||
|
|
||
|
devShells = eachSystem (
|
||
|
pkgs: {
|
||
|
default = pkgs.mkShell {
|
||
|
buildInputs = with pkgs; [
|
||
|
erlang
|
||
|
elixir
|
||
|
elixir-ls
|
||
|
mix2nix
|
||
|
];
|
||
|
};
|
||
|
}
|
||
|
);
|
||
|
};
|
||
|
}
|