Add an install of nixbsd.

This commit is contained in:
Tom Alexander
2026-08-07 18:42:28 -04:00
parent d4dc7e1f59
commit 1fc31fbfea
2 changed files with 320 additions and 0 deletions

111
nix/nixbsd/flake.nix Normal file
View File

@@ -0,0 +1,111 @@
# nix build .#computer.vm
# result/bin/run-nixbsd-base-vm
{
description = "NixBSD Flake";
inputs = {
nixpkgs.url = "https://channels.nixos.org/nixos-unstable-small/nixexprs.tar.xz";
# nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixbsd = {
url = "github:nixos-bsd/nixbsd";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
nixbsd,
...
}@inputs:
let
forAllSystems =
func:
builtins.listToAttrs (
map (system: {
name = system;
value = func system;
}) nixpkgs.lib.systems.flakeExposed
);
makeImage =
buildPlatform: conf:
let
extended = conf.extendModules {
modules = [
{
config.nixpkgs.buildPlatform = buildPlatform;
}
];
};
in
extended.config.system.build
// {
# appease `nix flake show`
type = "derivation";
name = "system-build";
closureInfo = extended.pkgs.closureInfo {
rootPaths = [ extended.config.system.build.toplevel.drvPath ];
};
vmClosureInfo = extended.pkgs.closureInfo {
rootPaths = [ extended.config.system.build.vm.drvPath ];
};
system = extended.config.system.build.toplevel;
inherit (extended) pkgs config;
};
in
{
nixosConfigurations.computer = nixbsd.lib.nixbsdSystem {
system = "x86_64-freebsd";
modules = [
(
{ config, lib, ... }:
{
nixpkgs.hostPlatform = "x86_64-freebsd";
networking.hostName = "computer";
users.users.root.initialPassword = "toor";
# Don't make me wait for an address...
networking.dhcpcd.wait = "background";
users.users.talexander = {
isNormalUser = true;
description = "me";
extraGroups = [ "wheel" ];
inherit (config.users.users.root) initialPassword;
};
services.sshd.enable = true;
boot.loader.stand-freebsd.enable = true;
fileSystems."/" = {
device = "/dev/gpt/nixos";
fsType = "ufs";
};
fileSystems."/boot" = {
device = "/dev/msdosfs/ESP";
fsType = "msdosfs";
};
virtualisation.vmVariant.virtualisation.diskImage = "./${config.system.name}.qcow2";
system.stateVersion = "26.11";
}
)
];
};
packages = forAllSystems (
system:
nixpkgs.lib.mapAttrs (name: makeImage system) self.nixosConfigurations
// {
tools =
nixpkgs.legacyPackages.${system}.callPackages "${nixbsd}/modules/installer/tools/package.nix"
{ };
}
);
};
}