Skip to content

Commit 395c662

Browse files
committed
Use top level flake, with specific shell.nix for subprojects
1 parent 7f150d8 commit 395c662

File tree

6 files changed

+232
-121
lines changed

6 files changed

+232
-121
lines changed

api/flake.nix

-121
This file was deleted.

api/shell.nix

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{ pkgs ? import <nixpkgs> { }, system ? builtins.currentSystem, ... }:
2+
let
3+
dev = fetchTarball "https://github.com/chvp/devshell/archive/main.tar.gz";
4+
devshell = pkgs.devshell or (import dev { inherit system; });
5+
ruby = pkgs.ruby_3_2;
6+
in
7+
devshell.mkShell {
8+
name = "Dolos API server";
9+
imports = [
10+
"${devshell.extraModulesDir}/language/ruby.nix"
11+
"${devshell.extraModulesDir}/git/hooks.nix"
12+
];
13+
git.hooks = {
14+
enable = true;
15+
};
16+
packages = with pkgs; [
17+
nixpkgs-fmt
18+
docker-compose
19+
docker
20+
];
21+
language.ruby = {
22+
package = (pkgs.lowPrio ruby);
23+
nativeDeps = with pkgs; [ libmysqlclient ];
24+
};
25+
env = [
26+
{
27+
name = "DATABASE_ROOT_PASSWORD";
28+
eval = "dolos";
29+
}
30+
{
31+
name = "TEST_DATABASE_URL";
32+
eval = "mysql2://root:[email protected]:3306/dolos_test";
33+
}
34+
{
35+
name = "DATABASE_URL";
36+
eval = "mysql2://root:[email protected]:3306/dolos";
37+
}
38+
];
39+
serviceGroups.server.services = {
40+
rails.command = "rails db:prepare && rails s -p 3000";
41+
worker.command = "rails jobs:work";
42+
mysql.command = "mysql";
43+
};
44+
commands = [
45+
{
46+
name = "mysql";
47+
category = "database";
48+
help = "Start database docker";
49+
command = ''
50+
trap "systemd-run --user docker stop dolos-db" 0
51+
docker run --name dolos-db -p 3306:3306 --rm -v dolos-db-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=$DATABASE_ROOT_PASSWORD mariadb:latest &
52+
wait
53+
'';
54+
}
55+
{
56+
name = "mysql-console";
57+
category = "database";
58+
help = "Open database console";
59+
command = ''
60+
docker exec -i dolos-db mysql -uroot -p"$DATABASE_ROOT_PASSWORD"
61+
'';
62+
}
63+
{
64+
name = "gems:update";
65+
category = "dependencies";
66+
help = "Update the `Gemfile.lock` and `gemset.nix` files";
67+
command = ''
68+
bundle install
69+
bundle pristine
70+
${pkgs.bundix}/bin/bundix
71+
'';
72+
}
73+
];
74+
}

docs/shell.nix

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{ pkgs ? import <nixpkgs> {}, system ? builtins.currentSystem, ... }:
2+
let
3+
dev = fetchTarball "https://github.com/chvp/devshell/archive/main.tar.gz";
4+
devshell = pkgs.devshell or (import dev { inherit system; });
5+
in devshell.mkShell {
6+
name = "Dolos docs - dolos.ugent.be";
7+
packages = with pkgs; [
8+
nodejs
9+
yarn
10+
];
11+
commands = [
12+
{
13+
name = "dev";
14+
help = "Run development server";
15+
command = "yarn dev";
16+
}
17+
];
18+
}

flake.lock

+85
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
description = "Dolos - Source Code Plagiarism Detection";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
devshell = {
8+
url = "github:chvp/devshell";
9+
inputs = {
10+
flake-utils.follows = "flake-utils";
11+
nixpkgs.follows = "nixpkgs";
12+
};
13+
};
14+
};
15+
16+
outputs = inputs@{ self, nixpkgs, devshell, flake-utils }:
17+
flake-utils.lib.eachDefaultSystem (system:
18+
let
19+
pkgs = import nixpkgs {
20+
inherit system;
21+
overlays = [
22+
devshell.overlays.default
23+
(self: super: {
24+
nodejs = super.nodejs-18_x;
25+
})
26+
];
27+
};
28+
in
29+
{
30+
devShells = rec {
31+
default = dolos-general;
32+
dolos-general = import ./shell.nix { inherit pkgs system; };
33+
dolos-docs = import ./docs/shell.nix { inherit pkgs system; };
34+
dolos-api = import ./api/shell.nix { inherit pkgs system; };
35+
};
36+
}
37+
);
38+
}

shell.nix

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ pkgs ? import <nixpkgs> { }, ... }:
2+
pkgs.devshell.mkShell {
3+
name = "Dolos";
4+
packages = with pkgs; [
5+
nodejs
6+
yarn
7+
python3
8+
gcc
9+
gnumake
10+
tree-sitter
11+
nixpkgs-fmt
12+
];
13+
env = [{
14+
name = "PYTHON";
15+
eval = "${pkgs.python3}/bin/python";
16+
}];
17+
}

0 commit comments

Comments
 (0)