nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 coreutils,
6 bash,
7
8 linuxManualConfig,
9 fetchurl,
10 linux_latest,
11}:
12
13buildGoModule (finalAttrs: {
14 pname = "u-root";
15 version = "0.14.0-unstable-2024-09-26";
16
17 src = fetchFromGitHub {
18 owner = "u-root";
19 repo = "u-root";
20 rev = "a620c4fc0eeeaa71ea68c27d6ef96352ed814829";
21 hash = "sha256-8B2H3AwGo9friveBk4bijOph9bSSNR7PPKJYEuywgm4=";
22 };
23
24 vendorHash = null;
25
26 subPackages = [ "." ];
27
28 env.CGO_ENABLED = "0";
29
30 ldflags = [ "-s" ];
31
32 allowGoReference = true;
33
34 # The tests want to copy /bin/bash and /bin/ls, but we don't have those.
35 # As these are interesting e2e tests to check if things work, we substitute
36 # them with the actual paths instead of just skipping the tests.
37 preCheck = ''
38 substituteInPlace ./uroot_test.go \
39 --replace-fail '-files=/bin/bash"' '-files=${bash}/bin/bash:bin/bash"' \
40 --replace-fail '-files=/bin/ls"' '-files=${coreutils}/bin/ls:bin/ls"' \
41 --replace-fail '-files=/bin/bash' '-files=${bash}/bin/bash'
42 '';
43
44 passthru = {
45 # Somewhat minimal kernel config for Go/u-root, used by upstream for testing.
46 # This can be used to quickly run u-root locally with proper serial console output.
47 kernel-amd64 = linuxManualConfig {
48 inherit (linux_latest) version src;
49 configfile = fetchurl {
50 url = "https://raw.githubusercontent.com/hugelgupf/vmtest/5d9f3d34a58dc7b13bca786e8ac32d3e2ce4e95d/images/kernel-amd64/config_linux.txt";
51 hash = "sha256-CjhWWK6YwSOXP10mpnJjG5nwLWs2cDtebvlDBLzN5fI=";
52 };
53 allowImportFromDerivation = true;
54 };
55 };
56
57 meta = {
58 description = "Fully Go userland with Linux bootloaders";
59 longDescription = ''
60 u-root can create a one-binary root file system (initramfs) containing a busybox-like set of tools written in Go.
61
62 The package exposes `u-root.kernel-amd64` passthru for a minimal and pre-configured kernel to be used locally with QEMU.
63 '';
64 homepage = "https://u-root.org/";
65 downloadPage = "https://github.com/u-root/u-root";
66 changelog = "https://github.com/u-root/u-root/blob/${finalAttrs.src.rev}/RELEASES";
67 license = lib.licenses.bsd3;
68 maintainers = with lib.maintainers; [ katexochen ];
69 mainProgram = "u-root";
70 platforms = lib.platforms.linux;
71 };
72})