update flake
This commit is contained in:
101
flake.nix
101
flake.nix
@ -1,37 +1,59 @@
|
||||
{
|
||||
description = "A basic flake with a shell";
|
||||
description = "BSEos flake for development shell";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.devshell.url = "github:numtide/devshell";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
outputs = { self, nixpkgs, flake-utils, devshell }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
# pkgs = nixpkgs.legacyPackages.${system};
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config = { allowUnfree = true; };
|
||||
};
|
||||
config.allowUnfree = true; # For clion
|
||||
overlays = [ devshell.overlay ];
|
||||
};
|
||||
|
||||
# bintools with multilib
|
||||
bintools_multi = pkgs.wrapBintoolsWith {
|
||||
bintools =
|
||||
pkgs.bintools.bintools; # Get the unwrapped bintools from the wrapper
|
||||
libc = pkgs.glibc_multi;
|
||||
};
|
||||
|
||||
# gcc12 with multilib
|
||||
gcc12_multi = pkgs.hiPrio (pkgs.wrapCCWith {
|
||||
cc = pkgs.gcc12.cc; # Get the unwrapped gcc from the wrapper
|
||||
libc = pkgs.glibc_multi;
|
||||
bintools = bintools_multi;
|
||||
});
|
||||
|
||||
# clang14 with multilib for clang-tools
|
||||
clang14_multi = pkgs.wrapCCWith {
|
||||
cc = pkgs.clang_14.cc;
|
||||
libc = pkgs.glibc_multi;
|
||||
bintools = bintools_multi;
|
||||
};
|
||||
in {
|
||||
# devShell = pkgs.devshell.mkShell ...
|
||||
devShell = pkgs.devshell.mkShell {
|
||||
name = "BSEos";
|
||||
|
||||
packages = with pkgs; [
|
||||
gcc12_multi
|
||||
bintools_multi
|
||||
clang14_multi
|
||||
# clang-tools_14 # clangd + clang-format + clang-tidy
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
# Native inputs run on host
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gcc_multi # Compile with 32bit
|
||||
glibc_multi # Needed for lsp to find some headers (can cause compilation errors when trying to
|
||||
# compile some file standalone)
|
||||
nasm
|
||||
# binutils # Should be included in gcc
|
||||
|
||||
gnumake
|
||||
bear # To generate compilation database
|
||||
gdb
|
||||
qemu # Start os in virtual machine
|
||||
doxygen # Generate docs + graphs
|
||||
|
||||
clang-tools_14 # clangd + clang-format + clang-tidy, the counterparts included in clang_14 package
|
||||
# don't function correctly somehow (don't find headers, probably some conflict between
|
||||
# nix clang and gcc environments)
|
||||
clang_14 # To view template generation, also alternative error messages
|
||||
# glibc_multi # Needed for lsp to find some headers
|
||||
# clang_14 # To view template generation, also alternative error messages, conflicts with gcc
|
||||
|
||||
jetbrains.clion
|
||||
|
||||
@ -41,13 +63,46 @@
|
||||
# root
|
||||
];
|
||||
|
||||
# Build inputs are for target platform, app will be linked against those
|
||||
buildInputs = with pkgs; [ ];
|
||||
# Not for devshell
|
||||
# hardeningDisable = [ "fortify" ]; # FORTIFY_SOURCE needs -O2 but we compile with -O0
|
||||
|
||||
# shellHook = ''
|
||||
# alias makeg="CC=gcc CXX=g++ make -j 8"
|
||||
# alias makec="CC=clang CXX=clang++ make -j 8"
|
||||
# '';
|
||||
commands = [
|
||||
{
|
||||
name = "ide";
|
||||
help = "Run clion for project";
|
||||
command = "clion &>/dev/null ./ &";
|
||||
}
|
||||
{
|
||||
name = "build";
|
||||
help = "Build the OS";
|
||||
command = "make --jobs 6";
|
||||
}
|
||||
{
|
||||
name = "build-clang";
|
||||
help = "Build the OS using clang";
|
||||
command = "GCCFLAGS='' CC=clang CXX=clang++ make --jobs 6";
|
||||
}
|
||||
{
|
||||
name = "run";
|
||||
help = "Start OS in qemu";
|
||||
command = "make qemu --jobs 6";
|
||||
}
|
||||
{
|
||||
name = "clean";
|
||||
help = "Cleanup build files";
|
||||
command = "make clean";
|
||||
}
|
||||
{
|
||||
name = "generate-compile-commands";
|
||||
help = "Generate the compilation database for clangd";
|
||||
command = "make clean && GCCFLAGS='' bear -- make --jobs 6";
|
||||
}
|
||||
{
|
||||
name = "debug";
|
||||
help = "Start OS for gdb connection and run gdb";
|
||||
command = "make clean && make qemu-gdb --jobs 6 & && make gdb";
|
||||
}
|
||||
];
|
||||
};
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user