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
```
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:

View file

@ -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

View file

@ -1,12 +1,7 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell.override
{
stdenv = pkgs.gcc13Stdenv;
}
{
name = "ladybird";
{ pkgs ? import <nixpkgs> { } }: 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"
'';
}

View file

@ -1,9 +1,7 @@
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
{ pkgs ? import <nixpkgs> { } }: 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" ];
}

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": {
"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",

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