A NixOS-based system for managing personal data across three tiers: - Tier 1: Configuration (shareable via git) - Tier 2: Syncable data (nb + Syncthing) - Tier 3: Large data (self-hosted services + backup) Includes: - NixOS modules for nb, Syncthing, backup (restic) - Server modules for Forgejo, Immich, Jellyfin - Helper scripts (usync, ustatus) - Comprehensive documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
142 lines
4.0 KiB
Nix
142 lines
4.0 KiB
Nix
{
|
|
description = "Ultimate Notetaking, Sync & Backup System - NixOS configuration for managing personal data";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
home-manager = {
|
|
url = "github:nix-community/home-manager";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
sops-nix = {
|
|
url = "github:Mic92/sops-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
# Optional: Neovim distribution
|
|
# nixvim = {
|
|
# url = "github:nix-community/nixvim";
|
|
# inputs.nixpkgs.follows = "nixpkgs";
|
|
# };
|
|
};
|
|
|
|
outputs = { self, nixpkgs, home-manager, sops-nix, ... }@inputs:
|
|
let
|
|
# Supported systems
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
|
|
|
|
# Helper to generate outputs for all systems
|
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
|
|
|
# Nixpkgs instantiated for each system
|
|
nixpkgsFor = forAllSystems (system: import nixpkgs {
|
|
inherit system;
|
|
config.allowUnfree = false; # FOSS only
|
|
});
|
|
|
|
# Shared modules for all hosts
|
|
sharedModules = [
|
|
./modules/nb.nix
|
|
./modules/syncthing.nix
|
|
./modules/backup.nix
|
|
sops-nix.nixosModules.sops
|
|
];
|
|
|
|
# Create a NixOS configuration for a host
|
|
mkHost = { hostname, system ? "x86_64-linux", extraModules ? [] }:
|
|
nixpkgs.lib.nixosSystem {
|
|
inherit system;
|
|
specialArgs = { inherit inputs; };
|
|
modules = sharedModules ++ [
|
|
./hosts/${hostname}/configuration.nix
|
|
home-manager.nixosModules.home-manager
|
|
{
|
|
home-manager.useGlobalPkgs = true;
|
|
home-manager.useUserPackages = true;
|
|
# home-manager.users.YOUR_USERNAME = import ./home;
|
|
}
|
|
] ++ extraModules;
|
|
};
|
|
|
|
in {
|
|
# NixOS configurations
|
|
# Uncomment and customize for your hosts:
|
|
#
|
|
# nixosConfigurations = {
|
|
# desktop = mkHost { hostname = "desktop"; };
|
|
# laptop = mkHost { hostname = "laptop"; };
|
|
# server = mkHost {
|
|
# hostname = "server";
|
|
# extraModules = [
|
|
# ./modules/server/forgejo.nix
|
|
# ./modules/server/immich.nix
|
|
# ./modules/server/jellyfin.nix
|
|
# ];
|
|
# };
|
|
# };
|
|
|
|
# Development shell with all tools
|
|
devShells = forAllSystems (system:
|
|
let
|
|
pkgs = nixpkgsFor.${system};
|
|
in {
|
|
default = pkgs.mkShell {
|
|
name = "unsbs-dev";
|
|
|
|
packages = with pkgs; [
|
|
# Tier 2: Notes & Sync
|
|
nb # Notebook CLI
|
|
syncthing # File sync
|
|
unison # Alternative sync
|
|
|
|
# Tier 3: Backup & Cloud
|
|
restic # Backup
|
|
rclone # Cloud storage
|
|
|
|
# Development
|
|
git
|
|
neovim
|
|
jq
|
|
ripgrep
|
|
fd
|
|
|
|
# Nix tools
|
|
nil # Nix LSP
|
|
nixpkgs-fmt # Nix formatter
|
|
];
|
|
|
|
shellHook = ''
|
|
echo "Ultimate Notetaking, Sync & Backup System"
|
|
echo ""
|
|
echo "Available tools:"
|
|
echo " nb - Note-taking CLI"
|
|
echo " syncthing - File synchronization"
|
|
echo " unison - Alternative file sync"
|
|
echo " restic - Backup"
|
|
echo " rclone - Cloud storage"
|
|
echo ""
|
|
echo "Run 'nb help' to get started with notes."
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
|
|
# Export modules for use in other flakes
|
|
nixosModules = {
|
|
nb = import ./modules/nb.nix;
|
|
syncthing = import ./modules/syncthing.nix;
|
|
backup = import ./modules/backup.nix;
|
|
default = { imports = sharedModules; };
|
|
};
|
|
|
|
# Templates for creating new hosts
|
|
templates = {
|
|
default = {
|
|
path = ./templates/host;
|
|
description = "Template for a new host configuration";
|
|
};
|
|
};
|
|
};
|
|
}
|