Compare commits
No commits in common. "c7975eb119459b25d490d62e93949ff3aefd2e70" and "9e849b95a8e0d6630d576c8794ecfaebff11601b" have entirely different histories.
c7975eb119
...
9e849b95a8
6 changed files with 185 additions and 24 deletions
2
.envrc
2
.envrc
|
@ -1 +1 @@
|
||||||
use nix
|
use flake
|
20
default.nix
20
default.nix
|
@ -9,28 +9,26 @@ let
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
inherit (lib.filesystem) listFilesRecursive;
|
inherit (lib.filesystem) listFilesRecursive;
|
||||||
inherit (lib.strings) hasSuffix;
|
inherit (lib.strings) hasSuffix;
|
||||||
inherit (lib.attrsets) genAttrs;
|
|
||||||
|
|
||||||
nixosSystem = import (sources.nixpkgs + "/nixos/lib/eval-config.nix");
|
|
||||||
mkSystem =
|
mkSystem =
|
||||||
hostname:
|
hostname:
|
||||||
nixosSystem {
|
import (src.nixpkgs + "/nixos/lib/eval-config.nix") {
|
||||||
system = null;
|
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit sources;
|
inherit sources;
|
||||||
self = ./.;
|
self = ./.;
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
|
# This is used to pre-emptively set the hostPlatform for nixpkgs.
|
||||||
|
# Also, we set the system hostname here.
|
||||||
{ networking.hostName = hostname; }
|
{ networking.hostName = hostname; }
|
||||||
|
./hosts/common.nix
|
||||||
./hosts/${hostname}
|
./hosts/${hostname}
|
||||||
]
|
]
|
||||||
++ ((listFilesRecursive ./modules) |> filter (hasSuffix ".mod.nix"));
|
++ ((listFilesRecursive ./modules) |> filter (hasSuffix ".mod.nix"));
|
||||||
};
|
};
|
||||||
|
|
||||||
hosts = [
|
|
||||||
"temperance"
|
|
||||||
"hermit"
|
|
||||||
"tower"
|
|
||||||
];
|
|
||||||
in
|
in
|
||||||
genAttrs hosts mkSystem
|
{
|
||||||
|
temperance = mkSystem "temperance";
|
||||||
|
hermit = mkSystem "hermit";
|
||||||
|
tower = mkSystem "tower";
|
||||||
|
}
|
||||||
|
|
55
docs/dualboot.md
Normal file
55
docs/dualboot.md
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# Dualbooting NixOS and FreeBSD
|
||||||
|
|
||||||
|
Out of curiosity, I decided to dual-boot NixOS and FreeBSD on my laptop, sharing
|
||||||
|
one disk. I document the process here for future reference:
|
||||||
|
|
||||||
|
## Linux install
|
||||||
|
|
||||||
|
First, flash a stick with NixOS, then boot into it, wipe your disk, create two
|
||||||
|
partitions, one being boot, the other your main NixOS partition. Then, follow
|
||||||
|
these commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo su
|
||||||
|
|
||||||
|
cryptsetup luksFormat /dev/diskname/partition
|
||||||
|
|
||||||
|
cryptsetup open /dev/diskname/partition crypt
|
||||||
|
|
||||||
|
mkfs.btrfs -L nixos /dev/mapper/crypt
|
||||||
|
|
||||||
|
mount /dev/mapper/crypt /mnt
|
||||||
|
|
||||||
|
btrfs create subvolume /mnt/nix
|
||||||
|
btrfs create subvolume /mnt/home
|
||||||
|
btrfs create subvolume /mnt/persist
|
||||||
|
|
||||||
|
mkdir /mnt/boot
|
||||||
|
mount /dev/partition # boot partition
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, copy [my nixos flake](https://github.com/bloxx12/nichts) to `/mnt`, you
|
||||||
|
can remove it from there later on.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/bloxx12/nichts /mnt
|
||||||
|
```
|
||||||
|
|
||||||
|
In there, change the file system uuids to the correct ones, you can see them
|
||||||
|
using
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo blkid
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, install NixOS itself:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
nixos-install --impure --flake /mnt/nichts#<hostname> -j 1 --cores 2
|
||||||
|
```
|
||||||
|
|
||||||
|
Wait for that to finish, then reboot.
|
||||||
|
|
||||||
|
If your system works, great! if not, redo from the beginning.
|
||||||
|
|
||||||
|
After that, set up FreeBSD the following way:
|
50
hosts/common.nix
Normal file
50
hosts/common.nix
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# This is for packages I want in all systems.
|
||||||
|
# Keeping this list as small as possible is important,
|
||||||
|
# since these also get installed to server,
|
||||||
|
# which should have a small attack surface.
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib.meta) hiPrioSet;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
environment.systemPackages =
|
||||||
|
builtins.attrValues {
|
||||||
|
inherit (pkgs)
|
||||||
|
cachix
|
||||||
|
calc
|
||||||
|
delta
|
||||||
|
difftastic
|
||||||
|
eza
|
||||||
|
gcc
|
||||||
|
git
|
||||||
|
httpie
|
||||||
|
inetutils
|
||||||
|
jujutsu
|
||||||
|
just
|
||||||
|
lazygit
|
||||||
|
linuxHeaders
|
||||||
|
neofetch
|
||||||
|
microfetch
|
||||||
|
mprocs
|
||||||
|
nmap
|
||||||
|
ripgrep
|
||||||
|
smartmontools
|
||||||
|
television
|
||||||
|
trash-cli
|
||||||
|
util-linux
|
||||||
|
w3m
|
||||||
|
wireguard-tools
|
||||||
|
zip
|
||||||
|
zoxide
|
||||||
|
;
|
||||||
|
}
|
||||||
|
++ builtins.attrValues (hiPrioSet {
|
||||||
|
})
|
||||||
|
++ [ (lib.hiPrio pkgs.uutils-coreutils-noprefix) ];
|
||||||
|
# helix as the only editor, a reasonable choice.
|
||||||
|
environment.variables.EDITOR = "hx";
|
||||||
|
}
|
70
hosts/default.nix
Normal file
70
hosts/default.nix
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
{
|
||||||
|
sources,
|
||||||
|
nixpkgs,
|
||||||
|
self,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (builtins) filter map toString;
|
||||||
|
inherit (nixpkgs) lib;
|
||||||
|
inherit (lib.attrsets) recursiveUpdate;
|
||||||
|
inherit (lib.filesystem) listFilesRecursive;
|
||||||
|
inherit (lib.lists) concatLists flatten singleton;
|
||||||
|
inherit (lib.strings) hasSuffix;
|
||||||
|
inherit (lib) nixosSystem;
|
||||||
|
# NOTE: This was inspired by raf, and I find this
|
||||||
|
# to be quite a sane way of managing all modules in my flake.
|
||||||
|
|
||||||
|
mkSystem =
|
||||||
|
{
|
||||||
|
system,
|
||||||
|
hostname,
|
||||||
|
...
|
||||||
|
}@args:
|
||||||
|
nixosSystem {
|
||||||
|
specialArgs = recursiveUpdate {
|
||||||
|
inherit lib;
|
||||||
|
inputs = sources;
|
||||||
|
inherit self;
|
||||||
|
} args.specialArgs or { };
|
||||||
|
modules = concatLists [
|
||||||
|
# This is used to pre-emptively set the hostPlatform for nixpkgs.
|
||||||
|
# Also, we set the system hostname here.
|
||||||
|
(singleton {
|
||||||
|
networking.hostName = hostname;
|
||||||
|
nixpkgs.hostPlatform = system;
|
||||||
|
})
|
||||||
|
(
|
||||||
|
concatLists [
|
||||||
|
# configuration for the host, passed as an argument.
|
||||||
|
(singleton ./${hostname}/default.nix)
|
||||||
|
# common configuration, which all hosts share.
|
||||||
|
(singleton ./common.nix)
|
||||||
|
# Import all files called module.nix from my modules directory.
|
||||||
|
(map toString (listFilesRecursive ../modules) |> filter (hasSuffix "module.nix"))
|
||||||
|
(map toString (listFilesRecursive ../modules) |> filter (hasSuffix ".mod.nix"))
|
||||||
|
]
|
||||||
|
|> flatten
|
||||||
|
)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
temperance = mkSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
hostname = "temperance";
|
||||||
|
};
|
||||||
|
|
||||||
|
hermit = mkSystem {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
hostname = "hermit";
|
||||||
|
};
|
||||||
|
tower = mkSystem {
|
||||||
|
system = "aarch64-linux";
|
||||||
|
hostname = "tower";
|
||||||
|
};
|
||||||
|
# world = mkSystem {
|
||||||
|
# system = "x86_64-linux";
|
||||||
|
# hostname = "world";
|
||||||
|
# };
|
||||||
|
}
|
12
shell.nix
12
shell.nix
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
pkgs ? import <nixpkgs> { },
|
|
||||||
sources ? import ./npins,
|
|
||||||
}:
|
|
||||||
pkgs.mkShellNoCC {
|
|
||||||
|
|
||||||
packages = [
|
|
||||||
(pkgs.callPackage (sources.npins + "/npins.nix") { })
|
|
||||||
pkgs.nil
|
|
||||||
pkgs.nixfmt
|
|
||||||
];
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue