Skip to content
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

Nix development env for linux #703

Closed
wants to merge 4 commits into from
Closed
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
43 changes: 9 additions & 34 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-22.04]
os: [ubuntu-24.04]
arch: [x64]
mode: [debug]

Expand All @@ -25,41 +25,16 @@ jobs:
git submodule sync --recursive
git submodule update --init --force --recursive --depth=1

# Install dependencies
- name: Update apt repositories
run: sudo apt-get update

- name: Install GCC12
shell: bash
run: |
sudo apt update
sudo apt install gcc-12 g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 110 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12

# Install xmake
- name: Setup xmake
uses: xmake-io/github-action-setup-xmake@v1
- name: Setup development environment with nix
uses: cachix/install-nix-action@v27
with:
xmake-version: '2.9.3'
github_access_token: ${{ secrets.GH_TOKEN }}

# Update xmake repository (in order to have the file that will be cached)
- name: Update xmake repository
run: xmake repo --update
- run: nix flake check

# Setup compilation mode and install project dependencies
- name: Configure xmake and install dependencies
run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --yes
# Kickoff install in its own step - it will be cached anyway
- name: Fetch build tools
run: nix develop

# Build the game
- name: Build
run: xmake

# Create install
#- name: Install
# run: xmake install -o packaged

# Upload artifacts
#- uses: actions/upload-artifact@v2
# with:
# name: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.mode }}
# path: packaged/bin/**
run: nix develop --command bash -c 'xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --yes && xmake'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ distrib_releasedbg/
new_addresses.txt

packaged/*

makefile
61 changes: 61 additions & 0 deletions flake.lock

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

58 changes: 58 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
description = "Tilted C++ development environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [
# msvc-llvm-nix.overlay
];
pkgs = import nixpkgs {
inherit system overlays;
config.allowUnfree = true; # In case MSVC toolchain is unfree
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
gcc14
gdb
libclang
cmake
xmake
gnumake
stdenv.cc.cc.lib
mold
#msvc-toolchain
];

shellHook = ''
# Unset environment variables, required for xmake to find
# the linker/compiler that we provide here
unset CC
unset CXX
unset LD
unset AR
unset AS
unset RANLIB
unset STRIP
unset CFLAGS
unset CXXFLAGS
unset LDFLAGS
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc
]}
export CC="${pkgs.gcc14}/bin/gcc"
export CXX="${pkgs.gcc14}/bin/g++"
export LD="${pkgs.mold}/bin/mold"

echo "C++ development environment loaded"
'';
};
});
}
Loading