-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
81 lines (78 loc) · 2.32 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
{
inputs = {
nixpkgs = {
url = "nixpkgs/nixos-unstable";
};
gradle2nix = {
url = "github:tadfisher/gradle2nix/v2";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, gradle2nix }: let
system = "x86_64-linux";
pkgs = import nixpkgs {inherit system;};
in rec {
packages.${system} = rec {
source = gradle2nix.builders.x86_64-linux.buildGradlePackage rec {
name = "rp-utils";
version = "1.0";
pname = "wordcount";
lockFile = ./gradle.lock;
src = ./.;
gradleBuildFlags = ["build -x test"];
gradleInstallFlags = ["installDist -x test"];
installPhase = ''
mkdir -p $out/{lib,share}/${name}
cp ./app/build/libs/app-all.jar $out/lib/${name}/rp-utils.jar
cp -r $src/* $out/share/${name}
'';
};
default = pkgs.writeScriptBin "rp-utils.sh" ''
#!${pkgs.bash}/bin/bash
${pkgs.jdk21}/bin/java -jar ${source}/lib/rp-utils/rp-utils.jar $@
'';
vm = (nixpkgs.lib.nixosSystem {
inherit system;
modules = [
nixosModules.default
{
system.stateVersion = "24.05";
services.rp-utils.enable = true;
users.users.root.password = "1234";
virtualisation.vmVariant.virtualisation.graphics = false;
}
];
}).config.system.build.vm;
};
nixosModules.default = {pkgs, lib, config, ...}: {
options.services.rp-utils = with lib.types; {
enable = lib.mkOption {
type = bool;
default = false;
};
runtimeDir = lib.mkOption {
type = str;
default = "/var/run/rp-utils";
};
};
config = {
systemd.services.rp-utils = {
enable = config.services.rp-utils.enable;
path = with pkgs; [
texliveFull
bash
sqlite
python311
];
serviceConfig = {
WorkingDirectory = config.services.rp-utils.runtimeDir;
ExecStart = "${pkgs.jdk21}/bin/java -jar ${packages.${system}.source}/lib/rp-utils/rp-utils.jar";
};
wantedBy = ["default.target"];
after = ["network-online.target"];
wants = ["network-online.target"];
};
};
};
};
}