Skip to content

Commit 2b8f96c

Browse files
authored
Merge pull request #320475 from rhelmot/freebsd-various2
freebsd: various new packages to support a NixBSD system
2 parents 24ced04 + e589fdb commit 2b8f96c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1244
-127
lines changed

pkgs/os-specific/bsd/freebsd/lib/default.nix

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
{ version }:
1+
{
2+
version,
3+
lib,
4+
writeText,
5+
}:
26

37
{
48
inherit version;
@@ -15,4 +19,65 @@
1519
.${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;
1620

1721
install-wrapper = builtins.readFile ../../lib/install-wrapper.sh;
22+
23+
# this function takes a list of patches and a list of paths and returns a list of derivations,
24+
# one per file that is patched, containing the actual patch contents. This allows us to have
25+
# extract only the patches that are relevant for a given subset of the source tree.
26+
# note: the "list of patches" input can be a directory containing patch files, a path or a list of valid inputs to this argument, recursively.
27+
filterPatches =
28+
patches: paths:
29+
let
30+
isDir =
31+
file:
32+
let
33+
base = baseNameOf file;
34+
type = (builtins.readDir (dirOf file)).${base} or null;
35+
in
36+
file == /. || type == "directory";
37+
consolidatePatches =
38+
patches:
39+
if (lib.isDerivation patches) then
40+
[ patches ]
41+
else if (builtins.isPath patches) then
42+
(if (isDir patches) then (lib.filesystem.listFilesRecursive patches) else [ patches ])
43+
else if (builtins.isList patches) then
44+
(lib.flatten (builtins.map consolidatePatches patches))
45+
else
46+
throw "Bad patches - must be path or derivation or list thereof";
47+
consolidated = consolidatePatches patches;
48+
splitPatch =
49+
patchFile:
50+
let
51+
allLines' = lib.strings.splitString "\n" (builtins.readFile patchFile);
52+
allLines = builtins.filter (
53+
line: !((lib.strings.hasPrefix "diff --git" line) || (lib.strings.hasPrefix "index " line))
54+
) allLines';
55+
foldFunc =
56+
a: b:
57+
if ((lib.strings.hasPrefix "--- " b) || (lib.strings.hasPrefix "diff --git " b)) then
58+
(a ++ [ [ b ] ])
59+
else
60+
((lib.lists.init a) ++ (lib.lists.singleton ((lib.lists.last a) ++ [ b ])));
61+
partitionedPatches' = lib.lists.foldl foldFunc [ [ ] ] allLines;
62+
partitionedPatches =
63+
if (builtins.length partitionedPatches' > 1) then
64+
(lib.lists.drop 1 partitionedPatches')
65+
else
66+
(throw "${patchFile} does not seem to be a unified patch (diff -u). this is required for FreeBSD.");
67+
filterFunc =
68+
patchLines:
69+
let
70+
prefixedPath = builtins.elemAt (builtins.split " |\t" (builtins.elemAt patchLines 1)) 2;
71+
unfixedPath = lib.path.subpath.join (lib.lists.drop 1 (lib.path.subpath.components prefixedPath));
72+
in
73+
lib.lists.any (included: lib.path.hasPrefix (/. + ("/" + included)) (/. + ("/" + unfixedPath))) (
74+
paths
75+
);
76+
filteredLines = builtins.filter filterFunc partitionedPatches;
77+
derive = patchLines: writeText "freebsd-patch" (lib.concatLines patchLines);
78+
derivedPatches = builtins.map derive filteredLines;
79+
in
80+
derivedPatches;
81+
in
82+
lib.lists.concatMap splitPatch consolidated;
1883
}

pkgs/os-specific/bsd/freebsd/package-set.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
versionData,
88
buildFreebsd,
99
patchesRoot,
10+
writeText,
1011
}:
1112

1213
self:
@@ -39,6 +40,7 @@ lib.packagesFromDirectoryRecursive {
3940
]
4041
)
4142
);
43+
inherit lib writeText;
4244
};
4345

4446
# The manual callPackages below should in principle be unnecessary, but are
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff --git a/lib/libifconfig/Makefile b/lib/libifconfig/Makefile
2+
index 6bdb202bec1d..ebc626901cfc 100644
3+
--- a/lib/libifconfig/Makefile
4+
+++ b/lib/libifconfig/Makefile
5+
@@ -1,7 +1,6 @@
6+
7+
PACKAGE= lib${LIB}
8+
LIB= ifconfig
9+
-INTERNALLIB= true
10+
11+
LIBADD= m
12+
13+
@@ -36,8 +35,8 @@ SRCS+= ${GEN}
14+
CLEANFILES+= ${GEN}
15+
16+
# If libifconfig become public uncomment those two lines
17+
-#INCSDIR= ${INCLUDEDIR}
18+
-#INCS= libifconfig.h libifconfig_sfp.h libifconfig_sfp_tables.h
19+
+INCSDIR= ${INCLUDEDIR}
20+
+INCS= libifconfig.h libifconfig_sfp.h libifconfig_sfp_tables.h
21+
22+
#MAN= libifconfig.3
23+
24+
diff --git a/lib/libifconfig/Symbol.map b/lib/libifconfig/Symbol.map
25+
index 2d80fb31652a..8b08947112e5 100644
26+
--- a/lib/libifconfig/Symbol.map
27+
+++ b/lib/libifconfig/Symbol.map
28+
@@ -2,6 +2,8 @@ FBSD_1.6 {
29+
ifconfig_bridge_get_bridge_status;
30+
ifconfig_bridge_free_bridge_status;
31+
ifconfig_carp_get_info;
32+
+ ifconfig_carp_get_vhid;
33+
+ ifconfig_carp_set_info;
34+
ifconfig_close;
35+
ifconfig_create_interface;
36+
ifconfig_create_interface_vlan;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c
2+
index 2fcc94e40818..7de6da1bb20e 100644
3+
--- a/sbin/mount/mount.c
4+
+++ b/sbin/mount/mount.c
5+
@@ -155,12 +155,9 @@ exec_mountprog(const char *name, const char *execname, char *const argv[])
6+
EXIT(1);
7+
case 0: /* Child. */
8+
/* Go find an executable. */
9+
- execvP(execname, _PATH_SYSPATH, argv);
10+
+ execvp(execname, argv);
11+
if (errno == ENOENT) {
12+
xo_warn("exec %s not found", execname);
13+
- if (execname[0] != '/') {
14+
- xo_warnx("in path: %s", _PATH_SYSPATH);
15+
- }
16+
}
17+
EXIT(1);
18+
default: /* Parent. */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/libexec/rc/rc b/libexec/rc/rc
2+
index 0ea61a4b2c0a..d9bfb228224c 100644
3+
--- a/libexec/rc/rc
4+
+++ b/libexec/rc/rc
5+
@@ -87,6 +87,12 @@ if ! [ -e ${firstboot_sentinel} ]; then
6+
skip_firstboot="-s firstboot"
7+
fi
8+
9+
+if [ -z "$USER_LOGIN" ]; then
10+
+ skip="$skip -s user"
11+
+else
12+
+ skip="$skip -k user"
13+
+fi
14+
+
15+
# Do a first pass to get everything up to $early_late_divider so that
16+
# we can do a second pass that includes $local_startup directories
17+
#
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ mkDerivation }:
2+
mkDerivation {
3+
path = "usr.bin/bintrans";
4+
MK_TESTS = "no";
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{ mkDerivation, libgeom }:
2+
mkDerivation {
3+
path = "sbin/bsdlabel";
4+
extraPaths = [ "sys/geom" ];
5+
buildInputs = [ libgeom ];
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{ mkDerivation }:
2+
mkDerivation {
3+
path = "usr.bin/cap_mkdb";
4+
5+
MK_TESTS = "no";
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ mkDerivation }:
2+
mkDerivation {
3+
path = "usr.sbin/daemon";
4+
MK_TESTS = "no";
5+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{ mkDerivation }:
2+
mkDerivation {
3+
path = "sbin/devfs";
4+
5+
# These config files are mostly examples and not super useful
6+
# in nixbsd
7+
postPatch = ''
8+
sed -i 's/^CONFS=.*$//' $BSDSRCDIR/sbin/devfs/Makefile
9+
'';
10+
}

0 commit comments

Comments
 (0)