-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to Nix flakes #31
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,50 @@ | ||
name: Nix | ||
name: Test Nix | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
shell: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- os: darwin | ||
cpu: x86_64 | ||
base: macos-12 | ||
base: macos-13 # always x86_64-darwin | ||
- os: darwin | ||
cpu: arm64 | ||
base: macos-14 # always arm64-darwin | ||
- os: linux | ||
cpu: x86_64 | ||
base: ubuntu-22.04 | ||
base: ubuntu-24.04 # always x86_64-linux-gnu | ||
- os: linux | ||
cpu: aarch64 | ||
base: arm-4core-linux | ||
base: arm-4core-linux-ubuntu24.04 # always aarch64-linux-gnu | ||
nix: | ||
- 24.05 | ||
|
||
name: Test Nix shell (${{ matrix.platform.cpu }}-${{ matrix.platform.os }}) | ||
name: Test Nix (${{ matrix.platform.cpu }}-${{ matrix.platform.os }}, ${{ matrix.nix }}) | ||
runs-on: ${{ matrix.platform.base }} | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- name: Check CPU arch | ||
run: | | ||
test "$(uname -m)" = "${{ matrix.platform.cpu }}" | ||
- uses: actions/checkout@v4 | ||
- uses: DeterminateSystems/nix-installer-action@main | ||
- uses: DeterminateSystems/magic-nix-cache-action@main | ||
- run: nix-shell --run 'which ruby' | ||
- run: nix-shell --run 'ruby --version' | ||
- name: Print ruby version | ||
run: | | ||
nix develop --command which ruby | ||
nix develop --command ruby --version | ||
- name: Bundle install | ||
run: nix develop --command bundle install | ||
- name: Run tests | ||
run: nix develop --command bundle exec rake test spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/vendor/bundle/ | ||
/.envrc | ||
/.direnv | ||
/Gemfile.lock | ||
/rbs_collection.lock.yaml | ||
/.gem_rbs_collection | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# flake-compat shim for usage without flakes | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).defaultNix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
inputs = { | ||
nixpkgs.url = "github:nixos/nixpkgs/master"; | ||
|
||
# cross-platform convenience | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
# backwards compatibility with nix-build and nix-shell | ||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, flake-compat }: | ||
# resolve for all platforms in turn | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
# packages for this system platform | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
|
||
# control versions | ||
ruby = pkgs.ruby_3_3; | ||
llvm = pkgs.llvmPackages_18; | ||
gcc = pkgs.gcc14; | ||
in { | ||
devShell = pkgs.llvm.stdenv.mkDerivation { | ||
name = "devshell"; | ||
|
||
buildInputs = with pkgs; [ | ||
ruby | ||
libyaml.dev | ||
|
||
# TODO: some gems insist on using `gcc` on Linux, satisfy them for now: | ||
# - json | ||
# - protobuf | ||
# - ruby-prof | ||
gcc | ||
]; | ||
|
||
shellHook = '' | ||
# get major.minor.0 ruby version | ||
export RUBY_VERSION="$(ruby -e 'puts RUBY_VERSION.gsub(/\d+$/, "0")')" | ||
|
||
# make gem install work in-project, compatibly with bundler | ||
export GEM_HOME="$(pwd)/vendor/bundle/ruby/$RUBY_VERSION" | ||
|
||
# make bundle work in-project | ||
export BUNDLE_PATH="$(pwd)/vendor/bundle" | ||
|
||
# enable calling gem scripts without bundle exec | ||
export PATH="$GEM_HOME/bin:$PATH" | ||
|
||
# enable implicitly resolving gems to bundled version | ||
export RUBYGEMS_GEMDEPS="$(pwd)/Gemfile" | ||
''; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
{ | ||
pkgs ? import <nixpkgs> {}, | ||
pinned ? import(fetchTarball("https://github.com/NixOS/nixpkgs/archive/25865a40d14b.tar.gz")) {}, | ||
}: | ||
let | ||
ruby = pinned.ruby_3_3; | ||
llvm = pinned.llvmPackages_16; | ||
in llvm.stdenv.mkDerivation { | ||
name = "shell"; | ||
|
||
buildInputs = [ | ||
ruby | ||
pinned.libyaml.dev | ||
]; | ||
|
||
shellHook = '' | ||
export RUBY_VERSION="$(ruby -e 'puts RUBY_VERSION.gsub(/\d+$/, "0")')" | ||
export GEM_HOME="$(pwd)/vendor/bundle/ruby/$RUBY_VERSION" | ||
export BUNDLE_PATH="$(pwd)/vendor/bundle" | ||
export PATH="$GEM_HOME/bin:$PATH" | ||
''; | ||
} | ||
# flake-compat shim for usage without flakes | ||
(import | ||
( | ||
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in | ||
fetchTarball { | ||
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; | ||
sha256 = lock.nodes.flake-compat.locked.narHash; | ||
} | ||
) | ||
{ src = ./.; } | ||
).shellNix |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 Code Vulnerability
No explicit permissions set for at the workflow level (...read more)
Datadog’s GitHub organization defines default permissions for the
GITHUB_TOKEN
to be restricted (contents:read
,metadata:read
, andpackages:read
).Your repository may require a different setup, so consider defining permissions for each job following the least privilege principle to restrict the impact of a possible compromise.
You can find the list of all possible permissions in Workflow syntax for GitHub Actions - GitHub Docs. They can be defined at the job or the workflow level.