Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freebsd: various new packages to support a NixBSD system #320475

Merged
merged 65 commits into from
Jul 4, 2024

Conversation

rhelmot
Copy link
Contributor

@rhelmot rhelmot commented Jun 17, 2024

Description of changes

61 of them,1 small package diff, 1 large package diff (sys), and 1 commit modifying lib and mkDerivation. This lets us boot NixBSD!

nixbsd neofetch

There are a few TODOs left in the code but I think they're fine for followup PRs.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
    • x86_64-freebsd (cross from linux)
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@rhelmot rhelmot added the 6.topic: bsd Running or building packages on BSD label Jun 17, 2024
@rhelmot rhelmot force-pushed the freebsd-various2 branch 2 times, most recently from 18c069c to a413a20 Compare June 17, 2024 08:36
@rhelmot rhelmot force-pushed the freebsd-various2 branch 2 times, most recently from fa97067 to c5cac2d Compare June 17, 2024 16:59
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jun 17, 2024
@@ -15,4 +19,61 @@
.${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;

install-wrapper = builtins.readFile ../../lib/install-wrapper.sh;

filterPatches =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too long. Can it be at least documented?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does need documentation, but do note it is just being moved. I would be OK with that happening in a later PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added an overview.

platforms = lib.platforms.freebsd;
license =
lib.optional withAmd licenses.unfreeRedistributableFirmware
# Intel license requires no modification, this will wrap firmware files in an ELF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ambiguous.

What does it mean?
a) does not require modification
b) prohibits any modification

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at the actual license file and it seems that it's the latter. I updated the verbage to be more explicit.

Comment on lines 4 to 13
useWrappedLogin ? true,
}:
mkDerivation {
path = "libexec/getty";

postPatch = ''
sed -E -i -e "s|/usr/bin/login|${
if useWrappedLogin then "/run/wrappers/bin/login" else "${login}/bin/login"
}|g" $BSDSRCDIR/libexec/getty/*.h
'';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this wrapping stuff should be left for later? Not really sure what it is yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with it? we are in fact doing suid binary wrappers on nixbsd and they work fine. Would you rather it default to off? What's the practical use of running a non-suid login binary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just meant that /run/wrappers isn't a Nixpkgs thing, so it's arguably a minor layer violation I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the parameter to be the wrappedLogin path itself, null if unused, as we discussed on matrix. You should go complain to the other package maintainers for their packages that hardcode wrapper paths!

];

postPatch = ''
sed -i 's/4555/0555/' $BSDSRCDIR/sbin/ping/Makefile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it's removing a suid bit

sed -i 's|/usr/share/zfs|${zfs-data}/share/zfs|' $BSDSRCDIR/cddl/sbin/zpool/Makefile
'';

# I lied, this is both zpool and zfs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Member

@Ericson2314 Ericson2314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through each commit, but I don't wanna nit-pick this to death :)

@rhelmot rhelmot force-pushed the freebsd-various2 branch 3 times, most recently from 5af68dd to a43ef1a Compare June 19, 2024 06:18
@rhelmot rhelmot requested a review from Ericson2314 June 22, 2024 04:38
pkgs/os-specific/bsd/freebsd/pkgs/drm-kmod-firmware.nix Outdated Show resolved Hide resolved
pkgs/os-specific/bsd/freebsd/pkgs/drm-kmod/package.nix Outdated Show resolved Hide resolved
pkgs/os-specific/bsd/freebsd/pkgs/drm-kmod/package.nix Outdated Show resolved Hide resolved
pkgs/os-specific/bsd/freebsd/pkgs/libzfs.nix Outdated Show resolved Hide resolved
pkgs/os-specific/bsd/freebsd/pkgs/syslogd.nix Outdated Show resolved Hide resolved
pkgs/os-specific/bsd/freebsd/pkgs/zfs.nix Outdated Show resolved Hide resolved
@rhelmot rhelmot force-pushed the freebsd-various2 branch from c5de37f to e589fdb Compare July 3, 2024 03:24
Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not hold this any further, subsequent improvements and bugfixes can come in a later PRs.

@JohnRTitor JohnRTitor merged commit 2b8f96c into NixOS:master Jul 4, 2024
21 checks passed
@trofi
Copy link
Contributor

trofi commented Jul 6, 2024

freebsd.drm-kmod.patches fails to evaluate with non-existent path:

$ nix-instantiate -A freebsd.drm-kmod.patches --argstr system x86_64-linux
error:
       … while calling the 'concatMap' builtin
         at pkgs/os-specific/bsd/freebsd/lib/default.nix:82:5:
           81|     in
           82|     lib.lists.concatMap splitPatch consolidated;
             |     ^
           83| }

       … while calling the 'map' builtin
         at pkgs/os-specific/bsd/freebsd/lib/default.nix:78:28:
           77|           derive = patchLines: writeText "freebsd-patch" (lib.concatLines patchLines);
           78|           derivedPatches = builtins.map derive filteredLines;
             |                            ^
           79|         in

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'path' missing
       at pkgs/os-specific/bsd/freebsd/pkgs/mkDerivation.nix:110:75:
          109|         (lib.optionals (attrs.autoPickPatches or true) (
          110|           freebsd-lib.filterPatches patches (attrs.extraPaths or [ ] ++ [ attrs.path ])
             |                                                                           ^
          111|         ))

Note it's a "syntax" error to try to dereference invalid attribute. Is it possible to have a check to return an exception here? (Inless it's a genuine bug)

@Ericson2314 Ericson2314 deleted the freebsd-various2 branch July 6, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: bsd Running or building packages on BSD 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants