diff --git a/.envrc b/.envrc index 8392d15..1d953f4 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use flake \ No newline at end of file +use nix diff --git a/default.nix b/default.nix index f01ab85..1950006 100644 --- a/default.nix +++ b/default.nix @@ -9,26 +9,28 @@ let inherit (pkgs) lib; inherit (lib.filesystem) listFilesRecursive; inherit (lib.strings) hasSuffix; + inherit (lib.attrsets) genAttrs; + nixosSystem = import (sources.nixpkgs + "/nixos/lib/eval-config.nix"); mkSystem = hostname: - import (src.nixpkgs + "/nixos/lib/eval-config.nix") { + nixosSystem { + system = null; specialArgs = { inherit sources; self = ./.; }; modules = [ - # This is used to pre-emptively set the hostPlatform for nixpkgs. - # Also, we set the system hostname here. { networking.hostName = hostname; } - ./hosts/common.nix ./hosts/${hostname} ] ++ ((listFilesRecursive ./modules) |> filter (hasSuffix ".mod.nix")); }; + + hosts = [ + "temperance" + "hermit" + "tower" + ]; in -{ - temperance = mkSystem "temperance"; - hermit = mkSystem "hermit"; - tower = mkSystem "tower"; -} +genAttrs hosts mkSystem diff --git a/docs/dualboot.md b/docs/dualboot.md deleted file mode 100644 index e1571e5..0000000 --- a/docs/dualboot.md +++ /dev/null @@ -1,55 +0,0 @@ -# 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# -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: diff --git a/hosts/common.nix b/hosts/common.nix deleted file mode 100644 index 0405615..0000000 --- a/hosts/common.nix +++ /dev/null @@ -1,50 +0,0 @@ -# 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"; -} diff --git a/hosts/default.nix b/hosts/default.nix deleted file mode 100644 index 12ee7fd..0000000 --- a/hosts/default.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ - 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"; - # }; -} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..505408b --- /dev/null +++ b/shell.nix @@ -0,0 +1,12 @@ +{ + pkgs ? import { }, + sources ? import ./npins, +}: +pkgs.mkShellNoCC { + + packages = [ + (pkgs.callPackage (sources.npins + "/npins.nix") { }) + pkgs.nil + pkgs.nixfmt + ]; +}