diff --git a/Documentation/BuildInstructionsLadybird.md b/Documentation/BuildInstructionsLadybird.md index da2c01224f..77b8914a5a 100644 --- a/Documentation/BuildInstructionsLadybird.md +++ b/Documentation/BuildInstructionsLadybird.md @@ -34,22 +34,20 @@ On openSUSE: sudo zypper install cmake libglvnd-devel ninja qt6-base-devel qt6-multimedia-devel qt6-tools-devel qt6-wayland-devel ccache ``` -On Nix/NixOS (using your host nixpkgs): -```bash -# From /path/to/serenity -nix-shell Ladybird/ladybird.nix +On NixOS or with Nix: +```console +nix develop .#ladybird # With a custom entrypoint, for example your favorite shell -nix-shell --command bash Ladybird/ladybird.nix +nix develop .#ladybird --command bash ``` -You can also use the nix flake in `Toolchain`: -```bash -# From /path/to/serenity -nix develop ./Toolchain#ladybird +On NixOS or with Nix using your host `nixpkgs` and the legacy `nix-shell` tool: +```console +nix-shell Ladybird # With a custom entrypoint, for example your favorite shell -nix develop ./Toolchain#ladybird --command bash +nix-shell --command bash Ladybird ``` On macOS: diff --git a/Documentation/BuildInstructionsOther.md b/Documentation/BuildInstructionsOther.md index 06c36208b0..fa57f7624d 100644 --- a/Documentation/BuildInstructionsOther.md +++ b/Documentation/BuildInstructionsOther.md @@ -27,35 +27,19 @@ apt-get install curl cmake libmpc-devel gmp-devel e2fsprogs libmpfr-devel ninja- ## NixOS -You can use the `nix-shell` script [`Toolchain/serenity.nix`](../Toolchain/serenity.nix) to set up the environment (using your host nixpkgs): +You can use the flake in the root directory to enter a devShell that has all the required packages and tools to build SerenityOS: ```console -nix-shell Toolchain/serenity.nix - -# With a custom entrypoint, for example your favorite shell -nix-shell --command bash Toolchain/serenity.nix +nix develop ``` -or you can use the nix flake [`Toolchain/flake.nix`](../Toolchain/flake.nix) instead: +Or you can use the legacy `nix-shell` tool to enter the devShell: ```console -nix develop ./Toolchain# - -# With a custom entrypoint, for example your favorite shell -nix develop ./Toolchain# --command bash +nix-shell Toolchain ``` -You can also save this environment to a profile: - -``` -nix develop Toolchain --profile Toolchain/nix-profiles/dev -``` - -and resume later with: - -``` -nix develop Toolchain/nix-profiles/dev -``` +This will use the `Toolchain/default.nix` file and your host `nixpkgs`. ## Alpine Linux diff --git a/Ladybird/ladybird.nix b/Ladybird/default.nix similarity index 61% rename from Ladybird/ladybird.nix rename to Ladybird/default.nix index 8e1afb5233..9d61d091ea 100644 --- a/Ladybird/ladybird.nix +++ b/Ladybird/default.nix @@ -1,12 +1,7 @@ -{ pkgs ? import { } }: -pkgs.mkShell.override -{ - stdenv = pkgs.gcc13Stdenv; -} -{ - name = "ladybird"; +{ pkgs ? import { } }: with pkgs; - nativeBuildInputs = with pkgs; [ +mkShell.override { stdenv = gcc13Stdenv; } { + packages = [ ccache cmake libxcrypt @@ -15,7 +10,6 @@ pkgs.mkShell.override qt6.qtbase qt6.qtbase.dev qt6.qtmultimedia - qt6.qtsvg qt6.qttools qt6.qtwayland qt6.qtwayland.dev @@ -24,7 +18,7 @@ pkgs.mkShell.override shellHook = '' # NOTE: This is required to make it find the wayland platform plugin installed # above, but should probably be fixed upstream. - export QT_PLUGIN_PATH="$QT_PLUGIN_PATH:${pkgs.qt6.qtwayland}/lib/qt-6/plugins" + export QT_PLUGIN_PATH="$QT_PLUGIN_PATH:${qt6.qtwayland}/lib/qt-6/plugins" export QT_QPA_PLATFORM="wayland;xcb" ''; } diff --git a/Toolchain/serenity.nix b/Toolchain/default.nix similarity index 61% rename from Toolchain/serenity.nix rename to Toolchain/default.nix index 1d92263735..e26bdce7d2 100644 --- a/Toolchain/serenity.nix +++ b/Toolchain/default.nix @@ -1,9 +1,7 @@ -{ pkgs ? import { } }: -with pkgs; +{ pkgs ? import { } }: with pkgs; -stdenv.mkDerivation { - name = "cpp-env"; - nativeBuildInputs = [ +mkShell.override { stdenv = gcc13Stdenv; } { + packages = [ ccache cmake curl @@ -21,11 +19,6 @@ stdenv.mkDerivation { rsync texinfo unzip - ]; - - buildInputs = [ - e2fsprogs - fuse2fs # To build the GRUB disk image grub2 libxcrypt @@ -34,6 +27,4 @@ stdenv.mkDerivation { qemu python3 ]; - - hardeningDisable = [ "format" "fortify" ]; } diff --git a/Toolchain/flake.nix b/Toolchain/flake.nix deleted file mode 100644 index f915778363..0000000000 --- a/Toolchain/flake.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ - description = "Serenity OS"; - - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - }; - outputs = { self, flake-utils, nixpkgs }: - - flake-utils.lib.eachDefaultSystem - (system: - let pkgs = nixpkgs.legacyPackages.${system}; in - { - formatter = pkgs.nixpkgs-fmt; - devShells.default = import ./serenity.nix { inherit pkgs; }; - devShells.ladybird = import ../Ladybird/ladybird.nix { inherit pkgs; }; - } - ); - - -} diff --git a/Toolchain/flake.lock b/flake.lock similarity index 82% rename from Toolchain/flake.lock rename to flake.lock index 85d902ecb9..133833c9ce 100644 --- a/Toolchain/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1701253981, @@ -36,8 +18,8 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "utils": "utils" } }, "systems": { @@ -54,6 +36,24 @@ "repo": "default", "type": "github" } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..945d8b494b --- /dev/null +++ b/flake.nix @@ -0,0 +1,15 @@ +{ + description = "Serenity"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, utils, }: utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { inherit system; }; + in { + devShells.default = import ./Toolchain { inherit pkgs; }; + devShells.ladybird = import ./Ladybird { inherit pkgs; }; + }); +}