Code Monkey home page Code Monkey logo

kernel's Introduction

Kernel Flake

A nix flake dedicated to making the developer tooling around kernel development easier.

Features

  • Compile a local copy of the linux kernel located unter ./linux
  • QEMU VM support using Nix's built in functions for generating an initramfs
  • Remote GDB debugging through the VM

Cloning the flake

Get started by cloning this repository.

git clone [email protected]:fxttr/kernel
cd kernel
git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git linux

# nix develop .# or direnv allow to get into the dev environment

runvm   # Calls QEMU with the necessary commands, uses sudo for enabling kvm

#### Inside QEMU
# insmod module/helloworld.ko   # Load the kernel module
# rmmod module/helloworld.ko    # Unload the module
#### C^A+X to exit
#### In another terminal while the VM is running
# rungdb                        # Connect to the VM with remote GDB debugging
### (GDB)
## lx-symbols-nix               # Runs lx-symbols with the nix store paths of the modules
####

cd linux
bear -- make            # generate the compile_commands.json

# exit and then nix develop .# or just direnv reload
# to rebuild and update the runvm command

How it works

Remote GDB

Remote GDB debugging is activated through the rungdb command (build/run-gdb.nix). It wraps GDB to provide the kernel source in the search path, loads vmlinux, sources the kernel gdb scripts, and then connects to the VM. An alias is provided lx-symbols-nix that runs the lx-symbols command with all the provided modules' nix store paths as search directories.

initramfs

The initial ram disk is built using the new make-initrd-ng. It is called through its nix wrapper which safely copies the nix store packages needed over. To see how to include modules and other options see the builder, build/initramfs.nix.

C

Clang-format was copied over from the linux source tree. To get CCLS working correctly call bear -- make to get a compile_commands.json. Then open up C files.

Direnv

If you have nix-direnv enabled a shell with everything you need should open when you cd into the directory after calling direnv allow

kernel's People

Contributors

jordanisaacs avatar fxttr avatar ocfox avatar

Stargazers

Alexey Debelov avatar  avatar Andrew Shebanow avatar Georges avatar lexi avatar Dmytro Kostiuchenko avatar Mattia Marchesini avatar Bo-Wei Chen avatar Nikita Wootten avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.