muhh.lol/flake.nix
2024-06-05 17:39:29 +02:00

43 lines
1.3 KiB
Nix

{
description = "my internet happy place";
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
ruby = pkgs.ruby_3_3;
rubyEnv = pkgs.bundlerEnv {
name = "muhh.lol";
ruby = ruby;
gemdir = ./.;
};
in {
devShells.default = pkgs.mkShell {
env = {
};
buildInputs = [
ruby
rubyEnv
rubyEnv.wrappedRuby
pkgs.bundler
pkgs.bundix
];
shellHook = ''
bundle config --local BUNDLE_FORCE_RUBY_PLATFORM true
# Check if Gemfile has changed
if [ "$(find . -name Gemfile -print0 | xargs -0 stat -c '%Y' | md5sum)" != "$(cat .gemfile.md5sum 2>/dev/null || true)" ]; then
echo "Gemfile has changed, running bundle lock and bundix..."
bundle lock
nix run nixpkgs#bundix -- --ruby=${ruby}
find . -name Gemfile -print0 | xargs -0 stat -c '%Y' | md5sum > .gemfile.md5sum
fi
'';
};
}
);
}