Skip to content

Commit

Permalink
Merge pull request #309577 from obsidiansystems/bsd-reformat
Browse files Browse the repository at this point in the history
bsd treewide: Run RFC formatter
  • Loading branch information
Ericson2314 authored May 6, 2024
2 parents c9335c6 + d516971 commit f571081
Show file tree
Hide file tree
Showing 67 changed files with 1,675 additions and 982 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,6 @@ fb0e5be84331188a69b3edd31679ca6576edb75a

# postgresql: move packages.nix to ext/default.nix
719034f6f6749d624faa28dff259309fc0e3e730

# pkgs/os-specific/bsd: Reformat with nixfmt-rfc-style 2024-03-01
3fe3b055adfc020e6a923c466b6bcd978a13069a
1 change: 1 addition & 0 deletions .github/workflows/check-nix-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
# Each environment variable beginning with NIX_FMT_PATHS_ is a list of
# paths to check with nixfmt.
env:
NIX_FMT_PATHS_BSD: pkgs/os-specific/bsd
NIX_FMT_PATHS_MPVSCRIPTS: pkgs/applications/video/mpv/scripts
# Format paths related to the Nixpkgs CUDA ecosystem.
NIX_FMT_PATHS_CUDA: |
Expand Down
11 changes: 9 additions & 2 deletions pkgs/os-specific/bsd/freebsd/evdev-proto/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{ lib, stdenv, linuxHeaders, freebsd, runCommandCC, buildPackages }:
{
lib,
stdenv,
linuxHeaders,
freebsd,
runCommandCC,
buildPackages,
}:

stdenv.mkDerivation {
pname = "evdev-proto";
Expand Down Expand Up @@ -28,7 +35,7 @@ stdenv.mkDerivation {
TOUCH = "touch";
XARGS = "xargs";

ABI_FILE = runCommandCC "abifile" {} "$CC -shared -o $out";
ABI_FILE = runCommandCC "abifile" { } "$CC -shared -o $out";
CLEAN_FETCH_ENV = true;
INSTALL_AS_USER = true;
NO_CHECKSUM = true;
Expand Down
18 changes: 10 additions & 8 deletions pkgs/os-specific/bsd/freebsd/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
{
inherit version;

mkBsdArch = stdenv': {
x86_64 = "amd64";
aarch64 = "arm64";
i486 = "i386";
i586 = "i386";
i686 = "i386";
}.${stdenv'.hostPlatform.parsed.cpu.name}
or stdenv'.hostPlatform.parsed.cpu.name;
mkBsdArch =
stdenv':
{
x86_64 = "amd64";
aarch64 = "arm64";
i486 = "i386";
i586 = "i386";
i686 = "i386";
}
.${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;

install-wrapper = builtins.readFile ./install-wrapper.sh;
}
45 changes: 28 additions & 17 deletions pkgs/os-specific/bsd/freebsd/package-set.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
{ stdenv, lib, stdenvNoCC
, fetchzip
, sourceData, versionData, buildFreebsd, patchesRoot
{
stdenv,
lib,
stdenvNoCC,
fetchzip,
sourceData,
versionData,
buildFreebsd,
patchesRoot,
}:

self:

lib.packagesFromDirectoryRecursive {
callPackage = self.callPackage;
directory = ./pkgs;
} // {
}
// {
inherit sourceData patchesRoot versionData;

# Keep the crawled portion of Nixpkgs finite.
Expand All @@ -21,11 +28,15 @@ lib.packagesFromDirectoryRecursive {

compatIfNeeded = lib.optional (!stdenvNoCC.hostPlatform.isFreeBSD) self.compat;
freebsd-lib = import ./lib {
version = lib.concatStringsSep "." (map toString (lib.filter (x: x != null) [
self.versionData.major
self.versionData.minor
self.versionData.patch or null
]));
version = lib.concatStringsSep "." (
map toString (
lib.filter (x: x != null) [
self.versionData.major
self.versionData.minor
self.versionData.patch or null
]
)
);
};

# The manual callPackages below should in principle be unnecessary, but are
Expand All @@ -51,21 +62,21 @@ lib.packagesFromDirectoryRecursive {
};

libc = self.callPackage ./pkgs/libc/package.nix {
inherit (buildFreebsd) makeMinimal install gencat rpcgen;
inherit (buildFreebsd)
makeMinimal
install
gencat
rpcgen
;
inherit (self) csu include;
};

libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix {
inherit (buildFreebsd) makeMinimal;
};
libnetbsd = self.callPackage ./pkgs/libnetbsd/package.nix { inherit (buildFreebsd) makeMinimal; };

mkDerivation = self.callPackage ./pkgs/mkDerivation.nix {
inherit stdenv;
inherit (buildFreebsd) makeMinimal install tsort;
};

makeMinimal = self.callPackage ./pkgs/makeMinimal.nix {
inherit (self) make;
};

makeMinimal = self.callPackage ./pkgs/makeMinimal.nix { inherit (self) make; };
}
9 changes: 6 additions & 3 deletions pkgs/os-specific/bsd/freebsd/pkgs/boot-install.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{ buildPackages, freebsd-lib }:

# Wrap NetBSD's install
buildPackages.writeShellScriptBin "boot-install" (freebsd-lib.install-wrapper + ''
buildPackages.writeShellScriptBin "boot-install" (
freebsd-lib.install-wrapper
+ ''
${buildPackages.netbsd.install}/bin/xinstall "''${args[@]}"
'')
${buildPackages.netbsd.install}/bin/xinstall "''${args[@]}"
''
)
205 changes: 112 additions & 93 deletions pkgs/os-specific/bsd/freebsd/pkgs/compat/package.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{ lib, stdenv, mkDerivation, patchesRoot
, bsdSetupHook, freebsdSetupHook
, makeMinimal, boot-install
, which
, freebsd-lib
, expat, zlib,
{
lib,
stdenv,
mkDerivation,
patchesRoot,
bsdSetupHook,
freebsdSetupHook,
makeMinimal,
boot-install,
which,
freebsd-lib,
expat,
zlib,
}:

let
Expand All @@ -13,90 +20,95 @@ in
mkDerivation rec {
pname = "compat";
path = "tools/build";
extraPaths = [
"lib/libc/db"
"lib/libc/stdlib" # getopt
"lib/libc/gen" # getcap
"lib/libc/locale" # rpmatch
] ++ lib.optionals stdenv.hostPlatform.isLinux [
"lib/libc/string" # strlcpy
"lib/libutil"
] ++ [
"contrib/libc-pwcache"
"contrib/libc-vis"
"sys/libkern"
"sys/kern/subr_capability.c"

# Take only individual headers, or else we will clobber native libc, etc.

"sys/rpc/types.h"

# Listed in Makekfile as INC
"include/mpool.h"
"include/ndbm.h"
"include/err.h"
"include/stringlist.h"
"include/a.out.h"
"include/nlist.h"
"include/db.h"
"include/getopt.h"
"include/nl_types.h"
"include/elf.h"
"sys/sys/ctf.h"

# Listed in Makekfile as SYSINC

"sys/sys/capsicum.h"
"sys/sys/caprights.h"
"sys/sys/imgact_aout.h"
"sys/sys/nlist_aout.h"
"sys/sys/nv.h"
"sys/sys/dnv.h"
"sys/sys/cnv.h"

"sys/sys/elf32.h"
"sys/sys/elf64.h"
"sys/sys/elf_common.h"
"sys/sys/elf_generic.h"
"sys/${mkBsdArch stdenv}/include"
] ++ lib.optionals stdenv.hostPlatform.isx86 [
"sys/x86/include"
] ++ [

"sys/sys/queue.h"
"sys/sys/md5.h"
"sys/sys/sbuf.h"
"sys/sys/tree.h"
"sys/sys/font.h"
"sys/sys/consio.h"
"sys/sys/fnv_hash.h"

"sys/crypto/chacha20/_chacha.h"
"sys/crypto/chacha20/chacha.h"
# included too, despite ".c"
"sys/crypto/chacha20/chacha.c"

"sys/fs"
"sys/ufs"
"sys/sys/disk"

"lib/libcapsicum"
"lib/libcasper"
];
extraPaths =
[
"lib/libc/db"
"lib/libc/stdlib" # getopt
"lib/libc/gen" # getcap
"lib/libc/locale" # rpmatch
]
++ lib.optionals stdenv.hostPlatform.isLinux [
"lib/libc/string" # strlcpy
"lib/libutil"
]
++ [
"contrib/libc-pwcache"
"contrib/libc-vis"
"sys/libkern"
"sys/kern/subr_capability.c"

# Take only individual headers, or else we will clobber native libc, etc.

"sys/rpc/types.h"

# Listed in Makekfile as INC
"include/mpool.h"
"include/ndbm.h"
"include/err.h"
"include/stringlist.h"
"include/a.out.h"
"include/nlist.h"
"include/db.h"
"include/getopt.h"
"include/nl_types.h"
"include/elf.h"
"sys/sys/ctf.h"

# Listed in Makekfile as SYSINC

"sys/sys/capsicum.h"
"sys/sys/caprights.h"
"sys/sys/imgact_aout.h"
"sys/sys/nlist_aout.h"
"sys/sys/nv.h"
"sys/sys/dnv.h"
"sys/sys/cnv.h"

"sys/sys/elf32.h"
"sys/sys/elf64.h"
"sys/sys/elf_common.h"
"sys/sys/elf_generic.h"
"sys/${mkBsdArch stdenv}/include"
]
++ lib.optionals stdenv.hostPlatform.isx86 [ "sys/x86/include" ]
++ [

"sys/sys/queue.h"
"sys/sys/md5.h"
"sys/sys/sbuf.h"
"sys/sys/tree.h"
"sys/sys/font.h"
"sys/sys/consio.h"
"sys/sys/fnv_hash.h"

"sys/crypto/chacha20/_chacha.h"
"sys/crypto/chacha20/chacha.h"
# included too, despite ".c"
"sys/crypto/chacha20/chacha.c"

"sys/fs"
"sys/ufs"
"sys/sys/disk"

"lib/libcapsicum"
"lib/libcasper"
];

patches = [
/${patchesRoot}/compat-install-dirs.patch
/${patchesRoot}/compat-fix-typedefs-locations.patch
];

preBuild = ''
NIX_CFLAGS_COMPILE+=' -I../../include -I../../sys'
preBuild =
''
NIX_CFLAGS_COMPILE+=' -I../../include -I../../sys'
cp ../../sys/${mkBsdArch stdenv}/include/elf.h ../../sys/sys
cp ../../sys/${mkBsdArch stdenv}/include/elf.h ../../sys/sys/${mkBsdArch stdenv}
'' + lib.optionalString stdenv.hostPlatform.isx86 ''
cp ../../sys/x86/include/elf.h ../../sys/x86
'';
cp ../../sys/${mkBsdArch stdenv}/include/elf.h ../../sys/sys
cp ../../sys/${mkBsdArch stdenv}/include/elf.h ../../sys/sys/${mkBsdArch stdenv}
''
+ lib.optionalString stdenv.hostPlatform.isx86 ''
cp ../../sys/x86/include/elf.h ../../sys/x86
'';

setupHooks = [
../../../../../build-support/setup-hooks/role.bash
Expand All @@ -109,13 +121,17 @@ mkDerivation rec {
'';

nativeBuildInputs = [
bsdSetupHook freebsdSetupHook
bsdSetupHook
freebsdSetupHook
makeMinimal
boot-install

which
];
buildInputs = [ expat zlib ];
buildInputs = [
expat
zlib
];

makeFlags = [
"STRIP=-s" # flag to install, not command
Expand All @@ -124,12 +140,15 @@ mkDerivation rec {
"INSTALL=boot-install"
];

preIncludes = ''
mkdir -p $out/{0,1}-include
cp --no-preserve=mode -r cross-build/include/common/* $out/0-include
'' + lib.optionalString stdenv.hostPlatform.isLinux ''
cp --no-preserve=mode -r cross-build/include/linux/* $out/1-include
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
cp --no-preserve=mode -r cross-build/include/darwin/* $out/1-include
'';
preIncludes =
''
mkdir -p $out/{0,1}-include
cp --no-preserve=mode -r cross-build/include/common/* $out/0-include
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
cp --no-preserve=mode -r cross-build/include/linux/* $out/1-include
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
cp --no-preserve=mode -r cross-build/include/darwin/* $out/1-include
'';
}
Loading

0 comments on commit f571081

Please sign in to comment.