Update env
This commit is contained in:
28
.project
Normal file
28
.project
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Java_CompilerProjekt</name>
|
||||||
|
<comment>Project Java_CompilerProjekt created by Buildship.</comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1751327639650</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
176
flake.lock
generated
Normal file
176
flake.lock
generated
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"clj-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"devshell": "devshell",
|
||||||
|
"nix-fetcher-data": "nix-fetcher-data",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1750260437,
|
||||||
|
"narHash": "sha256-IAVoxxP75xjQXBW2WK9Ku/d4Z3NB1SPLzCi3KaN/i4k=",
|
||||||
|
"owner": "jlesquembre",
|
||||||
|
"repo": "clj-nix",
|
||||||
|
"rev": "56a209351e1be2b5763d413315e61d32b653118a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "jlesquembre",
|
||||||
|
"repo": "clj-nix",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"devshell": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"clj-nix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1741473158,
|
||||||
|
"narHash": "sha256-kWNaq6wQUbUMlPgw8Y+9/9wP0F8SHkjy24/mN3UAppg=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "devshell",
|
||||||
|
"rev": "7c9e793ebe66bcba8292989a68c0419b737a22a0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "devshell",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-parts": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1719745305,
|
||||||
|
"narHash": "sha256-xwgjVUpqSviudEkpQnioeez1Uo2wzrsMaJKJClh+Bls=",
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"rev": "c3c5ecc05edc7dafba779c6c1a61cd08ac6583e9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hercules-ci",
|
||||||
|
"repo": "flake-parts",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nix-fetcher-data": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-parts": "flake-parts",
|
||||||
|
"nixpkgs": [
|
||||||
|
"clj-nix",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1728229178,
|
||||||
|
"narHash": "sha256-p5Fx880uBYstIsbaDYN7sECJT11oHxZQKtHgMAVblWA=",
|
||||||
|
"owner": "jlesquembre",
|
||||||
|
"repo": "nix-fetcher-data",
|
||||||
|
"rev": "f3a73c34d28db49ef90fd7872a142bfe93120e55",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "jlesquembre",
|
||||||
|
"repo": "nix-fetcher-data",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1751251929,
|
||||||
|
"narHash": "sha256-IJWIzZSkBsDzS7iS/iwSwur+xFkWqeLYC4kdf8ObtOM=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "b95255df2360a45ddbb03817a68869d5cb01bf96",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs-lib": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1717284937,
|
||||||
|
"narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"clj-nix": "clj-nix",
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1751251399,
|
||||||
|
"narHash": "sha256-y+viCuy/eKKpkX1K2gDvXIJI/yzvy6zA3HObapz9XZ0=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "b22d5ee8c60ed1291521f2dde48784edd6bf695b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
284
flake.nix
Normal file
284
flake.nix
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
rec {
|
||||||
|
description = "Compiler Project";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs"; # Use nixpkgs from system registry
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
|
clj-nix.url = "github:jlesquembre/clj-nix";
|
||||||
|
clj-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
rust-overlay,
|
||||||
|
clj-nix,
|
||||||
|
}:
|
||||||
|
# Create a shell (and possibly package) for each possible system, not only x86_64-linux
|
||||||
|
flake-utils.lib.eachDefaultSystem (system: let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
config.allowUnfree = true;
|
||||||
|
overlays = [
|
||||||
|
rust-overlay.overlays.default
|
||||||
|
];
|
||||||
|
};
|
||||||
|
inherit (pkgs) lib stdenv;
|
||||||
|
|
||||||
|
# ===========================================================================================
|
||||||
|
# Define custom dependencies
|
||||||
|
# ===========================================================================================
|
||||||
|
|
||||||
|
python = pkgs.python313.withPackages (p:
|
||||||
|
with p; [
|
||||||
|
# numpy
|
||||||
|
# matplotlib
|
||||||
|
# ffmpeg-python
|
||||||
|
# pyside6
|
||||||
|
]);
|
||||||
|
|
||||||
|
rust = pkgs.rust-bin.stable.latest.default.override {
|
||||||
|
extensions = ["rust-src"]; # Include the Rust stdlib source (for IntelliJ)
|
||||||
|
};
|
||||||
|
|
||||||
|
# 64 bit C/C++ compilers that don't collide (use the same libc)
|
||||||
|
bintools = pkgs.wrapBintoolsWith {
|
||||||
|
bintools = pkgs.bintools.bintools; # Unwrapped bintools
|
||||||
|
libc = pkgs.glibc;
|
||||||
|
};
|
||||||
|
gcc = pkgs.hiPrio (pkgs.wrapCCWith {
|
||||||
|
cc = pkgs.gcc.cc; # Unwrapped gcc
|
||||||
|
libc = pkgs.glibc;
|
||||||
|
bintools = bintools;
|
||||||
|
});
|
||||||
|
clang = pkgs.wrapCCWith {
|
||||||
|
cc = pkgs.clang.cc; # Unwrapped clang
|
||||||
|
libc = pkgs.glibc;
|
||||||
|
bintools = bintools;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Multilib C/C++ compilers that don't collide (use the same libc)
|
||||||
|
bintools_multilib = pkgs.wrapBintoolsWith {
|
||||||
|
bintools = pkgs.bintools.bintools; # Unwrapped bintools
|
||||||
|
libc = pkgs.glibc_multi;
|
||||||
|
};
|
||||||
|
gcc_multilib = pkgs.hiPrio (pkgs.wrapCCWith {
|
||||||
|
cc = pkgs.gcc.cc; # Unwrapped gcc
|
||||||
|
libc = pkgs.glibc_multi;
|
||||||
|
bintools = bintools_multilib;
|
||||||
|
});
|
||||||
|
clang_multilib = pkgs.wrapCCWith {
|
||||||
|
cc = pkgs.clang.cc; # Unwrapped clang
|
||||||
|
libc = pkgs.glibc_multi;
|
||||||
|
bintools = bintools_multilib;
|
||||||
|
};
|
||||||
|
|
||||||
|
# ===========================================================================================
|
||||||
|
# Specify dependencies
|
||||||
|
# https://nixos.org/manual/nixpkgs/stable/#ssec-stdenv-dependencies-overview
|
||||||
|
# Just for a "nix develop" shell, buildInputs can be used for everything.
|
||||||
|
# ===========================================================================================
|
||||||
|
|
||||||
|
# Add dependencies to nativeBuildInputs if they are executed during the build:
|
||||||
|
# - Those which are needed on $PATH during the build, for example cmake and pkg-config
|
||||||
|
# - Setup hooks, for example makeWrapper
|
||||||
|
# - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
# Languages:
|
||||||
|
# python
|
||||||
|
# rust
|
||||||
|
# bintools
|
||||||
|
# gcc
|
||||||
|
# clang
|
||||||
|
# bintools_multilib
|
||||||
|
# gcc_multilib
|
||||||
|
# clang_multilib
|
||||||
|
# clojure
|
||||||
|
jdk
|
||||||
|
|
||||||
|
# C/C++:
|
||||||
|
# gdb
|
||||||
|
# valgrind
|
||||||
|
# gnumake
|
||||||
|
# cmake
|
||||||
|
# pkg-config
|
||||||
|
|
||||||
|
# Clojure:
|
||||||
|
# leiningen
|
||||||
|
# clj-nix.packages.${system}.deps-lock
|
||||||
|
|
||||||
|
# Java:
|
||||||
|
gradle
|
||||||
|
|
||||||
|
# Qt:
|
||||||
|
# qt6.wrapQtAppsHook # For the shellHook
|
||||||
|
];
|
||||||
|
|
||||||
|
# Add dependencies to buildInputs if they will end up copied or linked into the final output or otherwise used at runtime:
|
||||||
|
# - Libraries used by compilers, for example zlib
|
||||||
|
# - Interpreters needed by patchShebangs for scripts which are installed, which can be the case for e.g. perl
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
# C/C++:
|
||||||
|
# boost
|
||||||
|
# sfml
|
||||||
|
|
||||||
|
# Qt:
|
||||||
|
# qt6.qtbase
|
||||||
|
# qt6.full
|
||||||
|
];
|
||||||
|
# ===========================================================================================
|
||||||
|
# Define buildable + installable packages
|
||||||
|
# ===========================================================================================
|
||||||
|
# package = stdenv.mkDerivation {
|
||||||
|
# inherit nativeBuildInputs buildInputs;
|
||||||
|
# pname = "";
|
||||||
|
# version = "1.0.0";
|
||||||
|
# src = ./.;
|
||||||
|
#
|
||||||
|
# installPhase = ''
|
||||||
|
# mkdir -p $out/bin
|
||||||
|
# mv ./BINARY $out/bin
|
||||||
|
# '';
|
||||||
|
# };
|
||||||
|
# package = clj-nix.lib.mkCljApp {
|
||||||
|
# inherit pkgs;
|
||||||
|
# modules = [
|
||||||
|
# # Option list: https://jlesquembre.github.io/clj-nix/options/
|
||||||
|
# {
|
||||||
|
# name = "";
|
||||||
|
# version = "1.0.0";
|
||||||
|
# main-ns = "";
|
||||||
|
# projectSrc = ./.;
|
||||||
|
# withLeiningen = true;
|
||||||
|
# buildCommand = "lein uberjar"; # Requires "withLeiningen = true;"
|
||||||
|
# jdk = pkgs.jdk; # Default is pkgs.jdk_headless
|
||||||
|
# # customJdk.enable = true;
|
||||||
|
# # nativeImage.enable = true;
|
||||||
|
# }
|
||||||
|
# ];
|
||||||
|
# };
|
||||||
|
in rec {
|
||||||
|
# Provide package for "nix build"
|
||||||
|
# defaultPackage = package;
|
||||||
|
# defaultApp = flake-utils.lib.mkApp {
|
||||||
|
# drv = defaultPackage;
|
||||||
|
# };
|
||||||
|
|
||||||
|
# Provide environment for "nix develop"
|
||||||
|
devShell = pkgs.mkShell {
|
||||||
|
inherit nativeBuildInputs buildInputs;
|
||||||
|
name = description;
|
||||||
|
|
||||||
|
# =========================================================================================
|
||||||
|
# Define environment variables
|
||||||
|
# =========================================================================================
|
||||||
|
|
||||||
|
# Rust stdlib source:
|
||||||
|
# RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
|
||||||
|
|
||||||
|
# Custom dynamic libraries:
|
||||||
|
LD_LIBRARY_PATH = builtins.concatStringsSep ":" [
|
||||||
|
# Rust Bevy GUI app:
|
||||||
|
# "${pkgs.xorg.libX11}/lib"
|
||||||
|
# "${pkgs.xorg.libXcursor}/lib"
|
||||||
|
# "${pkgs.xorg.libXrandr}/lib"
|
||||||
|
# "${pkgs.xorg.libXi}/lib"
|
||||||
|
# "${pkgs.libGL}/lib"
|
||||||
|
|
||||||
|
# JavaFX app:
|
||||||
|
# "${pkgs.libGL}/lib"
|
||||||
|
# "${pkgs.gtk3}/lib"
|
||||||
|
# "${pkgs.glib.out}/lib"
|
||||||
|
# "${pkgs.xorg.libXtst}/lib"
|
||||||
|
];
|
||||||
|
|
||||||
|
# Dynamic libraries from buildinputs:
|
||||||
|
# LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath buildInputs;
|
||||||
|
|
||||||
|
# =========================================================================================
|
||||||
|
# Define shell environment
|
||||||
|
# =========================================================================================
|
||||||
|
|
||||||
|
# Setup the shell when entering the "nix develop" environment (bash script).
|
||||||
|
shellHook = let
|
||||||
|
mkCmakeScript = type: let
|
||||||
|
typeLower = lib.toLower type;
|
||||||
|
in
|
||||||
|
pkgs.writers.writeFish "cmake-${typeLower}.fish" ''
|
||||||
|
cd $FLAKE_PROJECT_ROOT
|
||||||
|
|
||||||
|
echo "Removing build directory ./cmake-build-${typeLower}/"
|
||||||
|
rm -rf ./cmake-build-${typeLower}
|
||||||
|
|
||||||
|
echo "Creating build directory"
|
||||||
|
mkdir cmake-build-${typeLower}
|
||||||
|
cd cmake-build-${typeLower}
|
||||||
|
|
||||||
|
echo "Running cmake"
|
||||||
|
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="${type}" -DCMAKE_EXPORT_COMPILE_COMMANDS="On" ..
|
||||||
|
|
||||||
|
echo "Linking compile_commands.json"
|
||||||
|
cd ..
|
||||||
|
ln -sf ./cmake-build-${typeLower}/compile_commands.json ./compile_commands.json
|
||||||
|
'';
|
||||||
|
|
||||||
|
cmakeDebug = mkCmakeScript "Debug";
|
||||||
|
cmakeRelease = mkCmakeScript "Release";
|
||||||
|
|
||||||
|
mkBuildScript = type: let
|
||||||
|
typeLower = lib.toLower type;
|
||||||
|
in
|
||||||
|
pkgs.writers.writeFish "cmake-build.fish" ''
|
||||||
|
cd $FLAKE_PROJECT_ROOT/cmake-build-${typeLower}
|
||||||
|
|
||||||
|
echo "Running cmake"
|
||||||
|
cmake --build .
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildDebug = mkBuildScript "Debug";
|
||||||
|
buildRelease = mkBuildScript "Release";
|
||||||
|
|
||||||
|
# Use this to specify commands that should be ran after entering fish shell
|
||||||
|
initProjectShell = pkgs.writers.writeFish "init-shell.fish" ''
|
||||||
|
echo "Entering \"${description}\" environment..."
|
||||||
|
|
||||||
|
# Determine the project root, used e.g. in cmake scripts
|
||||||
|
set -g -x FLAKE_PROJECT_ROOT (git rev-parse --show-toplevel)
|
||||||
|
|
||||||
|
# Build the provided NixOS package
|
||||||
|
abbr -a build "nix build -L"
|
||||||
|
|
||||||
|
# Rust Bevy:
|
||||||
|
# abbr -a build-release-windows "CARGO_FEATURE_PURE=1 cargo xwin build --release --target x86_64-pc-windows-msvc"
|
||||||
|
|
||||||
|
# C/C++:
|
||||||
|
# abbr -a cmake-debug "${cmakeDebug}"
|
||||||
|
# abbr -a cmake-release "${cmakeRelease}"
|
||||||
|
# abbr -a build-debug "${buildDebug}"
|
||||||
|
# abbr -a build-release "${buildRelease}"
|
||||||
|
|
||||||
|
# Clojure:
|
||||||
|
# abbr -a clojure-deps "deps-lock --lein"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
builtins.concatStringsSep "\n" [
|
||||||
|
# Launch into pure fish shell
|
||||||
|
''
|
||||||
|
exec "$(type -p fish)" -C "source ${initProjectShell} && abbr -a menu '${pkgs.bat}/bin/bat "${initProjectShell}"'"
|
||||||
|
''
|
||||||
|
|
||||||
|
# Qt: Launch into wrapped fish shell
|
||||||
|
# ''
|
||||||
|
# fishdir=$(mktemp -d)
|
||||||
|
# makeWrapper "$(type -p fish)" "$fishdir/fish" "''${qtWrapperArgs[@]}"
|
||||||
|
# exec "$fishdir/fish" -C "source ${initProjectShell} && abbr -a menu '${pkgs.bat}/bin/bat "${initProjectShell}"'"
|
||||||
|
# ''
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user