Make entrance-exam a flake

This commit is contained in:
Charlotte Van Petegem 2025-05-21 13:37:02 +02:00
parent 5bd1e821f7
commit 6ccd23c06a
Signed by: chvp
SSH key fingerprint: SHA256:s9rb8jBVfdahqWHuBAcHCBP1wmj4eYQXZfqgz4H3E9E
6 changed files with 1276 additions and 35 deletions

View file

@ -19,7 +19,7 @@ gem "jbuilder"
# gem "bcrypt", "~> 3.1.7"
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ windows jruby ]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
# Use the database-backed adapters for Rails.cache and Active Job
gem "solid_cache"
@ -33,7 +33,7 @@ gem "bootsnap", require: false
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
gem "debug", platforms: %i[mri mingw mswin x64_mingw], require: "debug/prelude"
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
gem "brakeman", require: false

View file

@ -135,6 +135,7 @@ GEM
marcel (1.0.4)
matrix (0.4.2)
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.25.5)
msgpack (1.8.0)
net-imap (0.5.7)
@ -147,21 +148,8 @@ GEM
net-smtp (0.5.1)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.8-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.8-aarch64-linux-musl)
racc (~> 1.4)
nokogiri (1.18.8-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.8-arm-linux-musl)
racc (~> 1.4)
nokogiri (1.18.8-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.8-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.18.8-x86_64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.8-x86_64-linux-musl)
nokogiri (1.18.8)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
pp (0.6.2)
prettyprint
@ -242,14 +230,8 @@ GEM
fugit (~> 1.11.0)
railties (>= 7.1)
thor (~> 1.3.1)
sqlite3 (2.6.0-aarch64-linux-gnu)
sqlite3 (2.6.0-aarch64-linux-musl)
sqlite3 (2.6.0-arm-linux-gnu)
sqlite3 (2.6.0-arm-linux-musl)
sqlite3 (2.6.0-arm64-darwin)
sqlite3 (2.6.0-x86_64-darwin)
sqlite3 (2.6.0-x86_64-linux-gnu)
sqlite3 (2.6.0-x86_64-linux-musl)
sqlite3 (2.6.0)
mini_portile2 (~> 2.8.0)
stringio (3.1.7)
thor (1.3.2)
timeout (0.4.3)
@ -272,15 +254,7 @@ GEM
zeitwerk (2.7.2)
PLATFORMS
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
x86_64-darwin
x86_64-linux
x86_64-linux-gnu
x86_64-linux-musl
ruby
DEPENDENCIES
annotaterb

82
flake.lock generated Normal file
View file

@ -0,0 +1,82 @@
{
"nodes": {
"devshell": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1741473158,
"narHash": "sha256-kWNaq6wQUbUMlPgw8Y+9/9wP0F8SHkjy24/mN3UAppg=",
"owner": "numtide",
"repo": "devshell",
"rev": "7c9e793ebe66bcba8292989a68c0419b737a22a0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1747744144,
"narHash": "sha256-W7lqHp0qZiENCDwUZ5EX/lNhxjMdNapFnbErcbnP11Q=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "2795c506fe8fb7b03c36ccb51f75b6df0ab2553f",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

120
flake.nix Normal file
View file

@ -0,0 +1,120 @@
{
description = "Entrance exam";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, devshell, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlays.default ]; };
gems = pkgs.bundlerEnv rec {
name = "entrance-exam-env";
ruby = pkgs.ruby_3_4.override { jemallocSupport = true; };
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
groups = [ "default" "development" "test" "production" ];
};
src = pkgs.lib.cleanSourceWith { filter = name: type: !(builtins.elem name [ ".github" "flake.lock" "flake.nix" ]); src = ./.; name = "source"; };
in
{
packages = rec {
default = entrance-exam;
entrance-exam = pkgs.stdenv.mkDerivation rec {
inherit src;
pname = "entrance-exam";
version = "0.1.0";
buildPhase = ''
# Compile bootsnap cache
${gems}/bin/bundle exec bootsnap precompile --gemfile app/ lib/
'';
installPhase = ''
mkdir $out
cp -r * $out
rm -r $out/public
'';
passthru = {
assets = pkgs.stdenv.mkDerivation {
inherit src version;
pname = "entrance-exam-assets";
nativeBuildInputs = with pkgs; [
nodejs
yarnConfigHook
yarnBuildHook
];
yarnOfflineCache = pkgs.fetchYarnDeps {
yarnLock = src + "/yarn.lock";
hash = "sha256-jmVSCKHjDT1vmVRyXinKka7hK5hA37ZyE/pvRZ7z6T0=";
};
buildPhase = ''
SECRET_KEY_BASE=000000 RAILS_ENV=production SKIP_YARN_INSTALL=1 ${gems}/bin/bundle exec rails assets:precompile
'';
installPhase = ''
cp -r public $out
'';
};
env = gems;
};
};
};
devShells = rec {
default = entrance-exam;
entrance-exam = let
support-services = {
css.command = "yarn build:css --watch";
js.command = "yarn build:js --watch=forever";
};
all-services = support-services // {
rails = {
name = "server";
command = "rails s -p 3000";
};
};
in
pkgs.devshell.mkShell {
name = "Entrance Exam";
packages = [
gems
(pkgs.lowPrio gems.wrappedRuby)
pkgs.bundix
pkgs.nixpkgs-fmt
pkgs.yarn
pkgs.yarn2nix
];
serviceGroups = {
server.services = all-services;
server-support.services = support-services;
};
commands = [
{
name = "gems:update";
category = "dependencies";
help = "Update the `Gemfile.lock` and `gemset.nix` files";
command = ''
${pkgs.ruby_3_4}/bin/bundle lock
${pkgs.bundix}/bin/bundix
'';
}
];
};
};
}
);
}

1064
gemset.nix Normal file

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,8 @@
"private": true,
"scripts": {
"build:js": "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets",
"build:css": "postcss ./app/assets/stylesheets/application.postcss.css -o ./app/assets/builds/application.css"
"build:css": "postcss ./app/assets/stylesheets/application.postcss.css -o ./app/assets/builds/application.css",
"build": "yarn run build:js && yarn run build:css"
},
"dependencies": {
"autoprefixer": "^10.4.21",