1

update flake

This commit is contained in:
2022-07-27 23:44:31 +02:00
parent 1b588a5c09
commit c180028913
2 changed files with 134 additions and 28 deletions

61
flake.lock generated
View File

@ -1,6 +1,40 @@
{
"nodes": {
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1658746384,
"narHash": "sha256-CCJcoMOcXyZFrV1ag4XMTpAPjLWb4Anbv+ktXFI1ry0=",
"owner": "numtide",
"repo": "devshell",
"rev": "0ffc7937bb5e8141af03d462b468bd071eb18e1b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
@ -17,11 +51,27 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1658150454,
"narHash": "sha256-dhyOQvRT8oYWN0SwsNyujohBsJqwF5W7fnhEcfgBk7E=",
"lastModified": 1643381941,
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3110964916469ad6ed9fea72a0a3119a0959a14e",
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1658644204,
"narHash": "sha256-MWyfCH9K3eVTXJUxBi67OQSAh9jJAnvWklM6qm4j8w8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2f0c3be57c348f4cfd8820f2d189e29a685d9c41",
"type": "github"
},
"original": {
@ -33,8 +83,9 @@
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
"devshell": "devshell",
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
}
}
},

101
flake.nix
View File

@ -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";
}
];
};
});
}