From 1fc31fbfea8d86e4860cecc537ab314657fbffdd Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 7 Aug 2026 18:42:28 -0400 Subject: [PATCH] Add an install of nixbsd. --- nix/nixbsd/flake.lock | 209 ++++++++++++++++++++++++++++++++++++++++++ nix/nixbsd/flake.nix | 111 ++++++++++++++++++++++ 2 files changed, 320 insertions(+) create mode 100644 nix/nixbsd/flake.lock create mode 100644 nix/nixbsd/flake.nix diff --git a/nix/nixbsd/flake.lock b/nix/nixbsd/flake.lock new file mode 100644 index 0000000..135e33e --- /dev/null +++ b/nix/nixbsd/flake.lock @@ -0,0 +1,209 @@ +{ + "nodes": { + "cppnix": { + "inputs": { + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "git-hooks-nix": "git-hooks-nix", + "nixpkgs": [ + "nixbsd", + "nixpkgs" + ], + "nixpkgs-23-11": "nixpkgs-23-11", + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1781190364, + "narHash": "sha256-uP1AYpXYHdzmuz+a4AcScRIHa1uy7l9ObZovS0OqN70=", + "owner": "nixos", + "repo": "nix", + "rev": "ce9fda43e5cb8d2f6c57c7240d05d10ad0415799", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "revCount": 69, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixbsd", + "cppnix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1778716662, + "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "git-hooks-nix": { + "inputs": { + "flake-compat": [ + "nixbsd", + "cppnix" + ], + "gitignore": [ + "nixbsd", + "cppnix" + ], + "nixpkgs": [ + "nixbsd", + "cppnix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1778507602, + "narHash": "sha256-kTwur1wV+01SdqskVMSo6JMEpg71ps3HpbFY2GsflKs=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "61ab0e80d9c7ab14c256b5b453d8b3fb0189ba0a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "mini-tmpfiles": { + "inputs": { + "nixpkgs": [ + "nixbsd", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1742754557, + "narHash": "sha256-nGxgiNhA94eSl8jcQwCboJ5Ed132z8yrFdOoT+rf8bE=", + "owner": "nixos-bsd", + "repo": "mini-tmpfiles", + "rev": "534ee577692c7092fdcd035f89bc29b663c6f9ca", + "type": "github" + }, + "original": { + "owner": "nixos-bsd", + "repo": "mini-tmpfiles", + "type": "github" + } + }, + "nixbsd": { + "inputs": { + "cppnix": "cppnix", + "flake-compat": "flake-compat_2", + "mini-tmpfiles": "mini-tmpfiles", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1783703343, + "narHash": "sha256-kt38BGQYWXUtNgTV/hCx0tf8IZJFuEGE3/IYoRutha4=", + "owner": "nixos-bsd", + "repo": "nixbsd", + "rev": "2b512eda58e6d77378bd20d6027802b158942e24", + "type": "github" + }, + "original": { + "owner": "nixos-bsd", + "repo": "nixbsd", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1783693695, + "narHash": "sha256-4eOaoE0Z2OR28W/vdzp1H9Qkl84ajh7tdVsfNwTuG5U=", + "rev": "dc29ee8fa098c86053cc8ef25594738f28be5b6b", + "type": "tarball", + "url": "https://releases.nixos.org/nixos/unstable-small/nixos-26.11pre1032146.dc29ee8fa098/nixexprs.tar.xz" + }, + "original": { + "type": "tarball", + "url": "https://channels.nixos.org/nixos-unstable-small/nixexprs.tar.xz" + } + }, + "nixpkgs-23-11": { + "locked": { + "lastModified": 1717159533, + "narHash": "sha256-oamiKNfr2MS6yH64rUn99mIZjc45nGJlj9eGth/3Xuw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a62e6edd6d5e1fa0329b8653c801147986f8d446", + "type": "github" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "root": { + "inputs": { + "nixbsd": "nixbsd", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/nixbsd/flake.nix b/nix/nixbsd/flake.nix new file mode 100644 index 0000000..9e507ae --- /dev/null +++ b/nix/nixbsd/flake.nix @@ -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" + { }; + } + ); + }; +}