nix: Clean up files, use good practices

This commit is contained in:
RGBCube 2024-03-16 11:36:09 +03:00 committed by Andrew Kaster
parent 6654021655
commit 720feaa658
Notes: sideshowbarker 2024-07-17 01:04:03 +09:00
7 changed files with 55 additions and 94 deletions

View file

@ -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 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): On NixOS or with Nix:
```bash ```console
# From /path/to/serenity nix develop .#ladybird
nix-shell Ladybird/ladybird.nix
# With a custom entrypoint, for example your favorite shell # 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`: On NixOS or with Nix using your host `nixpkgs` and the legacy `nix-shell` tool:
```bash ```console
# From /path/to/serenity nix-shell Ladybird
nix develop ./Toolchain#ladybird
# With a custom entrypoint, for example your favorite shell # With a custom entrypoint, for example your favorite shell
nix develop ./Toolchain#ladybird --command bash nix-shell --command bash Ladybird
``` ```
On macOS: On macOS:

View file

@ -27,35 +27,19 @@ apt-get install curl cmake libmpc-devel gmp-devel e2fsprogs libmpfr-devel ninja-
## NixOS ## 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 ```console
nix-shell Toolchain/serenity.nix nix develop
# With a custom entrypoint, for example your favorite shell
nix-shell --command bash Toolchain/serenity.nix
``` ```
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 ```console
nix develop ./Toolchain# nix-shell Toolchain
# With a custom entrypoint, for example your favorite shell
nix develop ./Toolchain# --command bash
``` ```
You can also save this environment to a profile: This will use the `Toolchain/default.nix` file and your host `nixpkgs`.
```
nix develop Toolchain --profile Toolchain/nix-profiles/dev
```
and resume later with:
```
nix develop Toolchain/nix-profiles/dev
```
## Alpine Linux ## Alpine Linux

View file

@ -1,12 +1,7 @@
{ pkgs ? import <nixpkgs> { } }: { pkgs ? import <nixpkgs> { } }: with pkgs;
pkgs.mkShell.override
{
stdenv = pkgs.gcc13Stdenv;
}
{
name = "ladybird";
nativeBuildInputs = with pkgs; [ mkShell.override { stdenv = gcc13Stdenv; } {
packages = [
ccache ccache
cmake cmake
libxcrypt libxcrypt
@ -15,7 +10,6 @@ pkgs.mkShell.override
qt6.qtbase qt6.qtbase
qt6.qtbase.dev qt6.qtbase.dev
qt6.qtmultimedia qt6.qtmultimedia
qt6.qtsvg
qt6.qttools qt6.qttools
qt6.qtwayland qt6.qtwayland
qt6.qtwayland.dev qt6.qtwayland.dev
@ -24,7 +18,7 @@ pkgs.mkShell.override
shellHook = '' shellHook = ''
# NOTE: This is required to make it find the wayland platform plugin installed # NOTE: This is required to make it find the wayland platform plugin installed
# above, but should probably be fixed upstream. # 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" export QT_QPA_PLATFORM="wayland;xcb"
''; '';
} }

View file

@ -1,9 +1,7 @@
{ pkgs ? import <nixpkgs> { } }: { pkgs ? import <nixpkgs> { } }: with pkgs;
with pkgs;
stdenv.mkDerivation { mkShell.override { stdenv = gcc13Stdenv; } {
name = "cpp-env"; packages = [
nativeBuildInputs = [
ccache ccache
cmake cmake
curl curl
@ -21,11 +19,6 @@ stdenv.mkDerivation {
rsync rsync
texinfo texinfo
unzip unzip
];
buildInputs = [
e2fsprogs
fuse2fs
# To build the GRUB disk image # To build the GRUB disk image
grub2 grub2
libxcrypt libxcrypt
@ -34,6 +27,4 @@ stdenv.mkDerivation {
qemu qemu
python3 python3
]; ];
hardeningDisable = [ "format" "fortify" ];
} }

View file

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

View file

@ -1,23 +1,5 @@
{ {
"nodes": { "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1701253981, "lastModified": 1701253981,
@ -36,8 +18,8 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "nixpkgs": "nixpkgs",
"nixpkgs": "nixpkgs" "utils": "utils"
} }
}, },
"systems": { "systems": {
@ -54,6 +36,24 @@
"repo": "default", "repo": "default",
"type": "github" "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", "root": "root",

15
flake.nix Normal file
View file

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