dotfiles
My PC Dotfiles & Websitegit clone https://github.com/maydayv7/dotfiles
commit fb76b086e0d6b544d9f8caccfbd96ff6353a1323 parent 25e7cd110057f4cb33d95977679f00cc3a3df7b3 Author: maydayv7 <maydayv7@gmail.com> Date: Mon, 4 Dec 2023 14:05:24 +0530 feat: Enable Secure Boot
Diffstat:
| M | README.md | | | 27 | +++++++++++++++++---------- |
| M | devices/Vortex/default.nix | | | 2 | +- |
| M | flake.lock | | | 239 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- |
| M | flake.nix | | | 6 | ++++++ |
| M | modules/README.md | | | 2 | +- |
| M | modules/hardware/boot.nix | | | 30 | +++++++++++++++++++++++++----- |
6 files changed, 282 insertions(+), 24 deletions(-)
diff --git a/README.md b/README.md @@ -40,8 +40,9 @@ This [repository](https://github.com/maydayv7/dotfiles) contains the configurati - Automatically builds and deploys my [Website](./site) - Authentication Credentials Management using the [`sops`](https://github.com/Mic92/sops-nix) Module and [`gnupg`](https://gnupg.org/) Keys - Comprehensive User Configuration using the tightly integrated [`home-manager`](https://github.com/nix-community/home-manager) module, with [support](./modules/user/default.nix) for configuring shared user configuration, global conditionals and user-specific configuration -- Support for Multiple Programming Language Development [`shells`](./shells) integrated with [`direnv`](https://direnv.net/) and [`lorri`](https://github.com/nix-community/lorri) - Ephemeral, Opt-In File System State using the [`impermanence`](https://github.com/nix-community/impermanence) module and [ZFS](https://zfsonlinux.org/) +- Support for Secure Boot using [`lanzaboote`](https://github.com/nix-community/lanzaboote) +- Support for Multiple Programming Language Development [`shells`](./shells) integrated with [`direnv`](https://direnv.net/) and [`lorri`](https://github.com/nix-community/lorri) - Auto-Magic using [`flake-utils-plus`](https://github.com/gytis-ivaskevicius/flake-utils-plus) helper functions - Automatic `packages` Updates using [`update.sh`](./packages/update.sh) - Install Media and Device Images using [`nixos-generators`](https://github.com/nix-community/nixos-generators) image generation modules @@ -120,9 +121,7 @@ github:maydayv7/dotfiles ├───overlays ├───packages │ └───x86_64-linux -│ ├───dotfiles: package 'Dotfiles-v15.0' -│ ├───nixos: package 'nixos' -│ └───website: package 'website-stable' +│ └───nixos: package 'nixos' ├───templates │ └───default: template: My NixOS Configuration └───vmConfigurations @@ -269,7 +268,7 @@ _Note that the `install` script automatically creates and labels all the require | SWAP Area | swap | swap | 4G | | DATA Partition | Files | ZFS | 10G | -> **Note** +> **Note:** > For the `advanced` filesystem scheme only #### Procedure @@ -305,10 +304,6 @@ _May change according to available hardware_ - UEFI Compatible System - Intel CPU + iGPU -### License - -All the files and scripts in this repository are licensed under the very permissive MIT [License](./LICENSE), allowing you to freely use, modify, copy, distribute, sell or give away the software, only requirement being that the license and copyright notice must be provided with it - ### Branches There are two branches, [`stable`](../../tree/stable) and [`develop`](../../tree/develop) (when required). The `stable` branch consists of configuration that builds without failure, and the `develop` branch is a bleeding-edge testbed @@ -321,6 +316,18 @@ While rebuilding system with Flakes, make sure that any file with unstaged chang To boot into a different build generation, hold down the Spacebar (for `efi`) or the `Shift`/`Esc` key (for `mbr`) upon startup to access the boot menu +<details> +<summary>Secure Boot</summary> + +To configure Secure Boot, first install the system by using the `efi` loader, then follow [these](https://github.com/nix-community/lanzaboote/blob/v0.3.0/docs/QUICK_START.md) instructions and set `hardware.boot.loader` to `secure` + +_If the `advanced` filesystem scheme is used, the keys need to be created after `/etc/secureboot` is persisted_ + +> **Note:** +> Secure Boot is only supported in EFI Mode + +</details> + #### Cache The system build cache is publicly hosted using [Cachix](https://www.cachix.org) at [maydayv7-dotfiles](https://app.cachix.org/cache/maydayv7-dotfiles), and can be used while building the system to prevent rebuilding from scratch @@ -424,6 +431,7 @@ You can navigate to the `README`s present in the various directories to know mor - Support declarative [Flatpak](https://flatpak.org/) application install - Update Nix to version 2.19 - Enable Security & Hardening settings by default +- Support Secure Boot using [`lanzaboote`](https://github.com/nix-community/lanzaboote) - Allow patching Default Package Channel - Separate `games` and `laptop` module - Show package delta using [`nvd`](https://gitlab.com/khumba/nvd) @@ -633,7 +641,6 @@ You can navigate to the `README`s present in the various directories to know mor <summary><b>Known Limitations</b></summary> - It is a hard requirement to clone the repository to `/etc/nixos` in order to use it as intended -- Secure Boot isn't supported yet - Home Configuration can't be decoupled from System - Lack of automatic script checking - Currently using a workaround for CI due to NixOS/nix#3978 diff --git a/devices/Vortex/default.nix b/devices/Vortex/default.nix @@ -12,7 +12,7 @@ imports = [./secrets]; hardware = { - boot = "efi"; + boot = "secure"; cores = 8; filesystem = "advanced"; support = ["laptop" "mobile" "printer" "virtualisation"]; diff --git a/flake.lock b/flake.lock @@ -130,6 +130,66 @@ "type": "github" } }, + "boot": { + "inputs": { + "crane": "crane", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks-nix": "pre-commit-hooks-nix", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1682802423, + "narHash": "sha256-Fb5TeRTdvUlo/5Yi2d+FC8a6KoRLk2h1VE0/peMhWPs=", + "owner": "nix-community", + "repo": "lanzaboote", + "rev": "64b903ca87d18cef2752c19c098af275c6e51d63", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "v0.3.0", + "repo": "lanzaboote", + "type": "github" + } + }, + "crane": { + "inputs": { + "flake-compat": [ + "boot", + "flake-compat" + ], + "flake-utils": [ + "boot", + "flake-utils" + ], + "nixpkgs": [ + "boot", + "nixpkgs" + ], + "rust-overlay": [ + "boot", + "rust-overlay" + ] + }, + "locked": { + "lastModified": 1681177078, + "narHash": "sha256-ZNIjBDou2GOabcpctiQykEQVkI8BDwk7TyvlWlI4myE=", + "owner": "ipetkov", + "repo": "crane", + "rev": "0c9f468ff00576577d83f5019a66c557ede5acf6", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "filters": { "locked": { "lastModified": 1694857738, @@ -164,6 +224,22 @@ "flake-compat_2": { "flake": false, "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_3": { + "flake": false, + "locked": { "lastModified": 1696426674, "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", @@ -177,9 +253,48 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "boot", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1680392223, + "narHash": "sha256-n3g7QFr85lDODKt250rkZj2IFS3i4/8HBU2yKHO3tqw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "dcc36e45d054d7bb554c9cdab69093debd91a0b5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { - "systems": "systems_3" + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_4" }, "locked": { "lastModified": 1694529238, @@ -306,6 +421,28 @@ "type": "github" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "boot", + "pre-commit-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "hardware": { "locked": { "lastModified": 1701020860, @@ -408,6 +545,22 @@ "type": "github" } }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1693714546, @@ -455,6 +608,37 @@ "type": "github" } }, + "pre-commit-hooks-nix": { + "inputs": { + "flake-compat": [ + "boot", + "flake-compat" + ], + "flake-utils": [ + "boot", + "flake-utils" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "boot", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1681413034, + "narHash": "sha256-/t7OjNQcNkeWeSq/CFLYVBfm+IEnkjoSm9iKvArnUUI=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "d3de8f69ca88fb6f8b09e5b598be5ac98d28ede5", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "proprietary": { "inputs": { "nixpkgs": [ @@ -478,6 +662,7 @@ }, "root": { "inputs": { + "boot": "boot", "filters": "filters", "flatpak": "flatpak", "formatter": "formatter", @@ -493,13 +678,38 @@ "proprietary": "proprietary", "sops": "sops", "stylix": "stylix", - "systems": "systems_2", + "systems": "systems_3", "unstable": "unstable", "utils": "utils_2", "wfvm": "wfvm", "windows": "windows" } }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "boot", + "flake-utils" + ], + "nixpkgs": [ + "boot", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1682129965, + "narHash": "sha256-1KRPIorEL6pLpJR04FwAqqnt4Tzcm4MqD84yhlD+XSk=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "2c417c0460b788328220120c698630947547ee83", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "sops": { "inputs": { "nixpkgs": [ @@ -533,7 +743,7 @@ "base16-kitty": "base16-kitty", "base16-tmux": "base16-tmux", "base16-vim": "base16-vim", - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "home-manager": [ "home-manager" ], @@ -571,6 +781,21 @@ } }, "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { "flake": false, "locked": { "lastModified": 1, @@ -583,7 +808,7 @@ "type": "path" } }, - "systems_3": { + "systems_4": { "locked": { "lastModified": 1681028828, "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", @@ -616,7 +841,7 @@ }, "utils": { "inputs": { - "systems": "systems" + "systems": "systems_2" }, "locked": { "lastModified": 1694529238, @@ -634,7 +859,7 @@ }, "utils_2": { "inputs": { - "flake-utils": "flake-utils" + "flake-utils": "flake-utils_2" }, "locked": { "lastModified": 1696331477, @@ -672,7 +897,7 @@ }, "windows": { "inputs": { - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat_3", "nixpkgs": [ "unstable" ] diff --git a/flake.nix b/flake.nix @@ -97,6 +97,12 @@ # Hardware Support hardware.url = "github:nixos/nixos-hardware"; + # Secure Boot + boot = { + url = "github:nix-community/lanzaboote/v0.3.0"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # Authentication Credentials Manager sops = { url = "github:Mic92/sops-nix"; diff --git a/modules/README.md b/modules/README.md @@ -32,7 +32,7 @@ The `modules` directory contains custom-made pure Flakes-compatible configuratio - [`hardware`](./hardware): Module that configures device and additional hardware - - - `boot`: Supported Boot Firmware - `"mbr" / "efi"` + - `boot`: Supported Boot Firmware - `"mbr" / "efi" / "secure"` - `cores`: Number of CPU Cores - Ex. `4` - `filesystem`: Disk File System Choice - `"simple" / "advanced"` - - `persist`: System Files to Preserve across Reboots (while using `advanced` File System Layout) diff --git a/modules/hardware/boot.nix b/modules/hardware/boot.nix @@ -2,15 +2,19 @@ config, options, lib, + inputs, + pkgs, ... }: let inherit (lib) mkDefault mkForce mkIf mkMerge mkOption optional types; loader = config.hardware.boot; in { + imports = [inputs.boot.nixosModules.lanzaboote]; + options.hardware.boot = mkOption { description = "Supported Boot Firmware"; - type = types.nullOr (types.enum ["mbr" "efi"]); - default = "mbr"; + type = types.nullOr (types.enum ["mbr" "efi" "secure"]); + default = "efi"; }; ## Boot Configuration ## @@ -46,8 +50,10 @@ in { # Boot Loader loader = { timeout = mkDefault 0; - grub.enable = mkDefault false; efi.canTouchEfiVariables = true; + + grub.enable = mkDefault false; + systemd-boot.enable = mkDefault false; }; }; } @@ -68,9 +74,23 @@ in { ## SystemD EFI Boot Loader ## (mkIf (loader == "efi") { boot.loader.systemd-boot = { - enable = true; + enable = mkForce true; editor = false; - configurationLimit = 100; + configurationLimit = 15; + }; + }) + + ## Secure Boot (EFI Only) ## + (mkIf (loader == "secure") rec { + boot.lanzaboote = { + enable = true; + pkiBundle = "/etc/secureboot"; + configurationLimit = 15; + }; + + environment = { + systemPackages = [pkgs.sbctl]; + persist.directories = [boot.lanzaboote.pkiBundle]; }; }) ]);