diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..cffc922b --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . --impure diff --git a/.gitignore b/.gitignore index 2f7896d1..599a8908 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target/ +.direnv diff --git a/README.md b/README.md index 181fbb13..084dc916 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,6 @@ For running AbleOS, `repbuild` uses QEMU. 3. `cargo repbuild run` # Developing -There is a new work in progress developer tool for hblang. \ No newline at end of file +There is a new work in progress developer tool for hblang. + +There is also a flake you can run by typing `nix develop .`. diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..cc0c9d31 --- /dev/null +++ b/flake.lock @@ -0,0 +1,57 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 0, + "narHash": "sha256-6H95HGJHhEZtyYA3rIQpvamMKAGoa8Yh2rFV29QnuGw=", + "path": "/nix/store/nra828scc8qs92b9pxra5csqzffb6hpl-source", + "type": "path" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..03a0b7d4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "ableos flake"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + # legacyPackages is a misnomer, it's just using your system packages + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShell = pkgs.mkShell rec { + buildInputs = with pkgs; [ + clang + llvmPackages.bintools + rustup + qemu_full + # OMVFFull + # OMVF + ]; + extraCmds = ''''; + RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain.toml; + # https://github.com/rust-lang/rust-bindgen#environment-variables + LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ]; + shellHook = '' + export REPBUILD_QEMU_FIRMWARE_PATH=${pkgs.OVMF.fd}/FV/OVMF.fd + + export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin + export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ + ''; + # Add precompiled library to rustc search path + RUSTFLAGS = ( + builtins.map (a: "-L ${a}/lib") [ + # add libraries here (e.g. pkgs.libvmi) + ] + ); + # Add glibc, clang, glib and other headers to bindgen search path + BINDGEN_EXTRA_CLANG_ARGS = + # Includes with normal include path + (builtins.map (a: ''-I"${a}/include"'') [ + # add dev libraries here (e.g. pkgs.libvmi.dev) + pkgs.glibc.dev + ]) + # Includes with special directory paths + ++ [ + ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' + ''-I"${pkgs.glib.dev}/include/glib-2.0"'' + "-I${pkgs.glib.out}/lib/glib-2.0/include/" + ]; + }; + } + ); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9353a544..76d3c8d6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] channel = "nightly-2024-07-27" -components = ["rust-src", "llvm-tools"] +components = ["rust-src", "llvm-tools", "rust-analyzer"] diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 7e386e84..00000000 --- a/shell.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ pkgs ? import { } }: -pkgs.mkShell rec { - buildInputs = with pkgs; [ - clang - llvmPackages.bintools - rustup - qemu_full - # OMVFFull - # OMVF - ]; - extraCmds = ''''; - RUSTC_VERSION = pkgs.lib.readFile ./rust-toolchain.toml; - # https://github.com/rust-lang/rust-bindgen#environment-variables - LIBCLANG_PATH = - pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ]; - shellHook = '' - export REPBUILD_QEMU_FIRMWARE_PATH=${pkgs.OVMF.fd}/FV/OVMF.fd - - export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin - export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ - ''; - # Add precompiled library to rustc search path - RUSTFLAGS = (builtins.map (a: "-L ${a}/lib") [ - # add libraries here (e.g. pkgs.libvmi) - ]); - # Add glibc, clang, glib and other headers to bindgen search path - BINDGEN_EXTRA_CLANG_ARGS = - # Includes with normal include path - (builtins.map (a: ''-I"${a}/include"'') [ - # add dev libraries here (e.g. pkgs.libvmi.dev) - pkgs.glibc.dev - ]) - # Includes with special directory paths - ++ [ - '' - -I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' - ''-I"${pkgs.glib.dev}/include/glib-2.0"'' - "-I${pkgs.glib.out}/lib/glib-2.0/include/" - ]; - -}