Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
watch_file flake.lock
watch_file flake.nix
watch_file gemset.nix
use_flake ./dev
4 changes: 2 additions & 2 deletions .github/workflows/attic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ jobs:
endpoint: https://attic.chvp.be
cache: accentor
token: '${{ secrets.ATTIC_AUTH_TOKEN }}'
- run: nix build -L --no-link .#devShells.$(nix eval --impure --expr "builtins.currentSystem").accentor-api
- run: nix build -L --no-link .#devShells.$(nix eval --impure --expr "builtins.currentSystem").deps
- run: nix build -L --no-link ./dev#devShells.$(nix eval --impure --expr "builtins.currentSystem").accentor-api
- run: nix build -L --no-link ./dev#devShells.$(nix eval --impure --expr "builtins.currentSystem").deps
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ jobs:
token: '${{ secrets.ATTIC_AUTH_TOKEN }}'
- name: "Setup database"
run: |
nix develop --command pg:start
nix develop --command rails db:setup
nix develop ./dev --command pg:start
nix develop ./dev --command rails db:setup
- name: Run tests
env:
CI: true
run: nix develop --command rails test
run: nix develop ./dev --command rails test
- uses: codecov/codecov-action@v7
with:
token: ${{ secrets.CODECOV_TOKEN }} # required
Expand All @@ -58,9 +58,9 @@ jobs:
- name: Lint with rubocop
env:
RAILS_ENV: "test"
run: nix develop --command rubocop -c .rubocop.yml -f github
run: nix develop ./dev --command rubocop -c .rubocop.yml -f github
- name: Scan with brakeman
run: nix develop --command brakeman --no-pager
run: nix develop ./dev --command brakeman --no-pager
annotate-diff-check:
runs-on: ubuntu-latest
steps:
Expand All @@ -79,10 +79,10 @@ jobs:
token: '${{ secrets.ATTIC_AUTH_TOKEN }}'
- name: "Setup database"
run: |
nix develop --command pg:start
nix develop --command rails db:setup
nix develop ./dev --command pg:start
nix develop ./dev --command rails db:setup
- name: Run annotate
run: nix develop --command annotaterb models
run: nix develop ./dev --command annotaterb models
- name: Check diff
run: |
if ! git diff-index --quiet HEAD; then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
cache: accentor
token: '${{ secrets.ATTIC_AUTH_TOKEN }}'
- name: Run bundix
run: nix develop .#deps --command bundix
run: nix develop ./dev#deps --command bundix
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v7.2.1
with:
Expand Down
55 changes: 47 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,65 @@
{ stdenv
, lib
, accentor-api-env
{
stdenv,
lib,
ruby_4_0,
bundlerEnv,
}:

let
rootFiles = lib.fileset.fileFilter (file: builtins.elem file.name [ "config.ru" "Gemfile" "Gemfile.lock" "gemset.nix" "Rakefile" ]) ./.;
srcFiles = lib.fileset.unions [ rootFiles ./app ./bin ./config ./db ./lib ./public ];
rootFiles = lib.fileset.fileFilter (
file:
builtins.elem file.name [
"config.ru"
"Gemfile"
"Gemfile.lock"
"gemset.nix"
"Rakefile"
]
) ./.;
srcFiles = lib.fileset.unions [
rootFiles
./app
./bin
./config
./db
./lib
./public
];
ruby = ruby_4_0.override { jemallocSupport = true; };
gems = bundlerEnv {
inherit ruby;
name = "accentor-api-env";
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
groups = [
"default"
"development"
"test"
"production"
];
};
in
stdenv.mkDerivation {
pname = "accentor-api";
version = "0.24.0";
src = lib.fileset.toSource { root = ./.; fileset = srcFiles; };
src = lib.fileset.toSource {
root = ./.;
fileset = srcFiles;
};

buildPhase = ''
# Compile bootsnap cache
${accentor-api-env}/bin/bundle exec bootsnap precompile --gemfile app/ lib/
${gems}/bin/bundle exec bootsnap precompile --gemfile app/ lib/
'';

installPhase = ''
mkdir $out
cp -r * $out
'';

passthru.env = accentor-api-env;
passthru = {
inherit ruby;
env = gems;
};
}
83 changes: 83 additions & 0 deletions dev/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions dev/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
description = "Accentor API development";

inputs = {
super = {
url = "../";
inputs.nixpkgs.follows = "nixpkgs";
};
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.zst";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an ideal world, this would follow the nixpkgs of super, but that leads to issues with dependabot where the reference here isn't updated. Since dependabot does the updates anyway, they should remain in sync.

bundix = {
url = "github:inscapist/bundix";
inputs.nixpkgs.follows = "nixpkgs";
};
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs: {
devShells = builtins.mapAttrs (
system: pkgs':
let
pkgs = pkgs'.appendOverlays [
(self: super: {
bundix = inputs.bundix;
})
inputs.super.overlays.default
inputs.devshell.overlays.default
];
in
{
accentor-api = pkgs.callPackage ./shell.nix { };
default = inputs.self.devShells.${system}.accentor-api;
deps = pkgs.devshell.mkShell {
packages = [
pkgs.accentor-api.ruby
pkgs.bundix
];
};
}
) inputs.nixpkgs.legacyPackages;
};
}
24 changes: 12 additions & 12 deletions shell.nix → dev/shell.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{ devshell
, lib
, accentor-api-env
, ffmpeg
, nixpkgs-fmt
, postgresql_18
, bundix
{
devshell,
lib,
accentor-api,
ffmpeg,
nixfmt,
postgresql_18,
}:

let
ruby = accentor-api-env.wrappedRuby;
ruby = accentor-api.env.wrappedRuby;
in
devshell.mkShell {
name = "Accentor API";
packages = [
accentor-api-env
accentor-api.env
(lib.lowPrio ruby)
ffmpeg
nixpkgs-fmt
nixfmt
postgresql_18
];
env = [
Expand Down Expand Up @@ -71,8 +71,8 @@ devshell.mkShell {
category = "dependencies";
help = "Update the `Gemfile.lock` and `gemset.nix` files";
command = ''
${ruby}/bin/bundle lock --add-checksums
${bundix}/bin/bundix
nix develop $PRJ_ROOT/dev#deps -c bundle lock --add-checksums
nix develop $PRJ_ROOT/dev#deps -c bundix
'';
}
];
Expand Down
48 changes: 3 additions & 45 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading