-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
flake.nix
94 lines (77 loc) · 2.52 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
{
description = "A URL shortener, except emojis";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
devenv.url = "github:cachix/devenv";
naersk.url = "github:nix-community/naersk";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = { self, nixpkgs, devenv, naersk, pre-commit-hooks } @ inputs: (
let system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
naersk-lib = naersk.lib.${system}.override {
cargo = pkgs.cargo;
rustc = pkgs.rustc;
};
shell = import ./nix/shell.nix {
inherit pkgs;
};
emojied = import ./nix/modules/packages/emojied.nix {
inherit pkgs;
inherit naersk-lib;
};
buildDockerImage = tag: pkgs.dockerTools.buildImage {
name = "emojied-docker";
tag = tag;
contents = [ pkgs.bash ];
config = {
Cmd = [ "${self.packages.x86_64-linux.emojied}/bin/run" ];
WorkingDir = "/app";
Env = [ "PATH=${pkgs.coreutils}/bin/:${self.packages.${system}.emojied}/bin" ];
ExposedPorts = {
"3000/tcp" = {};
};
};
};
in {
# checks = {
# pre-commit-check = pre-commit-hooks.lib.${system}.run {
# src = ./.;
# hooks = {
# cargo-check.enable = true;
# clippy.enable = true;
# rustfmt.enable = true;
# };
# };
# };
packages.${system} = {
emojied-unwrapped = emojied;
emojied = pkgs.symlinkJoin {
name = "emojied";
paths = [ emojied ];
buildInputs = [ pkgs.makeWrapper ];
# https://gist.github.com/CMCDragonkai/9b65cbb1989913555c203f4fa9c23374
postBuild = ''
wrapProgram $out/bin/emojied \
--set APP__STATIC_ASSETS "${emojied}/bin/public"
'';
};
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/docker/examples.nix
emojied-docker = buildDockerImage "latest";
default = self.packages.${system}.emojied;
};
# nix run
apps.${system}.emojied = {
type = "app";
program = "${self.packages.${system}.emojied}/bin/emojied";
};
nixosModules.default = import ./nix/modules/services/emojied.nix;
devShells.${system}.default = devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
./nix/shell.nix
];
};
}
);
}