refactor: gigantic refactor

This commit is contained in:
leonhard committed 2026-11-12 13:26:08 +01:00
1 parent d1e2bde503
commit 0474f7bbb4
50 files changed
+230 -205

No files matched your search

+21 -44
View File
@@ -2,75 +2,52 @@
description = "leonhard's nix config"; description = "leonhard's nix config";
inputs = { inputs = {
systems.url = "github:nix-systems/default";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
sops-nix = { sops-nix = {
url = "github:mic92/sops-nix"; url = "github:mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nixvim.url = "github:nix-community/nixvim"; nixvim.url = "github:nix-community/nixvim";
}; };
outputs = outputs =
{ {
self, self,
systems,
nixpkgs, nixpkgs,
home-manager,
sops-nix,
nixvim,
... ...
}@inputs: }@inputs:
let let
inherit (self) outputs; inherit (nixpkgs) lib;
system = "x86_64-linux"; forAllSystems = lib.genAttrs (import systems);
pkgs = import nixpkgs { pkgsFor =
system:
import nixpkgs {
inherit system; inherit system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
homeImports = [
./options.nix
nixvim.homeModules.nixvim
./home-manager/base
];
mkNixosConfig = name: modules: {
"${name}" = nixpkgs.lib.nixosSystem {
modules = modules ++ [
./nixos/base
./options.nix
home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops
{
home-manager = {
useGlobalPkgs = true;
extraSpecialArgs = { inherit inputs outputs; };
backupFileExtension = "hm.bak";
users.leonhard.imports = homeImports ++ [
./home-manager/leonhard
];
};
}
];
specialArgs = { inherit inputs outputs; };
};
};
mkHomeConfig = name: modules: {
"${name}" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = modules ++ homeImports;
extraSpecialArgs = { inherit inputs outputs; };
};
};
in in
{ {
nixosConfigurations = nixosConfigurations = import ./hosts { inherit self inputs; };
(mkNixosConfig "desktop" [ ./nixos/desktop ]) // (mkNixosConfig "server" [ ./nixos/server ]);
homeConfigurations = mkHomeConfig "leonhard" [ ./home-manager/leonhard ]; homeConfigurations = import ./standalone { inherit self inputs; };
packages = forAllSystems (
system:
import ./pkgs {
pkgs = pkgsFor system;
inherit inputs;
}
);
}; };
} }
-52
View File
@@ -1,52 +0,0 @@
{
config,
osConfig ? null,
inputs,
lib,
pkgs,
...
}:
let
mkDefaultSharedAttrs =
base: defaults: lib.mapAttrs (_: v: lib.mkDefault v) (lib.filterAttrs (k: _: base ? ${k}) defaults);
in
{
imports = [
./git.nix
./fish.nix
./nixvim
./hyprland.nix
./kitty.nix
./rofi
];
kekleo = lib.mkIf (osConfig != null) (mkDefaultSharedAttrs config.kekleo (osConfig.kekleo or { }));
nix =
let
flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs;
in
lib.mkDefault {
package = pkgs.nix;
settings = {
experimental-features = osConfig.nix.settings.experimental-features or "nix-command flakes";
# Opinionated: disable global registry
flake-registry = "";
};
# Opinionated: make flake registry and nix path match flake inputs
registry = lib.mapAttrs (_: flake: { inherit flake; }) flakeInputs;
nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs;
};
xdg.enable = true;
programs.home-manager.enable = true;
# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
home.stateVersion = "25.11";
}
-30
View File
@@ -1,30 +0,0 @@
{
config,
lib,
...
}:
{
imports = [
./opts.nix
./keymaps.nix
./plugins
];
options.kekleo.neovim.enable = lib.mkEnableOption "neovim";
config = lib.mkIf config.kekleo.neovim.enable {
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
defaultEditor = true;
colorschemes.tokyonight.enable = true;
clipboard.providers.wl-copy.enable = true;
globals.mapleader = " ";
};
};
}
@@ -1,19 +0,0 @@
{
lib,
config,
...
}:
{
options.kekleo.neovim.typst.enable = lib.mkEnableOption "typst editing";
config = {
programs.nixvim = lib.mkIf config.kekleo.neovim.typst.enable {
dependencies.tinymist.enable = true;
dependencies.websocat.enable = true;
plugins.typst-preview.enable = true;
plugins.lsp.servers.tinymist.enable = true;
};
};
}
-9
View File
@@ -1,9 +0,0 @@
{
home = {
username = "leonhard";
homeDirectory = "/home/leonhard";
};
kekleo.neovim.enable = true;
kekleo.neovim.typst.enable = true;
}
+18
View File
@@ -0,0 +1,18 @@
{
imports = [
./git.nix
./firefox.nix
./fish.nix
./nixvim.nix
./hyprland.nix
./kitty.nix
./rofi
];
home = {
username = "leonhard";
homeDirectory = "/home/leonhard";
};
xdg.enable = true;
}
+1 -1
View File
@@ -4,7 +4,7 @@
... ...
}: }:
{ {
config = lib.mkIf config.kekleo.graphical { config = lib.mkIf config.nix-leonhard.graphical {
programs.firefox.enable = true; programs.firefox.enable = true;
}; };
} }
File renamed without changes.
File renamed without changes.
@@ -6,7 +6,7 @@
}: }:
{ {
config = lib.mkIf config.kekleo.graphical { config = lib.mkIf config.nix-leonhard.graphical {
home.packages = with pkgs; [ nordzy-cursor-theme ]; home.packages = with pkgs; [ nordzy-cursor-theme ];
programs.waybar.enable = true; programs.waybar.enable = true;
@@ -5,7 +5,7 @@
... ...
}: }:
{ {
config = lib.mkIf config.kekleo.graphical { config = lib.mkIf config.nix-leonhard.graphical {
programs.kitty = { programs.kitty = {
enable = true; enable = true;
themeFile = "tokyo_night_night"; themeFile = "tokyo_night_night";
+13
View File
@@ -0,0 +1,13 @@
{
config,
lib,
self,
...
}:
{
options.nix-leonhard.neovim.enable = lib.mkEnableOption "neovim";
config = lib.mkIf config.nix-leonhard.neovim.enable {
home.packages = [ self.packages.nixvim ];
};
}
@@ -4,7 +4,7 @@
... ...
}: }:
{ {
config = lib.mkIf config.kekleo.graphical { config = lib.mkIf config.nix-leonhard.graphical {
programs.rofi = { programs.rofi = {
enable = true; enable = true;
theme = ./tokyonight.rasi; theme = ./tokyonight.rasi;
File renamed without changes.
+30
View File
@@ -0,0 +1,30 @@
{
self,
inputs,
...
}:
let
inherit (inputs.nixpkgs.lib) nixosSystem;
specialArgs = { inherit inputs self; };
mkNixosSystem =
modules:
nixosSystem {
inherit specialArgs;
modules = modules ++ [
../system
../options.nix
inputs.home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.leonhard = ../home/default.nix;
}
];
};
in
{
desktop = mkNixosSystem [ ./desktop ];
server = mkNixosSystem [ ./server ];
}
File renamed without changes.
@@ -1,5 +1,6 @@
{ {
config, config,
lib,
... ...
}: }:
{ {
@@ -11,13 +12,21 @@
./vaultwarden.nix ./vaultwarden.nix
]; ];
kekleo.graphical = false; options.nix-leonhard.domain =
with lib.types;
lib.mkOption {
type = str;
default = "";
description = "Domain of the device.";
};
nix-leonhard.graphical = false;
users.users.leonhard = { users.users.leonhard = {
initialPassword = "leonhard"; initialPassword = "leonhard";
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = config.kekleo.publicKeys; openssh.authorizedKeys.keys = config.nix-leonhard.publicKeys;
}; };
networking = { networking = {
@@ -53,9 +62,9 @@
security.acme = { security.acme = {
acceptTerms = true; acceptTerms = true;
defaults.email = "admin@${config.kekleo.domain}"; defaults.email = "admin@${config.nix-leonhard.domain}";
defaults.webroot = "/var/lib/acme/acme-challenge/"; defaults.webroot = "/var/lib/acme/acme-challenge/";
certs.${config.kekleo.domain} = { certs.${config.nix-leonhard.domain} = {
group = config.services.nginx.group; group = config.services.nginx.group;
}; };
}; };
@@ -63,9 +72,9 @@
services.nginx = { services.nginx = {
enable = true; enable = true;
virtualHosts.${config.kekleo.domain} = { virtualHosts.${config.nix-leonhard.domain} = {
forceSSL = true; forceSSL = true;
useACMEHost = config.kekleo.domain; useACMEHost = config.nix-leonhard.domain;
locations."/.well-known/".root = config.security.acme.defaults.webroot; locations."/.well-known/".root = config.security.acme.defaults.webroot;
}; };
}; };
File renamed without changes.
File renamed without changes.
@@ -3,7 +3,7 @@
... ...
}: }:
let let
domain = config.kekleo.domain; domain = config.nix-leonhard.domain;
gitDomain = "git.${domain}"; gitDomain = "git.${domain}";
in in
{ {
@@ -24,7 +24,7 @@ in
virtualHosts.${gitDomain} = { virtualHosts.${gitDomain} = {
forceSSL = true; forceSSL = true;
useACMEHost = config.kekleo.domain; useACMEHost = config.nix-leonhard.domain;
locations."/" = { locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.gitea.settings.server.HTTP_PORT}"; proxyPass = "http://127.0.0.1:${toString config.services.gitea.settings.server.HTTP_PORT}";
proxyWebsockets = true; proxyWebsockets = true;
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
@@ -3,7 +3,7 @@
... ...
}: }:
let let
domain = config.kekleo.domain; domain = config.nix-leonhard.domain;
vaultDomain = "bitwarden.${domain}"; vaultDomain = "bitwarden.${domain}";
in in
{ {
@@ -29,7 +29,7 @@ in
virtualHosts.${vaultDomain} = { virtualHosts.${vaultDomain} = {
forceSSL = true; forceSSL = true;
useACMEHost = config.kekleo.domain; useACMEHost = config.nix-leonhard.domain;
locations."/" = { locations."/" = {
proxyPass = "http://127.0.0.1:${toString config.services.vaultwarden.config.ROCKET_PORT}"; proxyPass = "http://127.0.0.1:${toString config.services.vaultwarden.config.ROCKET_PORT}";
proxyWebsockets = true; proxyWebsockets = true;
Binary file not shown.
+1 -11
View File
@@ -3,17 +3,7 @@
... ...
}: }:
{ {
options.kekleo = with lib.types; { options.nix-leonhard = with lib.types; {
domain = lib.mkOption {
type = str;
default = "";
description = "Domain of the device.";
};
publicKeys = lib.mkOption {
type = listOf str;
default = [ ];
description = "List of public keys to use for ssh login, secret encryption, etc.";
};
graphical = lib.mkOption { graphical = lib.mkOption {
type = bool; type = bool;
default = true; default = true;
+11
View File
@@ -0,0 +1,11 @@
{
pkgs,
inputs,
...
}:
{
nixvim = inputs.nixvim.lib.buildNixvimWith {
inherit (pkgs) system;
modules = [ ./nixvim ];
};
}
+21
View File
@@ -0,0 +1,21 @@
{
imports = [
./opts.nix
./keymaps.nix
./plugins
];
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
defaultEditor = true;
colorschemes.tokyonight.enable = true;
clipboard.providers.wl-copy.enable = true;
globals.mapleader = " ";
};
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+10
View File
@@ -0,0 +1,10 @@
{
programs.nixvim = {
dependencies.tinymist.enable = true;
dependencies.websocat.enable = true;
plugins.typst-preview.enable = true;
plugins.lsp.servers.tinymist.enable = true;
};
}
+28
View File
@@ -0,0 +1,28 @@
{
config,
lib,
inputs,
...
}:
{
nix =
let
flakeInputs = lib.filterAttrs (_: v: lib.isType "flake" v) inputs;
in
{
# pin the registry to avoid downloading and evaling a new nixpkgs version every time
registry = lib.mapAttrs (_: v: { flake = v; }) flakeInputs;
# set the path for channels compat
nixPath = lib.mapAttrsToList (key: _: "${key}=flake:${key}") config.nix.registry;
settings.experimental-features = "nix-command flakes";
channels.enable = false;
};
programs.home-manager.enable = true;
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
home.stateVersion = "25.11";
}
+25
View File
@@ -0,0 +1,25 @@
{
pkgs,
inputs,
...
}:
let
inherit (inputs.home-manager.lib) homeManagerConfiguration;
extraSpecialArgs = { inherit inputs; };
in
{
leonhard = homeManagerConfiguration {
inherit pkgs extraSpecialArgs;
modules = [
./base.nix
../home
../options.nix
{
nix-leonhard.graphical = false;
nix-leonhard.neovim.enable = true;
nix-leonhard.neovim.typst.enable = true;
}
];
};
}
+1 -24
View File
@@ -1,38 +1,15 @@
{ {
inputs,
lib,
pkgs, pkgs,
... ...
}: }:
{ {
imports = [ imports = [
./fish.nix ./fish.nix
./firefox.nix
./hyprland.nix ./hyprland.nix
./ly.nix ./ly.nix
./nix.nix
]; ];
nix =
let
flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs;
in
{
settings = {
experimental-features = [
"nix-command"
"flakes"
];
# Opinionated: disable global registry
flake-registry = "";
};
# Opinionated: disable channels
channel.enable = false;
# Opinionated: make flake registry and nix path match flake inputs
registry = lib.mapAttrs (_: flake: { inherit flake; }) flakeInputs;
nixPath = lib.mapAttrsToList (n: _: "${n}=flake:${n}") flakeInputs;
};
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
vim vim
wget wget
File renamed without changes.
@@ -4,7 +4,7 @@
... ...
}: }:
{ {
config = lib.mkIf config.kekleo.graphical { config = lib.mkIf config.nix-leonhard.graphical {
programs.hyprland.enable = true; programs.hyprland.enable = true;
}; };
} }
+1 -1
View File
@@ -4,7 +4,7 @@
... ...
}: }:
{ {
config = lib.mkIf config.kekleo.graphical { config = lib.mkIf config.nix-leonhard.graphical {
services.displayManager.ly.enable = true; services.displayManager.ly.enable = true;
}; };
} }
+26
View File
@@ -0,0 +1,26 @@
{
config,
lib,
inputs,
...
}:
{
nix =
let
flakeInputs = lib.filterAttrs (_: v: lib.isType "flake" v) inputs;
in
{
# pin the registry to avoid downloading and evaling a new nixpkgs version every time
registry = lib.mapAttrs (_: v: { flake = v; }) flakeInputs;
# set the path for channels compat
nixPath = lib.mapAttrsToList (key: _: "${key}=flake:${key}") config.nix.registry;
settings.experimental-features = [
"nix-command"
"flakes"
];
channels.enable = false;
};
}