Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into staging-next
Browse files Browse the repository at this point in the history
  • Loading branch information
K900 committed Dec 16, 2024
2 parents c9e934a + 3cf4242 commit 2075b1d
Show file tree
Hide file tree
Showing 45 changed files with 3,455 additions and 2,525 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Building Images with `nixos-rebuild build-image` {#sec-image-nixos-rebuild-build-image}

Nixpkgs contains a variety of modules to build custom images for different virtualization platforms and cloud providers, such as e.g. `amazon-image.nix` and `proxmox-lxc.nix`.

While those can be imported individually, `system.build.images` provides an attribute set mapping variant names to image derivations. Available variants are defined - end extendable - in `image.modules`, an attribute set mapping variant names to a list of NixOS modules.

All of those images can be built via both, their `system.build.image` attribute, and the CLI `nixos-rebuild build-image`. To build i.e. an Amazon image from your existing NixOS configuration:

```ShellSession
$ nixos-rebuild build-image --image-variant amazon
$ ls result
nixos-image-amazon-25.05pre-git-x86_64-linux.vhd nix-support
```

To get a list of all variants available, run `nixos-rebuild build-image` without arguments.

6 changes: 2 additions & 4 deletions nixos/doc/manual/installation/building-nixos.chapter.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Building a NixOS (Live) ISO {#sec-building-image}

Default live installer configurations are available inside `nixos/modules/installer/cd-dvd`.
For building other system images, [nixos-generators] is a good place to start looking at.
For building other system images, see [Building Images with `nixos-rebuild build-image`](#sec-image-nixos-rebuild-build-image).

You have two options:

Expand All @@ -14,8 +14,6 @@ on which they immediately depend in order to work correctly.
However, if you are confident, you can opt to override those
enforced values with `mkForce`.

[nixos-generators]: https://github.com/nix-community/nixos-generators

## Practical Instructions {#sec-building-image-instructions}

To build an ISO image for the channel `nixos-unstable`:
Expand All @@ -30,7 +28,7 @@ $ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd
To check the content of an ISO image, mount it like so:

```ShellSession
# mount -o loop -t iso9660 ./result/iso/cd.iso /mnt/iso
# mount -o loop -t iso9660 ./result/iso/nixos-image-25.05pre-git-x86_64-linux.iso /mnt/iso
```

## Additional drivers or firmware {#sec-building-image-drivers}
Expand Down
1 change: 1 addition & 0 deletions nixos/doc/manual/installation/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ installing.chapter.md
changing-config.chapter.md
upgrading.chapter.md
building-nixos.chapter.md
building-images-via-nixos-rebuild-build-image.chapter.md
building-images-via-systemd-repart.chapter.md
```
3 changes: 3 additions & 0 deletions nixos/doc/manual/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
"sec-building-image-tech-notes": [
"index.html#sec-building-image-tech-notes"
],
"sec-image-nixos-rebuild-build-image": [
"index.html#sec-image-nixos-rebuild-build-image"
],
"sec-image-repart": [
"index.html#sec-image-repart"
],
Expand Down
30 changes: 30 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
- The default PHP version has been updated to 8.3.

- `nixos-rebuild-ng`, a full rewrite of `nixos-rebuild` in Python, is available for testing. You can enable it by setting [system.rebuild.enableNg](options.html#opt-system.rebuild.enableNg) in your configuration (this will replace the old `nixos-rebuild`), or by adding `nixos-rebuild-ng` to your `environment.systemPackages` (in this case, it will live side-by-side with `nixos-rebuild` as `nixos-rebuild-ng`). It is expected that the next major version of NixOS (25.11) will enable `system.rebuild.enableNg` by default.
- A `nixos-rebuild build-image` sub-command has been added.

It allows users to build platform-specific (disk) images from their NixOS configurations. `nixos-rebuild build-image` works similar to the popular [nix-community/nixos-generators](https://github.com/nix-community/nixos-generators) project. See new [section on image building in the nixpkgs manual](https://nixos.org/manual/nixpkgs/unstable/#sec-image-nixos-rebuild-build-image).

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

## New Modules {#sec-release-25.05-new-modules}
Expand Down Expand Up @@ -143,6 +147,32 @@

- `python3Packages.opentracing` has been removed due to being unmaintained upstream. [OpenTelemetry](https://opentelemetry.io/) is the recommended replacement.

- Default file names of images generated by several builders in `system.build` have been changed as outlined in the table below.

Names are now known at evaluation time and customizable via the new options `image.baseName`, `image.extension`, `image.fileName` and `image.filePath` with the latter returning a path relative to the derivations out path (e.g. `iso/${image.fileName` for iso images).

| `system.build` Option | Old Filename | New Filename |
|--------------------------+------------------------------------------------------------+-----------------------------------------------------------------|
| amazonImage | nixos-amazon-image-25.05pre-git-x86_64-linux.vhd | nixos-image-amazon-25.05pre-git-x86_64-linux.vhd |
| azureImage | disk.vhd | nixos-image-azure-25.05pre-git-x86_64-linux.vhd |
| digitalOceanImage | nixos.qcow2.gz | nixos-image-digital-ocean-25.05pre-git-x86_64-linux.qcow2.gz |
| googleComputeImage | nixos-image-25.05pre-git-x86_64-linux.raw.tar.gz | nixos-image-google-compute-25.05pre-git-x86_64-linux.raw.tar.gz |
| hypervImage | nixos-25.05pre-git-x86_64-linux.vhdx | nixos-image-hyperv-25.05pre-git-x86_64-linux.vhdx |
| isoImage (installer) | nixos-25.05pre-git-x86_64-linux.iso | nixos-image-25.05pre-git-x86_64-linux.iso |
| isoImage | nixos.iso | nixos-image-25.05pre-git-x86_64-linux.iso |
| kubevirtImage | nixos.qcow2 | nixos-image-kubevirt-25.05pre-git-x86_64-linux.qcow2 |
| linodeImage | nixos-image-25.05pre-git-x86_64-linux.img.gz | nixos-image-linode-25.05pre-git-x86_64-linux.img.gz |
| metadata (lxc-container) | nixos-system-x86_64-linux.tar.xz | nixos-image-lxc-metadata-25.05pre-git-x86_64-linux.tar.xz |
| OCIImage | nixos.qcow2 | nixos-image-oci-25.05pre-git-x86_64-linux.qcow2 |
| openstackImage (zfs) | nixos-openstack-image-25.05pre-git-x86_64-linux.root.qcow2 | nixos-image-openstack-zfs-25.05pre-git-x86_64-linux.root.qcow2 |
| openstackImage | nixos.qcow2 | nixos-image-openstack-25.05pre-git-x86_64-linux.qcow2 |
| sdImage | nixos-sd-image-25.05pre-git-x86_64-linux.img.zst | nixos-image-sd-card-25.05pre-git-x86_64-linux.img.zst |
| tarball (lxc-container) | nixos-system-x86_64-linux.tar.xz | nixos-image-lxc-25.05pre-git-x86_64-linux.tar.xz |
| tarball (proxmox-lxc) | nixos-system-x86_64-linux.tar.xz | nixos-image-lxc-proxmox-25.05pre-git-x86_64-linux.tar.xz |
| vagrantVirtualbox | nixos-25.05pre-git-x86_64-linux.ova | nixos-image-virtualbox-25.05pre-git-x86_64-linux.ova |
| virtualBoxOVA | virtualbox-vagrant.box | nixos-image-vagrant-virtualbox-25.05pre-git-x86_64-linux.ova |
| vmwareImage | nixos-25.05pre-git-x86_64-linux.vmdk | nixos-image-vmware-25.05pre-git-x86_64-linux.vmdk |

- the notmuch vim plugin now lives in a separate output of the `notmuch`
package. Installing `notmuch` will not bring the notmuch vim package anymore,
add `vimPlugins.notmuch-vim` to your (Neo)vim configuration if you want the
Expand Down
4 changes: 2 additions & 2 deletions nixos/maintainers/scripts/ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ nix run nixpkgs#upload-ami -- --image-info ./result/nix-support/image-info.json

## How to build your own NixOS config into an AMI

I suggest looking at https://github.com/nix-community/nixos-generators for a user-friendly interface.
Use `nixos-rebuild build-image` as follows:

```bash
nixos-generate -c ./my-config.nix -f amazon
NIXOS_CONFIG="$(pwd)/my-config.nix" nixos-rebuild build-image --image-variant amazon

export AWS_REGION=us-west-2
export AWS_PROFILE=my-profile
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/hardware/udev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ let
'';

compressFirmware = firmware:
if config.hardware.firmwareCompression == "none" || (firmware.compressFirmware or false) == false then firmware
if config.hardware.firmwareCompression == "none" || (firmware.compressFirmware or true) == false then firmware
else if config.hardware.firmwareCompression == "zstd" then pkgs.compressFirmwareZstd firmware
else pkgs.compressFirmwareXz firmware;

Expand Down
10 changes: 0 additions & 10 deletions pkgs/applications/networking/cluster/k3s/1_28/chart-versions.nix

This file was deleted.

18 changes: 0 additions & 18 deletions pkgs/applications/networking/cluster/k3s/1_28/images-versions.json

This file was deleted.

15 changes: 0 additions & 15 deletions pkgs/applications/networking/cluster/k3s/1_28/versions.nix

This file was deleted.

11 changes: 0 additions & 11 deletions pkgs/applications/networking/cluster/k3s/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ let
extraArgs = builtins.removeAttrs args [ "callPackage" ];
in
{
# 1_28 can be built with the same builder as 1_30
k3s_1_28 = common (
(import ./1_28/versions.nix)
// {
updateScript = [
./update-script.sh
"28"
];
}
) extraArgs;

# 1_29 can be built with the same builder as 1_30
k3s_1_29 = common (
(import ./1_29/versions.nix)
Expand Down
59 changes: 59 additions & 0 deletions pkgs/by-name/aw/awk-language-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "awk-language-server",
"description": "AWK Language Server",
"version": "0.10.6",
"author": "Stanislav Chernov <[email protected]>",
"publisher": "beaglefoot",
"license": "MIT",
"keywords": [
"language-server",
"language-server-protocol",
"lsp",
"awk",
"gawk"
],
"engines": {
"node": ">=16.0.0"
},
"bin": "./server/out/cli.js",
"main": "./server/out/server.js",
"typings": "./server/out/server.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/Beaglefoot/awk-language-server"
},
"dependencies": {
"minimist": "1.2.6",
"tree-sitter-awk": "0.7.2",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"web-tree-sitter": "0.22.1"
},
"devDependencies": {
"@types/minimist": "1.2.2",
"@types/jest": "27.0.1",
"@types/node": "^12.12.0",
"jest": "27.1.1",
"prettier": "2.3.2",
"ts-jest": "27.0.5",
"typescript": "^4.3.2"
},
"scripts": {
"build:completion": "man gawk | gawk -f scripts/build_completion_list.awk > docs.json",
"prepublishOnly": "cd .. && yarn build:server:force",
"clean:client": "rm -rfv client/out/*",
"clean:server": "rm -rfv server/out/*",
"build": "yarn build:server && yarn build:client",
"build:client": "tsc -b client/tsconfig.json",
"build:client:force": "yarn clean:client && yarn build:client --verbose --force",
"build:server": "tsc -b server/tsconfig.json",
"build:server:force": "yarn clean:server && yarn build:server --verbose --force",
"postinstall": "cd client && yarn && cd ../server && yarn && cd ..",
"test": "jest",
"test:server": "jest server/tests",
"test:ci": "jest --runInBand",
"check:types": "tsc --noEmit -p server/tsconfig.json",
"check:style": "prettier --check **/*.ts"
},
"private": true
}
67 changes: 67 additions & 0 deletions pkgs/by-name/aw/awk-language-server/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
lib,
mkYarnPackage,
fetchYarnDeps,
fetchFromGitHub,
jq,
}:

mkYarnPackage rec {
name = "awk-language-server";
version = "0.10.6";

src = fetchFromGitHub {
owner = "Beaglefoot";
repo = "awk-language-server";
rev = "server-${version}";
hash = "sha256-YtduDfMAUAoQY9tgyhgERFwx9TEgD52KdeHnX2MrjjI=";
sparseCheckout = [ "server" ];
postFetch = ''
# combine both yarn lock files
tail -n+4 $out/server/yarn.lock >> $out/yarn.lock
# recontextualize server/package.json to be one folder up
sed -i 's|\./|./server/|' $out/server/package.json
# combine both package.json files
${lib.getExe jq} -s '.[0] * .[1]' \
$out/server/package.json \
$out/package.json \
> package.json
mv -f package.json $out/
'';
};

packageJSON = ./package.json;
yarnLock = ./yarn.lock;

offlineCache = fetchYarnDeps {
yarnLock = ./yarn.lock;
hash = "sha256-PaebqpXQGBxqcaxun8zi6TPeIgHmY+2fjsE/3LaWPN8=";
};

distPhase = "true";

buildPhase = ''
runHook preBuild
export HOME=$(mktemp -d)
yarn --offline build:server
runHook postBuild
'';

postInstall = ''
chmod +x $out/bin/awk-language-server
'';

passthru.updateScript = ./update.sh;

meta = with lib; {
description = "Language Server for AWK and associated VSCode client extension";
homepage = "https://github.com/Beaglefoot/awk-language-server";
license = licenses.mit;
maintainers = with maintainers; [ mathiassven ];
mainProgram = "awk-language-server";
};
}
30 changes: 30 additions & 0 deletions pkgs/by-name/aw/awk-language-server/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts coreutils gnused prefetch-yarn-deps

set -e

# update src version and hash
version="$(list-git-tags | sort -V | tail -1 | sed 's|server-||')"

update-source-version awk-language-server "$version"

# update vendored yarn.lock & package.json
newSrc="$(nix-build --no-out-link -A awk-language-server.src)"

nixFile="$(nix-instantiate --eval --strict -A 'awk-language-server.meta.position' \
| sed -re 's/^"(.*):[0-9]+"$/\1/')"

nixFileDir="$(dirname "$nixFile")"

cp --force --no-preserve=mode "$newSrc"/{yarn.lock,package.json} "$nixFileDir/"

# update offlineCache hash
oldCacheSriHash="$(nix-instantiate --eval --strict \
-A 'awk-language-server.offlineCache.drvAttrs.outputHash')"

newCacheHash="$(prefetch-yarn-deps "$nixFileDir/yarn.lock")"

newCacheSriHash="$(nix-hash --to-sri --type sha256 "$newCacheHash")"

sed -i "s|$oldCacheSriHash|\"$newCacheSriHash\"|" "$nixFile"

Loading

0 comments on commit 2075b1d

Please sign in to comment.