From 69b8ac350a61fbf39f89b9716c51b9c09d676fd7 Mon Sep 17 00:00:00 2001 From: fidgetingbits Date: Sat, 9 Nov 2024 09:36:43 +0800 Subject: [PATCH 1/2] feat: add flake build environment --- flake.lock | 27 +++++++++++++++++++++++ flake.nix | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8dcbdd4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b830007 --- /dev/null +++ b/flake.nix @@ -0,0 +1,64 @@ +{ + description = "Linux Kernel Build Environment"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + }; + + outputs = + { + nixpkgs, + ... + }: + { + devShells.x86_64-linux.default = + let + pkgs = import nixpkgs { + system = "x86_64-linux"; + }; + in + (pkgs.buildFHSUserEnv { + name = "kernel-build-env"; + targetPkgs = + pkgs: + (builtins.attrValues { + inherit (pkgs) + python3 + pkg-config + gnumake + ncurses + binutils + linuxHeaders + libelf + flex + bison + gdb + strace + gcc + ; + + inherit (pkgs.qt5) qtbase; + # inherit (pkgs.linux) nativeBuildInputs; + }) + ++ [ + pkgs.llvmPackages.clangUseLLVM + pkgs.openssl.dev + pkgs.ncurses.dev + ]; + runScript = pkgs.writeScript "init.sh" '' + # set the cross-compilation environment variables. + # export CROSS_COMPILE=riscv64-unknown-linux-gnu- + # export ARCH=riscv + # export PKG_CONFIG_PATH="${pkgs.ncurses.dev}/lib/pkgconfig:" + + # set the CFLAGS and CPPFLAGS to enable the rv64gc and lp64d. + # as described here: + # https://github.com/graysky2/kernel_compiler_patch#alternative-way-to-define-a--march-option-without-this-patch + # export KCFLAGS=' -march=rv64gc -mabi=lp64d' + # export KCPPFLAGS=' -march=rv64gc -mabi=lp64d' + + exec zsh + ''; + }).env; + }; +} From 409f32b8ebf59ac9434341b27cc2a630de408615 Mon Sep 17 00:00:00 2001 From: fidgetingbits Date: Sat, 9 Nov 2024 09:39:37 +0800 Subject: [PATCH 2/2] refactor: disable broke in shell for now --- flake.nix | 92 +++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/flake.nix b/flake.nix index b830007..835184b 100644 --- a/flake.nix +++ b/flake.nix @@ -11,54 +11,54 @@ ... }: { - devShells.x86_64-linux.default = - let - pkgs = import nixpkgs { - system = "x86_64-linux"; - }; - in - (pkgs.buildFHSUserEnv { - name = "kernel-build-env"; - targetPkgs = - pkgs: - (builtins.attrValues { - inherit (pkgs) - python3 - pkg-config - gnumake - ncurses - binutils - linuxHeaders - libelf - flex - bison - gdb - strace - gcc - ; + # devShells.x86_64-linux.default = + # let + # pkgs = import nixpkgs { + # system = "x86_64-linux"; + # }; + # in + # (pkgs.buildFHSUserEnv { + # name = "kernel-build-env"; + # targetPkgs = + # pkgs: + # (builtins.attrValues { + # inherit (pkgs) + # python3 + # pkg-config + # gnumake + # ncurses + # binutils + # linuxHeaders + # libelf + # flex + # bison + # gdb + # strace + # gcc + # ; - inherit (pkgs.qt5) qtbase; - # inherit (pkgs.linux) nativeBuildInputs; - }) - ++ [ - pkgs.llvmPackages.clangUseLLVM - pkgs.openssl.dev - pkgs.ncurses.dev - ]; - runScript = pkgs.writeScript "init.sh" '' - # set the cross-compilation environment variables. - # export CROSS_COMPILE=riscv64-unknown-linux-gnu- - # export ARCH=riscv - # export PKG_CONFIG_PATH="${pkgs.ncurses.dev}/lib/pkgconfig:" + # inherit (pkgs.qt5) qtbase; + # # inherit (pkgs.linux) nativeBuildInputs; + # }) + # ++ [ + # pkgs.llvmPackages.clangUseLLVM + # pkgs.openssl.dev + # pkgs.ncurses.dev + # ]; + # runScript = pkgs.writeScript "init.sh" '' + # # set the cross-compilation environment variables. + # # export CROSS_COMPILE=riscv64-unknown-linux-gnu- + # # export ARCH=riscv + # # export PKG_CONFIG_PATH="${pkgs.ncurses.dev}/lib/pkgconfig:" - # set the CFLAGS and CPPFLAGS to enable the rv64gc and lp64d. - # as described here: - # https://github.com/graysky2/kernel_compiler_patch#alternative-way-to-define-a--march-option-without-this-patch - # export KCFLAGS=' -march=rv64gc -mabi=lp64d' - # export KCPPFLAGS=' -march=rv64gc -mabi=lp64d' + # # set the CFLAGS and CPPFLAGS to enable the rv64gc and lp64d. + # # as described here: + # # https://github.com/graysky2/kernel_compiler_patch#alternative-way-to-define-a--march-option-without-this-patch + # # export KCFLAGS=' -march=rv64gc -mabi=lp64d' + # # export KCPPFLAGS=' -march=rv64gc -mabi=lp64d' - exec zsh - ''; - }).env; + # exec zsh + # ''; + # }).env; }; }