diff --git a/flake.nix b/flake.nix index 0c8039e6..793f11de 100644 --- a/flake.nix +++ b/flake.nix @@ -460,6 +460,10 @@ path = ./templates/sample-nixos-template; description = "Simple sample Nix flake with NixOS and home-manager"; }; + local-ruby-nix = { + path = ./templates/local-ruby-nix; + description = "Local Ruby app development with ruby-nix"; + }; }; # No amount of formatters will make this codebase nicer but it sure does diff --git a/templates/local-ruby-nix/Gemfile b/templates/local-ruby-nix/Gemfile new file mode 100644 index 00000000..a0adb94e --- /dev/null +++ b/templates/local-ruby-nix/Gemfile @@ -0,0 +1,12 @@ +source 'https://rubygems.org' + +gemspec + +group :development do + gem 'rake' + gem 'ruby-lsp', require: false +end + +group :lint do + gem 'rubocop', require: false +end diff --git a/templates/local-ruby-nix/flake.nix b/templates/local-ruby-nix/flake.nix new file mode 100644 index 00000000..baad1bbe --- /dev/null +++ b/templates/local-ruby-nix/flake.nix @@ -0,0 +1,24 @@ +{ + description = "Basic flake template for setting up development shells"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + + ruby-nix.url = "github:sagittaros/ruby-nix"; + ruby-nix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs@{ self, ruby-nix, nixpkgs, ... }: + let systems = inputs.flake-utils.lib.defaultSystems; + in inputs.flake-utils.lib.eachSystem systems (system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShells.default = + import ./shell.nix { inherit pkgs ruby-nix; }; + + formatter = pkgs.treefmt; + }); +} diff --git a/templates/local-ruby-nix/shell.nix b/templates/local-ruby-nix/shell.nix new file mode 100644 index 00000000..e91f593a --- /dev/null +++ b/templates/local-ruby-nix/shell.nix @@ -0,0 +1,25 @@ +{ pkgs ? import { }, ruby-nix }: + +with pkgs; + +let + gems = ruby-nix.lib pkgs { + name = "ruby-nix-env"; + ruby = ruby_3_1; + gemset = ./gemset.nix; + }; +in +mkShell { + buildInputs = [ + gems.env + gems.ruby + ]; + + packages = [ + # Formatters + nixpkgs-fmt + + # Language servers + rnix-lsp + ]; +}