-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
69 lines (61 loc) · 1.92 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
{
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-24.05;
flake-utils.url = github:numtide/flake-utils;
build-gradle-application.url = github:raphiz/buildGradleApplication;
};
outputs = { self, nixpkgs, flake-utils, build-gradle-application, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [build-gradle-application.overlays.default];
};
mkEars = pkgs.callPackage ./nix/ears.nix {};
in
{
packages.submissions.minimal = mkEars {
pname = "minimal";
version = "1.0.0";
src = ./submissions/minimal;
};
devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.gradle pkgs.jdk11 ];
};
}) // {
nixosModules.default = { config, lib, pkgs, ... }:
let
cfg = config.ears;
boot-detect = pkgs.writeScript "boot-detect" ''
${pkgs.mount}/bin/mount -t tmpfs -o size=1 tmpfs /boot-detect
'';
submission = pkgs.writeScript "submission" ''
if [[ -f /boot-detect ]]
then
echo "BOOT"
else
${lib.getExe self.packages.x86_64-linux.submissions.minimal}
fi
'';
in
{
systemd.services.boot-detect = {
description = "Submissions service";
wantedBy = [ "multi-user.target" ];
wants = [ "submissions.service" ];
serviceConfig = {
ExecStart = lib.getExe boot-detect;
};
};
systemd.services.submissions = {
description = "Submissions service";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "ears";
ExecStart = "${pkgs.coreutils}/bin/true";
ExecReload = lib.getExe submission;
};
};
};
};
}