Compare commits
16 Commits
cac57806b5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 976e1663aa | |||
| eb4609613e | |||
| 41e50f98b5 | |||
| 6ef3f87d16 | |||
| f878369896 | |||
| 179ced171d | |||
| a226d68df7 | |||
| 8e6cfa47b8 | |||
| 9d702285b6 | |||
| ef128b240e | |||
| f66c8792c4 | |||
| dde6dc3246 | |||
| 0d3d41c8f9 | |||
| 8c566ed869 | |||
| eb09fdf8fd | |||
| 650ae4ef16 |
8
.vscode/extensions.json
vendored
8
.vscode/extensions.json
vendored
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"davidanson.vscode-markdownlint"
|
||||
]
|
||||
}
|
||||
"recommendations": [
|
||||
"davidanson.vscode-markdownlint"
|
||||
]
|
||||
}
|
||||
|
||||
11
.vscode/mcp.json
vendored
11
.vscode/mcp.json
vendored
@@ -1,10 +1 @@
|
||||
{
|
||||
"servers": {
|
||||
"nixos": {
|
||||
"command": "uvx",
|
||||
"args": [
|
||||
"mcp-nixos"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
105
AGENTS.md
Normal file
105
AGENTS.md
Normal file
@@ -0,0 +1,105 @@
|
||||
> Note: This document was AI-generated and reviewed by a maintainer.
|
||||
|
||||
# AGENTS Guide for nix-dotfiles
|
||||
|
||||
This file is the quick-start map for coding agents working in this repository.
|
||||
Use this first, then follow the linked source files for full detail.
|
||||
|
||||
## Purpose and Scope
|
||||
|
||||
- Repository type: flake-based NixOS + Home Manager dotfiles/infrastructure.
|
||||
- Primary goals: safe system/user config edits, reproducible builds, and clean secrets handling.
|
||||
- Default assumption: preserve existing module patterns and avoid broad refactors unless requested.
|
||||
|
||||
## Source of Truth
|
||||
|
||||
Read these files before substantial changes:
|
||||
|
||||
- `.github/copilot-instructions.md`: Full repository guide for structure, workflows, dynamic system generation, module patterns, and SOPS handling.
|
||||
- `.github/instructions/ai-doc-attribution.instructions.md`: Markdown rule for top-of-document attribution when docs are fully AI-generated.
|
||||
- `flake.nix`: Flake inputs/outputs entrypoint; system generation begins here.
|
||||
- `lib/systems.nix`: Core dynamic config assembly (`genSystems`, `constructSystem`, and wrapper generators).
|
||||
- `systems/<hostname>/default.nix`: Per-host parameters (users, home, sops, server role, extra modules).
|
||||
- `systems/<hostname>/configuration.nix`: Main host config.
|
||||
- `modules/*.nix`: Global modules automatically imported into all systems.
|
||||
- `users/<username>/home.nix` and `users/<username>/default.nix`: Home Manager and user account configuration.
|
||||
- `hydra/jobs.nix` and `hydra/jobsets.nix`: CI/build orchestration details.
|
||||
|
||||
## Repo Mental Model
|
||||
|
||||
- `systems/` contains host-specific configs.
|
||||
- `modules/` contains global modules applied across hosts.
|
||||
- `users/` contains user and home-manager configs.
|
||||
- `lib/systems.nix` auto-discovers hosts and composes final configs.
|
||||
- SOPS secrets are colocated with hosts/users via `secrets.yaml` files.
|
||||
|
||||
## Dynamic Configuration Rules
|
||||
|
||||
- Hosts are auto-discovered from subdirectories in `systems/`.
|
||||
- Each host's `default.nix` feeds `constructSystem` parameters.
|
||||
- Effective module merge order matters. High-level order is: 1) base external
|
||||
modules, 2) host essentials (`hardware.nix`, `configuration.nix`), 3)
|
||||
host-specific modules from `systems/<host>/default.nix`, 4) global
|
||||
`modules/*.nix`, 5) optional SOPS and Home Manager/user layers.
|
||||
- Global modules load after host config, so explicit overrides may require `lib.mkForce` depending on target option.
|
||||
|
||||
## Editing Conventions
|
||||
|
||||
- Keep changes minimal and scoped to the requested behavior.
|
||||
- Preserve existing Nix style and option naming patterns.
|
||||
- Prefer module options + `lib.mkIf` toggles over hard-coded behavior.
|
||||
- Use `lib.mkDefault` for soft defaults and `lib.mkForce` only when necessary.
|
||||
- Do not commit plaintext secrets.
|
||||
- Update docs when behavior/workflow changes.
|
||||
|
||||
## Validation and Workflow
|
||||
|
||||
Typical local sequence:
|
||||
|
||||
1. Make targeted edits.
|
||||
2. Evaluate and build with `nix flake check` and `nix build .#<hostname>`.
|
||||
3. Optionally deploy/apply with `nh os switch` or `nh home switch`.
|
||||
4. For secrets-related changes, edit with `sops .../secrets.yaml` and validate expected `config.sops.secrets` evaluation paths.
|
||||
|
||||
## Secrets and Safety
|
||||
|
||||
- Secrets live in `systems/<hostname>/secrets.yaml` and `users/<username>/secrets.yaml`.
|
||||
- Use SOPS for create/edit/rekey operations.
|
||||
- During merge conflicts in encrypted files, prefer repository SOPS merge tooling (`utils/sops-mergetool.sh`, `utils/sops-mergetool-new.sh`).
|
||||
|
||||
## Agent and Tool Routing
|
||||
|
||||
When a specialized agent is available, route work by intent:
|
||||
|
||||
- `Explore`: Fast read-only repository exploration and Q&A.
|
||||
- `dependency-auditor`: Flake/module dependency security and CVE-oriented audits.
|
||||
- `security-researcher`: Read-only server security configuration audits.
|
||||
- `server-architect`: Server integration/review planning for `palatine-hill` style infra changes.
|
||||
|
||||
Use Nix lookup tooling for package/options discovery; prefer `unstable` channel when channel selection is available.
|
||||
|
||||
## Where To Look Next (By Task)
|
||||
|
||||
- Add a new host: see `.github/copilot-instructions.md` sections on "Adding a New NixOS System", plus `systems/<new-host>/default.nix`, `hardware.nix`, and `configuration.nix`.
|
||||
- Add/modify a global capability: see `modules/*.nix` and the `.github/copilot-instructions.md` section "Adding a Global Module to modules/".
|
||||
- Change user/home-manager behavior: see `users/<username>/home.nix` and `users/<username>/default.nix`.
|
||||
- Modify build/release automation: see `hydra/jobs.nix` and `hydra/jobsets.nix`.
|
||||
- Work with secrets: see `.sops.yaml`, `systems/*/secrets.yaml`, `users/*/secrets.yaml`, and the `.github/copilot-instructions.md` section "Secrets Management".
|
||||
- Validate module composition/debug evaluation: see `lib/systems.nix` and `nix eval .#nixosConfigurations.<host>...`.
|
||||
|
||||
## Documentation Attribution Rule
|
||||
|
||||
For Markdown docs (`**/*.md`):
|
||||
|
||||
- If a document is fully AI-generated, include explicit attribution near the top.
|
||||
- Accepted label includes "AI-generated documentation" wording.
|
||||
- Do not imply fully human authorship for fully AI-authored content.
|
||||
|
||||
## Quick Command Reference
|
||||
|
||||
- `nh os build`
|
||||
- `nh os switch`
|
||||
- `nh home switch`
|
||||
- `nix build .#<hostname>`
|
||||
- `nix flake check`
|
||||
- `nix eval .#nixosConfigurations.<hostname>.config.<path>`
|
||||
60
flake.lock
generated
60
flake.lock
generated
@@ -76,11 +76,11 @@
|
||||
},
|
||||
"locked": {
|
||||
"dir": "pkgs/firefox-addons",
|
||||
"lastModified": 1775534587,
|
||||
"narHash": "sha256-OLAoGTTwPVTH13C1e2Vcdff4WigTsk6hO5Y3sEcwl/s=",
|
||||
"lastModified": 1776398575,
|
||||
"narHash": "sha256-WArU6WOdWxzbzGqYk4w1Mucg+bw/SCl6MoSp+/cZMio=",
|
||||
"owner": "rycee",
|
||||
"repo": "nur-expressions",
|
||||
"rev": "9f1e4b7f5443c50cb4ccc2a376ba1058231e64b4",
|
||||
"rev": "05815686caf4e3678f5aeb5fd36e567886ab0d30",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
@@ -240,11 +240,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775556024,
|
||||
"narHash": "sha256-j1u/859OVS54rGlsvFqJdwKPEnFYCI+4pyfTiSfv1Xc=",
|
||||
"lastModified": 1776454077,
|
||||
"narHash": "sha256-7zSUFWsU0+jlD7WB3YAxQ84Z/iJurA5hKPm8EfEyGJk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "4bdfeff1d9b7473e6e58f73f5809576e8a69e406",
|
||||
"rev": "565e5349208fe7d0831ef959103c9bafbeac0681",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -281,11 +281,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1774778246,
|
||||
"narHash": "sha256-OX9Oba3/cHq1jMS1/ItCdxNuRBH3291Lg727nHOzYnc=",
|
||||
"lastModified": 1776426061,
|
||||
"narHash": "sha256-3rROoGl8xBsIOM+5m+qZS4GJnsdQPAH3NJJe1OUfJ5o=",
|
||||
"owner": "hyprwm",
|
||||
"repo": "contrib",
|
||||
"rev": "ca3c381df6018e6c400ceac994066427c98fe323",
|
||||
"rev": "1f71628d86a7701fd5ba0f8aeabe15376f4c6afc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -335,11 +335,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775365369,
|
||||
"narHash": "sha256-DgH5mveLoau20CuTnaU5RXZWgFQWn56onQ4Du2CqYoI=",
|
||||
"lastModified": 1775970782,
|
||||
"narHash": "sha256-7jt9Vpm48Yy5yAWigYpde+HxtYEpEuyzIQJF4VYehhk=",
|
||||
"owner": "Mic92",
|
||||
"repo": "nix-index-database",
|
||||
"rev": "cef5cf82671e749ac87d69aadecbb75967e6f6c3",
|
||||
"rev": "bedba5989b04614fc598af9633033b95a937933f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -438,11 +438,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775331627,
|
||||
"narHash": "sha256-przIxCbTrNgLzcBlNPGZRfZbiPLzUkLUtNS05Ekcogk=",
|
||||
"lastModified": 1776036369,
|
||||
"narHash": "sha256-TxBJY5IwDu3peDIK3b9+A7pwqBaFRCAIllaRSfYMQtI=",
|
||||
"owner": "NuschtOS",
|
||||
"repo": "nixos-modules",
|
||||
"rev": "b4cc33254b872b286b9fe481e60e3fc2abc78072",
|
||||
"rev": "2bea807180b3931cf8765078205fd9171dbfd2b5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -500,11 +500,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1775423009,
|
||||
"narHash": "sha256-vPKLpjhIVWdDrfiUM8atW6YkIggCEKdSAlJPzzhkQlw=",
|
||||
"lastModified": 1776169885,
|
||||
"narHash": "sha256-l/iNYDZ4bGOAFQY2q8y5OAfBBtrDAaPuRQqWaFHVRXM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "68d8aa3d661f0e6bd5862291b5bb263b2a6595c9",
|
||||
"rev": "4bd9165a9165d7b5e33ae57f3eecbcb28fb231c9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -550,11 +550,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775036584,
|
||||
"narHash": "sha256-zW0lyy7ZNNT/x8JhzFHBsP2IPx7ATZIPai4FJj12BgU=",
|
||||
"lastModified": 1775585728,
|
||||
"narHash": "sha256-8Psjt+TWvE4thRKktJsXfR6PA/fWWsZ04DVaY6PUhr4=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "4e0eb042b67d863b1b34b3f64d52ceb9cd926735",
|
||||
"rev": "580633fa3fe5fc0379905986543fd7495481913d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -594,11 +594,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775531562,
|
||||
"narHash": "sha256-G83GDxQo6lqO5aeTSD5RFLhnh2g6DzJpSvSju2EjjrQ=",
|
||||
"lastModified": 1776395632,
|
||||
"narHash": "sha256-Mi1uF5f2FsdBIvy+v7MtsqxD3Xjhd0ARJdwoqqqPtJo=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "d8b1b209203665924c81eabf750492530754f27e",
|
||||
"rev": "8087ff1f47fff983a1fba70fa88b759f2fd8ae97",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -614,11 +614,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775365543,
|
||||
"narHash": "sha256-f50qrK0WwZ9z5EdaMGWOTtALgSF7yb7XwuE7LjCuDmw=",
|
||||
"lastModified": 1776119890,
|
||||
"narHash": "sha256-Zm6bxLNnEOYuS/SzrAGsYuXSwk3cbkRQZY0fJnk8a5M=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "a4ee2de76efb759fe8d4868c33dec9937897916f",
|
||||
"rev": "d4971dd58c6627bfee52a1ad4237637c0a2fb0cd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -647,11 +647,11 @@
|
||||
"tinted-zed": "tinted-zed"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1775429060,
|
||||
"narHash": "sha256-wbFF5cRxQOCzL/wHOKYm21t5AHPH2Lfp0mVPCOAvEoc=",
|
||||
"lastModified": 1776170745,
|
||||
"narHash": "sha256-Tl1aZVP5EIlT+k0+iAKH018GLHJpLz3hhJ0LNQOWxCc=",
|
||||
"owner": "danth",
|
||||
"repo": "stylix",
|
||||
"rev": "d27951a6539951d87f75cf0a7cda8a3a24016019",
|
||||
"rev": "e3861617645a43c9bbefde1aa6ac54dd0a44bfa9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
10
flake.nix
10
flake.nix
@@ -164,19 +164,23 @@
|
||||
lib = self;
|
||||
}
|
||||
);
|
||||
packageSetup = import ./pkgs/default.nix { inherit nixpkgs; };
|
||||
inherit (packageSetup) localPackagesOverlay;
|
||||
inherit (lib.adev.systems) genSystems getImages;
|
||||
inherit (self) outputs; # for hydra
|
||||
in
|
||||
rec {
|
||||
inherit lib; # for allowing use of custom functions in nix repl
|
||||
|
||||
overlays.default = localPackagesOverlay;
|
||||
|
||||
hydraJobs = import ./hydra/jobs.nix { inherit inputs outputs systems; };
|
||||
formatter = forEachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt);
|
||||
|
||||
nixosConfigurations = genSystems inputs outputs src (src + "/systems");
|
||||
homeConfigurations = {
|
||||
"alice" = inputs.home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; };
|
||||
pkgs = packageSetup.mkPkgs "x86_64-linux";
|
||||
modules = [
|
||||
inputs.stylix.homeModules.stylix
|
||||
inputs.sops-nix.homeManagerModules.sops
|
||||
@@ -203,9 +207,7 @@
|
||||
qcow = getImages nixosConfigurations "qcow";
|
||||
};
|
||||
|
||||
packages.x86_64-linux.lego-latest =
|
||||
nixpkgs.legacyPackages.x86_64-linux.callPackage ./pkgs/lego-latest/default.nix
|
||||
{ };
|
||||
packages = forEachSystem packageSetup.mkPackages;
|
||||
|
||||
checks = import ./checks.nix { inherit inputs forEachSystem formatter; };
|
||||
devShells = import ./shell.nix { inherit inputs forEachSystem checks; };
|
||||
|
||||
@@ -172,6 +172,7 @@ rec {
|
||||
modules = [
|
||||
inputs.nixos-modules.nixosModule
|
||||
inputs.nix-index-database.nixosModules.nix-index
|
||||
{ nixpkgs.overlays = [ outputs.overlays.default ]; }
|
||||
(genHostName hostname)
|
||||
(configPath + "/hardware.nix")
|
||||
(configPath + "/configuration.nix")
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
enable = lib.mkDefault true;
|
||||
flags = [ "--accept-flake-config" ];
|
||||
randomizedDelaySec = "1h";
|
||||
runGarbageCollection = true;
|
||||
persistent = true;
|
||||
flake = "git+ssh://nayeonie.com/ahuston-0/nix-dotfiles.git";
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
libnotify,
|
||||
}:
|
||||
let
|
||||
maintainers = import ../maintainers.nix;
|
||||
bins = [
|
||||
jq
|
||||
bitwarden-cli
|
||||
@@ -64,6 +65,7 @@ stdenv.mkDerivation {
|
||||
description = "Wrapper for Bitwarden and Rofi";
|
||||
homepage = "https://github.com/mattydebie/bitwarden-rofi";
|
||||
license = licenses.gpl3;
|
||||
maintainers = [ maintainers.alice ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
|
||||
|
||||
52
pkgs/claurst/default.nix
Normal file
52
pkgs/claurst/default.nix
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
rustPlatform,
|
||||
pkg-config,
|
||||
openssl,
|
||||
alsa-lib,
|
||||
dbus,
|
||||
libxkbcommon,
|
||||
libxcb,
|
||||
}:
|
||||
|
||||
let
|
||||
maintainers = import ../maintainers.nix;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "claurst";
|
||||
version = "0.0.9";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Kuberwastaken";
|
||||
repo = "claurst";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-bTQHtZGZxhEAki0JxSC8smAC3w+otm8ubHvZ9MvwDaE=";
|
||||
};
|
||||
|
||||
cargoRoot = "src-rust";
|
||||
cargoHash = "sha256-6+B43spqmUZ983YMl5UBH5647DcUOS2ngw5ChMIPFFo=";
|
||||
buildAndTestSubdir = "src-rust";
|
||||
doCheck = false;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
openssl
|
||||
alsa-lib
|
||||
dbus
|
||||
libxkbcommon
|
||||
libxcb
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Terminal coding agent written in Rust";
|
||||
homepage = "https://github.com/Kuberwastaken/claurst";
|
||||
license = licenses.gpl3Only;
|
||||
mainProgram = "claurst";
|
||||
maintainers = [ maintainers.alice ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
33
pkgs/default.nix
Normal file
33
pkgs/default.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
{ nixpkgs }:
|
||||
let
|
||||
localPackagesOverlay = final: _prev: {
|
||||
lego-latest = final.callPackage ./lego-latest/default.nix { };
|
||||
claurst = final.callPackage ./claurst/default.nix { };
|
||||
};
|
||||
|
||||
mkPkgs =
|
||||
system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ localPackagesOverlay ];
|
||||
};
|
||||
|
||||
mkPackages =
|
||||
system:
|
||||
let
|
||||
pkgs = mkPkgs system;
|
||||
in
|
||||
{
|
||||
inherit (pkgs)
|
||||
lego-latest
|
||||
claurst
|
||||
;
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit
|
||||
localPackagesOverlay
|
||||
mkPkgs
|
||||
mkPackages
|
||||
;
|
||||
}
|
||||
8
pkgs/maintainers.nix
Normal file
8
pkgs/maintainers.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
alice = {
|
||||
name = "Alice Huston";
|
||||
email = "aliceghuston@gmail.com";
|
||||
github = "ahuston-0";
|
||||
githubId = 43225907;
|
||||
};
|
||||
}
|
||||
@@ -54,6 +54,12 @@
|
||||
"starcoder2:7b"
|
||||
];
|
||||
};
|
||||
avahi = {
|
||||
enable = true;
|
||||
#publish.enable = true;
|
||||
nssmdns4 = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
flatpak.enable = true;
|
||||
calibre-web = {
|
||||
# temp disable this
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
attic-client
|
||||
amdgpu_top
|
||||
android-tools
|
||||
bat
|
||||
bitwarden-cli
|
||||
bfg-repo-cleaner
|
||||
brightnessctl
|
||||
@@ -19,7 +18,6 @@
|
||||
#claude-code
|
||||
croc
|
||||
deadnix
|
||||
direnv
|
||||
easyeffects
|
||||
eza
|
||||
fanficfare
|
||||
@@ -107,4 +105,13 @@
|
||||
zoom-us
|
||||
zoxide
|
||||
];
|
||||
programs = {
|
||||
appimage = {
|
||||
enable = true;
|
||||
binfmt = true;
|
||||
};
|
||||
bat.enable = true;
|
||||
direnv.enable = true;
|
||||
kdeconnect.enable = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,6 +12,107 @@
|
||||
options zfs zfs_arc_min=82463372083
|
||||
options zfs zfs_arc_max=192414534860
|
||||
'';
|
||||
|
||||
initrd.systemd.services = {
|
||||
zfs-import-zfs-primary = {
|
||||
description = "Import ZFS-primary pool in initrd";
|
||||
wantedBy = [ "initrd-root-fs.target" ];
|
||||
wants = [ "systemd-udev-settle.service" ];
|
||||
after = [ "systemd-udev-settle.service" ];
|
||||
before = [
|
||||
"sysroot.mount"
|
||||
"initrd-root-fs.target"
|
||||
];
|
||||
unitConfig.DefaultDependencies = "no";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
path = with pkgs; [
|
||||
coreutils
|
||||
gawk
|
||||
zfs
|
||||
];
|
||||
script = ''
|
||||
ZFS_FORCE="-f"
|
||||
msg=""
|
||||
|
||||
for o in $(cat /proc/cmdline); do
|
||||
case "$o" in
|
||||
zfs_force|zfs_force=1|zfs_force=y)
|
||||
ZFS_FORCE="-f"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
pool_ready() {
|
||||
pool="$1"
|
||||
state="$(zpool import -d /dev/disk/by-id/ 2>/dev/null | awk '/pool: '"$pool"'/ { found = 1 }; /state:/ { if (found == 1) { print $2; exit } }; END { if (found == 0) { print "MISSING" } }')"
|
||||
if [ "$state" = "ONLINE" ]; then
|
||||
return 0
|
||||
fi
|
||||
echo "Pool $pool in state $state, waiting"
|
||||
return 1
|
||||
}
|
||||
|
||||
pool_imported() {
|
||||
pool="$1"
|
||||
zpool list "$pool" >/dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
pool_import() {
|
||||
pool="$1"
|
||||
zpool import -d /dev/disk/by-id/ -N $ZFS_FORCE "$pool"
|
||||
}
|
||||
|
||||
echo -n 'importing root ZFS pool "ZFS-primary"...'
|
||||
# Loop until import succeeds, because by-id devices may not be discovered yet.
|
||||
if ! pool_imported "ZFS-primary"; then
|
||||
trial=1
|
||||
while [ "$trial" -le 60 ]; do
|
||||
if pool_ready "ZFS-primary" >/dev/null && msg="$(pool_import "ZFS-primary" 2>&1)"; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
echo -n .
|
||||
trial=$((trial + 1))
|
||||
done
|
||||
echo
|
||||
if [ -n "$msg" ]; then
|
||||
echo "$msg"
|
||||
fi
|
||||
pool_imported "ZFS-primary" || pool_import "ZFS-primary" # Try one last time, e.g. to import a degraded pool.
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
zfs-load-nix-key = {
|
||||
description = "Load ZFS key for ZFS-primary/nix in initrd";
|
||||
wantedBy = [ "initrd-fs.target" ];
|
||||
requires = [
|
||||
"sysroot.mount"
|
||||
"zfs-import-zfs-primary.service"
|
||||
];
|
||||
after = [
|
||||
"sysroot.mount"
|
||||
"zfs-import-zfs-primary.service"
|
||||
];
|
||||
before = [
|
||||
"initrd-fs.target"
|
||||
"sysroot-nix.mount"
|
||||
];
|
||||
unitConfig.DefaultDependencies = "no";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
path = with pkgs; [ zfs ];
|
||||
script = ''
|
||||
key_file="/sysroot/crypto/keys/zfs-nix-store-key"
|
||||
zfs load-key -L "file://$key_file" "ZFS-primary/nix"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
@@ -82,69 +183,4 @@
|
||||
};
|
||||
};
|
||||
|
||||
# hack to make sure pool is imported before keys are loaded,
|
||||
# and also keys are imported before things get mounted
|
||||
# note to self: move zfs encryption over to luks lol
|
||||
boot.initrd.postResumeCommands = ''
|
||||
ZFS_FORCE="-f"
|
||||
|
||||
for o in $(cat /proc/cmdline); do
|
||||
case $o in
|
||||
zfs_force|zfs_force=1|zfs_force=y)
|
||||
ZFS_FORCE="-f"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
poolReady() {
|
||||
pool="$1"
|
||||
state="$("zpool" import -d "/dev/disk/by-id/" 2>/dev/null | "awk" "/pool: $pool/ { found = 1 }; /state:/ { if (found == 1) { print \$2; exit } }; END { if (found == 0) { print \"MISSING\" } }")"
|
||||
if [[ "$state" = "ONLINE" ]]; then
|
||||
return 0
|
||||
else
|
||||
echo "Pool $pool in state $state, waiting"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
poolImported() {
|
||||
pool="$1"
|
||||
"zpool" list "$pool" >/dev/null 2>/dev/null
|
||||
}
|
||||
poolImport() {
|
||||
pool="$1"
|
||||
"zpool" import -d "/dev/disk/by-id/" -N $ZFS_FORCE "$pool"
|
||||
}
|
||||
|
||||
echo -n "importing root ZFS pool \"ZFS-primary\"..."
|
||||
# Loop across the import until it succeeds, because the devices needed may not be discovered yet.
|
||||
if ! poolImported "ZFS-primary"; then
|
||||
for trial in `seq 1 60`; do
|
||||
poolReady "ZFS-primary" > /dev/null && msg="$(poolImport "ZFS-primary" 2>&1)" && break
|
||||
sleep 1
|
||||
echo -n .
|
||||
done
|
||||
echo
|
||||
if [[ -n "$msg" ]]; then
|
||||
echo "$msg";
|
||||
fi
|
||||
poolImported "ZFS-primary" || poolImport "ZFS-primary" # Try one last time, e.g. to import a degraded pool.
|
||||
fi
|
||||
|
||||
# let root mount and everything, then manually unlock stuff
|
||||
load_zfs_nix() {
|
||||
local device="/dev/disk/by-uuid/8bfaa32b-09dd-45c8-831e-05e80be82f9e"
|
||||
local mountPoint="/"
|
||||
local options="x-initrd.mount,noatime,nodiratime"
|
||||
local fsType="ext4"
|
||||
|
||||
echo "manually mounting key location, then unmounting"
|
||||
udevadm settle
|
||||
|
||||
mountFS "$device" "$(escapeFstab "$mountPoint")" "$(escapeFstab "$options")" "$fsType"
|
||||
|
||||
zfs load-key -L "file://$targetRoot/crypto/keys/zfs-nix-store-key" "ZFS-primary/nix"
|
||||
umount "$targetRoot/"
|
||||
}
|
||||
|
||||
load_zfs_nix
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@
|
||||
|
||||
gocryptfs
|
||||
awscli2
|
||||
claurst
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
@@ -194,21 +194,23 @@ in
|
||||
onSave = true;
|
||||
forwardSearchAfter = true;
|
||||
};
|
||||
forwardSearch = {
|
||||
executable = "zathura";
|
||||
args = [
|
||||
"--synctex-forward"
|
||||
"%l:1:%f"
|
||||
"-x"
|
||||
"zed %%{input}:%%{line}"
|
||||
"%p"
|
||||
];
|
||||
};
|
||||
#forwardSearch = {
|
||||
# #executable = "zathura";
|
||||
# args = [
|
||||
# "--synctex-forward"
|
||||
# "%l:1:%f"
|
||||
# "-x"
|
||||
# "zed %%{input}:%%{line}"
|
||||
# "%p"
|
||||
# ];
|
||||
#};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services.gnome-keyring.enable = true;
|
||||
|
||||
home.packages = with pkgs; [
|
||||
cmake
|
||||
shellcheck
|
||||
@@ -268,7 +270,6 @@ in
|
||||
bitwarden-cli
|
||||
bitwarden-menu
|
||||
wtype
|
||||
zathura
|
||||
obsidian
|
||||
libreoffice-qt-fresh
|
||||
wlr-randr
|
||||
@@ -282,5 +283,8 @@ in
|
||||
|
||||
pdf4qt
|
||||
masterpdfeditor4
|
||||
|
||||
gitea-mcp-server
|
||||
tea
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user